RTShader.cc

Go to the documentation of this file.
00001 #include <gra/shader/RTShader.h>
00002 
00003 using namespace gra;
00004 
00005 Color3f* RTShader::illuminatePoint(const Vector3& location,
00006                                    const Vector3& normal,
00007                                    const Vector3& eyeDir,
00008                                    float          eyeDist,
00009                                    double*        pNV,
00010                                    const Matrix4* pTrMat)
00011 {
00012     static PointEnv env;
00013     
00014     if (!_pReflectionModel) return NULL;
00015     
00016     env.viewerDir.set(eyeDir);
00017     env.intersection.set(location);
00018     env.normal.set(normal);
00019     env.normalOrientation = PointEnv::OUTWARDS_NORMAL;//we suppose fixed normal
00020 
00021     if (pTrMat) {
00022         Matrix3 rotMat;
00023         pTrMat->get(rotMat);
00024         pTrMat->transform(env.intersection);
00025         rotMat.transform(env.normal);
00026         rotMat.transform(env.viewerDir);
00027     }
00028 
00029     env.distance = eyeDist;
00030     
00031     if (pNV) {
00032         env.nd = -(*pNV);
00033         env.mask = (ENV_HAVE_N_DOT_D|
00034                     ENV_HAVE_INTERSECTION|
00035                     ENV_HAVE_NORMAL|
00036                     ENV_HAVE_VIEWER_DIR|
00037                     ENV_HAVE_DISTANCE);
00038     } else
00039         env.mask = (ENV_HAVE_INTERSECTION|
00040                     ENV_HAVE_NORMAL|
00041                     ENV_HAVE_VIEWER_DIR|
00042                     ENV_HAVE_DISTANCE);
00043     
00044     if (_pShape) {
00045         env.pVisitableObj = _pShape;
00046         env.mask |= ENV_HAVE_ASOC_PRIMITIVE;
00047     } 
00048 
00049     return _pReflectionModel->illuminatePoint(env);
00050 }

Generated on Tue Nov 21 15:11:42 2006 for gra by  doxygen 1.4.6