Changeset 2475 for GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src
- Timestamp:
- 07/02/07 04:12:36 (18 years ago)
- Location:
- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreRenderable.cpp
r1425 r2475 131 131 { 132 132 case OGRE_RENDERABLETYPE_SUBENTITY: 133 { 133 134 parentEntity->getParentSceneNode()->_updateBounds(); 134 135 boundingBox = parentEntity->getWorldBoundingBox(true); 135 boundingSphere = parentEntity->getWorldBoundingSphere(true); 136 break; 137 case OGRE_RENDERABLETYPE_BILLBOARDSET: 136 137 Vector3 center = (boundingBox.getMaximum() + boundingBox.getMaximum()) / 2.0; 138 float radius = (center - boundingBox.getMaximum()).length(); 139 boundingSphere.setRadius(radius); 140 boundingSphere.setCenter(center); 141 //boundingSphere = parentEntity->getWorldBoundingSphere(true); 142 break; 143 } 144 case OGRE_RENDERABLETYPE_BILLBOARDSET: 145 { 138 146 /* billboardSetRenderable->getParentSceneNode()->_updateBounds(); 139 147 boundingBox = billboardSetRenderable->getWorldBoundingBox(true); … … 144 152 boundingSphere.setCenter( (boundingBox.getMaximum() + boundingBox.getMinimum()) / 2.0); 145 153 break; 154 } 146 155 default: 147 156 OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, … … 152 161 } 153 162 163 SceneNode* OgreRenderable::getParentSceneNode() 164 { 165 switch(renderableType) 166 { 167 case OGRE_RENDERABLETYPE_SUBENTITY: 168 { 169 return parentEntity->getParentSceneNode(); 170 } 171 case OGRE_RENDERABLETYPE_BILLBOARDSET: 172 { 173 return parentParticleSystem->getParentSceneNode(); 174 } 175 default: 176 OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, 177 "Unknown renderable type! Check RenderTechnique initializations!", 178 "OgreRenderable::getParentSceneNode"); 179 } 180 return 0; 181 } 182 154 183 Renderable* OgreRenderable::getRenderable() 155 184 { -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreCausticReceiverRenderTechnique.cpp
r2366 r2475 15 15 String casterCenterVariableName, 16 16 String attenuationVariableName, 17 bool bindDistanceMap, 17 18 Pass* pass, 18 19 OgreRenderable* parentRenderable, … … 31 32 this->casterCenterVariableName = casterCenterVariableName; 32 33 this->attenuationVariableName = attenuationVariableName; 34 this->bindDistanceMap = bindDistanceMap; 35 bindAttenuation = false; 36 if(attenuationVariableName != "") 37 bindAttenuation = true; 33 38 34 39 if(createNewPasses) … … 66 71 67 72 TextureUnitState* st = newpass->createTextureUnitState(); 68 TextureUnitState* st2 = newpass->createTextureUnitState();69 70 73 st->setTextureFiltering(TFO_BILINEAR); 71 st2->setTextureFiltering(TFO_BILINEAR); 74 if(bindDistanceMap) 75 { 76 TextureUnitState* st2 = newpass->createTextureUnitState(); 77 st2->setTextureFiltering(TFO_BILINEAR); 78 } 72 79 73 80 newpass->setSceneBlending(passBlendingSRC, passBlendingDEST); … … 109 116 110 117 Pass* passToSet = this->pass; 111 int textureUnit = startTextureUnitID + i; 118 int p = bindDistanceMap?i*2:i; 119 int textureUnit = startTextureUnitID + p; 112 120 if(createNewPasses) 113 121 { … … 119 127 passToSet->getTextureUnitState(textureUnit)->setTextureName( 120 128 cauCubeRun->getCausticCubeMapTextureName()); 129 if(bindDistanceMap) 130 { 131 OgreCubeMapRenderingRun* distCubeRun = 132 (OgreCubeMapRenderingRun*) causticCasters.at(i)-> 133 getRun(ILLUMRUN_DISTANCE_CUBEMAP)->asOgreRenderingRun(); 134 if(distCubeRun) 135 passToSet->getTextureUnitState(textureUnit + 1)->setTextureName( 136 distCubeRun->getCubeMapTextureName()); 137 } 121 138 122 139 //set caster position nad caustic attenuation … … 126 143 if(!createNewPasses) 127 144 { 128 centerVarName += String ("[") + StringConverter::toString(i) + String("]");129 attenuationVarName += String ("[") + StringConverter::toString(i) + String("]");145 centerVarName += StringConverter::toString(i+1); 146 attenuationVarName += StringConverter::toString(i+1); 130 147 } 131 148 Fparams->setNamedConstant(centerVarName, 132 149 causticCasters.at(i)->getRootPosition(ILLUMRUN_CAUSTIC_CUBEMAP)); 150 if(bindAttenuation) 133 151 Fparams->setNamedConstant(attenuationVarName, 134 152 cauCubeRun->getAttenuation()); … … 247 265 f->attenuationVariableName = params; 248 266 } 267 268 void parseBindDistanceMap(String& params, RenderTechniqueFactory* factory) 269 { 270 OgreCausticReceiverRenderTechniqueFactory* f = (OgreCausticReceiverRenderTechniqueFactory*) factory; 271 f->bindDistanceMap = StringConverter::parseBool(params); 272 } 249 273 } 250 274 … … 263 287 this->attributeParsers.insert(AttribParserList::value_type("center_var_name", (ILLUM_ATTRIBUTE_PARSER) parseCenterVarName)); 264 288 this->attributeParsers.insert(AttribParserList::value_type("attenuation_var_name", (ILLUM_ATTRIBUTE_PARSER) parseAttenuationVarName)); 289 this->attributeParsers.insert(AttribParserList::value_type("bind_distance_map", (ILLUM_ATTRIBUTE_PARSER) parseBindDistanceMap)); 265 290 } 266 291 … … 280 305 startTextureUnitID = 0; 281 306 casterCenterVariableName = "cubeMapCameraPosition"; 282 String attenuationVariableName = "attenuation"; 307 attenuationVariableName = ""; 308 bindDistanceMap = false; 283 309 284 310 parseParams(params); … … 294 320 casterCenterVariableName, 295 321 attenuationVariableName, 322 bindDistanceMap, 296 323 pass, 297 324 parentRenderable, -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreDepthShadowReceiverRenderTechnique.cpp
r2460 r2475 21 21 int startTextureUnitID, 22 22 bool nearestLightsFromCamera, 23 bool bindToVertexShader, 23 24 Pass* pass, 24 25 OgreRenderable* parentRenderable, … … 28 29 DepthShadowReceiverRenderTechnique(parentRenderable, parentTechniqueGroup) 29 30 { 31 this->bindToVertexShader = bindToVertexShader; 30 32 this->passBlendingSRC = passBlendingSRC; 31 33 this->passBlendingDEST = passBlendingDEST; … … 99 101 Vector3 center = OgreIlluminationManager::getSingleton().getMainCamera()->getWorldPosition(); 100 102 if(!nearestLightsFromCamera) 101 center = ((OgreSharedRuns*) sharedRuns)->getRootPosition(); 103 center = ((OgreSharedRuns*) sharedRuns)->getRootRenderable()->getParentSceneNode()->_getDerivedPosition(); 104 //center = ((OgreSharedRuns*) sharedRuns)->getRootPosition(); 102 105 Root::getSingleton()._getCurrentSceneManager()->_populateLightList( 103 106 center, … … 149 152 GpuProgramParametersSharedPtr fpParams = passToSet->getFragmentProgramParameters(); 150 153 GpuProgramParametersSharedPtr vpParams = passToSet->getVertexProgramParameters(); 154 GpuProgramParametersSharedPtr variableSetParams = fpParams; 155 if(bindToVertexShader) 156 variableSetParams = vpParams; 151 157 152 158 String LightViewProjParamName = lightViewProjParamName; … … 165 171 vpParams->setNamedConstant(LightViewProjParamName, depthRun->getLightViewProjMatrix()); 166 172 else 167 fpParams->setNamedConstant(LightViewProjParamName, depthRun->getLightViewProjMatrix());173 variableSetParams->setNamedConstant(LightViewProjParamName, depthRun->getLightViewProjMatrix()); 168 174 } 169 175 if(setLightViewMatrix) … … 172 178 vpParams->setNamedConstant(LightViewParamName, depthRun->getLightViewMatrix()); 173 179 else 174 fpParams->setNamedConstant(LightViewParamName, depthRun->getLightViewMatrix());180 variableSetParams->setNamedConstant(LightViewParamName, depthRun->getLightViewMatrix()); 175 181 } 176 182 if(setLightProjFarPlane) … … 347 353 f->nearestLightsFromCamera = StringConverter::parseBool(params); 348 354 } 355 void parseBindToVertexShader(String& params, RenderTechniqueFactory* factory) 356 { 357 OgreDepthShadowReceiverRenderTechniqueFactory* f = (OgreDepthShadowReceiverRenderTechniqueFactory*) factory; 358 f->bindToVertexShader = StringConverter::parseBool(params); 359 } 349 360 } 350 361 … … 370 381 this->attributeParsers.insert(AttribParserList::value_type("start_tex_id", (ILLUM_ATTRIBUTE_PARSER) parseStartTexID)); 371 382 this->attributeParsers.insert(AttribParserList::value_type("nearest_from_camera", (ILLUM_ATTRIBUTE_PARSER) parseNearestFromCamera)); 383 this->attributeParsers.insert(AttribParserList::value_type("bind_to_vertex_shader", (ILLUM_ATTRIBUTE_PARSER) parseBindToVertexShader)); 372 384 } 373 385 … … 394 406 createNewPasses = true; 395 407 startTextureUnitID = 0; 396 nearestLightsFromCamera = true; 397 408 nearestLightsFromCamera = false; 409 bindToVertexShader = false; 410 398 411 parseParams(params); 399 412 … … 415 428 startTextureUnitID, 416 429 nearestLightsFromCamera, 430 bindToVertexShader, 417 431 pass, 418 432 parentRenderable, -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgrePathMapRenderTechnique.cpp
r2460 r2475 144 144 LightList lights; 145 145 SceneManager* sm = Root::getSingleton()._getCurrentSceneManager(); 146 sm->_populateLightList(OgreIlluminationManager::getSingleton().getMainCamera()->get Position(), 1000, lights);146 sm->_populateLightList(OgreIlluminationManager::getSingleton().getMainCamera()->getWorldPosition(), 1000, lights); 147 147 148 148 int found = 0; 149 for(int i = 0 ; found < 5&& i < lights.size(); i++)149 for(int i = 0 ; found < 2 && i < lights.size(); i++) 150 150 { 151 151 if(lights.at(i)->isAttached()) -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreLightVolumeRenderingRun.cpp
r2427 r2475 137 137 restoreMaterials(); 138 138 139 // rt->writeContentsToFile(name+"_lightVolume.bmp"); 139 140 //do blending 140 141 rt = lightVolumeTexture2->getBuffer().getPointer()->getRenderTarget(); … … 143 144 renderFullscreenQuad("GameTools/BlurLightVolume", rt); 144 145 145 146 // rt->writeContentsToFile(name+"_blurredlightVolume.bmp"); 146 147 /* 147 148 static int framecount = 0; … … 199 200 void OgreLightVolumeRenderingRun::refreshLight() 200 201 { 202 Vector3 center = sharedRuns->getRootPosition(ILLUMRUN_LIGHTVOLUME_MAP); 203 201 204 SceneManager* sm = Root::getSingleton()._getCurrentSceneManager(); 202 205 LightList list; 203 sm->_populateLightList( ((OgreSharedRuns*)sharedRuns)->getRootPosition(ILLUMRUN_LIGHTVOLUME_MAP),100000, list);206 sm->_populateLightList(center, 100000, list); 204 207 205 208 light = *(list.begin()); … … 226 229 lightVolumeCamera->setDirection( dir ); 227 230 Real r = sharedRuns->getRootBoundingSphere(ILLUMRUN_LIGHTVOLUME_MAP).getRadius(); 228 r += baseRad;231 //r += baseRad; 229 232 systemRadius = r; 230 233 lightVolumeCamera->setPosition( sharedRuns->getRootPosition(ILLUMRUN_LIGHTVOLUME_MAP) - dir * r); … … 239 242 { 240 243 Vector3 pos = light->getDerivedPosition(); 241 Vector3 dir = sharedRuns->getRootPosition(ILLUMRUN_LIGHTVOLUME_MAP) - pos; 244 Vector3 dir = center - pos; 245 Real r = sharedRuns->getRootBoundingSphere(ILLUMRUN_LIGHTVOLUME_MAP).getRadius(); 246 //r += baseRad; 247 Real d = dir.length(); 242 248 dir.normalise(); 243 Real r = sharedRuns->getRootBoundingSphere(ILLUMRUN_LIGHTVOLUME_MAP).getRadius(); 244 r += baseRad; 245 lightVolumeCamera->setPosition( sharedRuns->getRootPosition(ILLUMRUN_LIGHTVOLUME_MAP) - dir * r); 246 lightVolumeCamera->lookAt( sharedRuns->getRootPosition(ILLUMRUN_LIGHTVOLUME_MAP) ); 249 /*float mindist = 1.5 * r; 250 if(d < mindist) 251 { 252 pos -= dir * (mindist - d) ; 253 d = mindist; 254 }*/ 255 lightVolumeCamera->setPosition( center - dir * d); 256 lightVolumeCamera->lookAt( center ); 247 257 lightVolumeCamera->setProjectionType(PT_ORTHOGRAPHIC); 248 258 Matrix4 proj;
Note: See TracChangeset
for help on using the changeset viewer.