- Timestamp:
- 07/11/06 15:48:46 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreDepthShadowMapRenderingRun.cpp
r1103 r1120 16 16 this->light = light; 17 17 this->sharedRuns = sharedRuns; 18 names[0] = name + "1";19 names[1] = name + "2";18 this->name = name; 19 20 20 this->materialName = materialName; 21 21 … … 25 25 void OgreDepthShadowMapRenderingRun::createDepthMap() 26 26 { 27 for(int i = 0; i < 1; i++) 28 { 29 TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(names[i], 27 28 TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(name, 30 29 "default", 31 30 TEX_TYPE_2D, … … 36 35 PF_FLOAT16_RGBA, 37 36 TU_RENDERTARGET); 38 depthMapTexture s[i]= texPtr.getPointer();39 depthMapCamera s[i] = Root::getSingleton()._getCurrentSceneManager()->createCamera(names[i]+ "_CAMERA");37 depthMapTexture = texPtr.getPointer(); 38 depthMapCamera = Root::getSingleton()._getCurrentSceneManager()->createCamera(name + "_CAMERA"); 40 39 //add viewport to rendertarget 41 HardwarePixelBuffer* hpb = (depthMapTexture s[i]->getBuffer()).getPointer();40 HardwarePixelBuffer* hpb = (depthMapTexture->getBuffer()).getPointer(); 42 41 RenderTarget* rt = hpb->getRenderTarget(); 43 Viewport* v = rt->addViewport(depthMapCamera s[i]);42 Viewport* v = rt->addViewport(depthMapCamera); 44 43 v->setOverlaysEnabled(false); 45 rt->setAutoUpdated(false); 46 } 44 rt->setAutoUpdated(false); 47 45 } 48 46 … … 69 67 void OgreDepthShadowMapRenderingRun::updateDepthMap() 70 68 { 71 setMaterialForVisibles(materialName, depthMapCameras[0], false); 72 RenderTarget* rt = depthMapTextures[0]->getBuffer().getPointer()->getRenderTarget(); 69 setMaterialForVisibles(materialName, depthMapCamera, false); 70 RenderTarget* rt = depthMapTexture->getBuffer().getPointer()->getRenderTarget(); 71 Viewport* vp = rt->getViewport(0); 72 73 73 rt->update(); 74 74 restoreMaterials(); … … 103 103 Vector3 lightpos = light->getPosition(); 104 104 Vector3 lightdir = light->getDirection(); 105 lightdir.normalise(); 106 107 depthMapCamera->setProjectionType(PT_ORTHOGRAPHIC); 108 /*depthMapCameras[0]->setAspectRatio(1.0); 109 depthMapCameras[0]->setFOVy(Radian(Degree(20))); 110 depthMapCameras[0]->setNearClipDistance(0.1); 111 depthMapCameras[0]->setFarClipDistance(200);*/ 112 105 113 106 Vector3 center = (min + max) / 2.0; 107 Vector3 scale = max - min; 108 scale.x = 2.0 / scale.x; 109 scale.y = 2.0 / scale.y; 110 scale.z = 2.0 / scale.z; 111 center.x *= scale.x; 112 center.y *= scale.y; 113 center.z *= scale.z; 114 115 116 depthMapCameras[0]->setDirection( lightdir ); 117 depthMapCameras[0]->setPosition( lightpos ); 118 119 Matrix4 projection = Matrix4::IDENTITY; 120 projection.setTrans(center); 121 projection.setScale(scale); 122 depthMapCameras[0]->setCustomProjectionMatrix(true, projection); 123 /* 114 Vector3 scale = (max - min); 115 scale *= 1.5; 116 //scale = Vector3(150,150,150); 117 Matrix4 projection = depthMapCamera->getProjectionMatrix(); 118 projection = Matrix4::IDENTITY; 119 projection.setScale(Vector3(2.0 / scale.x, 2.0 / scale.y, -2.0 / scale.z)); 120 projection.setTrans(Vector3(-(max.x + min.x) / scale.x, 121 -(max.y + min.y) / scale.y, 122 -(max.z + min.z) / scale.z)); 123 depthMapCamera->setCustomProjectionMatrix(true, projection); 124 125 depthMapCamera->setPosition(lightpos); 126 depthMapCamera->setDirection(lightdir); 127 128 /* 124 129 projection = Matrix4::IDENTITY; 125 130 projection.setScale(Vector3(1.0 / 100.0, 1.0 / 100.0, -1.0 / 100.0)); … … 161 166 } 162 167 163 Matrix4 OgreDepthShadowMapRenderingRun::getLightViewMatrix( int i)168 Matrix4 OgreDepthShadowMapRenderingRun::getLightViewMatrix() 164 169 { 165 return depthMapCamera s[i]->getViewMatrix();170 return depthMapCamera->getViewMatrix(); 166 171 } 167 172 168 Matrix4 OgreDepthShadowMapRenderingRun::getLightViewProjMatrix( int i)173 Matrix4 OgreDepthShadowMapRenderingRun::getLightViewProjMatrix() 169 174 { 170 return depthMapCamera s[i]->getProjectionMatrix() * depthMapCameras[i]->getViewMatrix();175 return depthMapCamera->getProjectionMatrixWithRSDepth() * depthMapCamera->getViewMatrix(); 171 176 } 172 177
Note: See TracChangeset
for help on using the changeset viewer.