- Timestamp:
- 09/03/08 01:57:45 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShadowMapping.cpp
r2894 r2897 79 79 80 80 81 ShadowMap::ShadowMap( int size, const AxisAlignedBox3 &sceneBox, Camera *cam):82 mSceneBox(sceneBox), mSize(size), mCamera(cam) 81 ShadowMap::ShadowMap(Light *light, int size, const AxisAlignedBox3 &sceneBox, Camera *cam): 82 mSceneBox(sceneBox), mSize(size), mCamera(cam), mLight(light) 83 83 { 84 84 mFbo = new FrameBufferObject(size, size, FrameBufferObject::DEPTH_32, true); … … 94 94 { 95 95 DEL_PTR(mFbo); 96 } 97 98 99 100 void ShadowMap::ComputeShadowMap(Light *light, RenderTraverser *traverser) 101 { 102 mLight = light; 103 96 DEL_PTR(mShadowCam); 97 } 98 99 100 void ShadowMap::ComputeShadowMap(RenderTraverser *renderer) 101 { 104 102 const float xlen = Magnitude(mSceneBox.Diagonal() * 0.5f); 105 103 const float ylen = Magnitude(mSceneBox.Diagonal() * 0.5f); 106 104 107 mShadowCam->SetDirection( light->GetDirection());105 mShadowCam->SetDirection(mLight->GetDirection()); 108 106 109 107 // set position so that we can see the whole scene 110 108 Vector3 pos = mSceneBox.Center(); 111 109 112 pos -= light->GetDirection() * Magnitude(mSceneBox.Diagonal() * 0.5f);110 pos -= mLight->GetDirection() * Magnitude(mSceneBox.Diagonal() * 0.5f); 113 111 mShadowCam->SetPosition(pos); 114 112 … … 142 140 glMatrixMode(GL_MODELVIEW); 143 141 glPushMatrix(); 144 145 142 glLoadIdentity(); 146 143 147 144 // setup shadow camera 148 145 mShadowCam->SetupCameraView(); 146 149 147 150 148 ////////////// … … 168 166 //-- render scene into shadow map 169 167 170 traverser->RenderScene(); 168 renderer->RenderScene(); 169 171 170 172 171 glDisable(GL_POLYGON_OFFSET_FILL);
Note: See TracChangeset
for help on using the changeset viewer.