Changeset 1330 for GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src
- Timestamp:
- 09/11/06 15:30:44 (18 years ago)
- Location:
- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreHierarchicalParticleSystemTechnique.cpp
r1062 r1330 14 14 bool useOwnMaterial, 15 15 String impostorMaterialName, 16 bool useVParam, 17 String VParamRadius, 18 bool useFParam, 19 String FParamRadius, 16 20 Pass* pass, 17 21 OgreRenderable* parentRenderable, … … 25 29 this->impostorMaterialName = impostorMaterialName; 26 30 this->useOwnMaterial = useOwnMaterial; 31 this->VParamRadius = VParamRadius; 32 this->FParamRadius = FParamRadius; 33 this->useVParam = useVParam; 34 this->useFParam = useFParam; 27 35 28 36 //create the Particle system … … 36 44 sharedRuns->addRun(ILLUMRUN_HPP_IMPOSTOR, createChildPSysRenderingRun()); 37 45 46 ((OgreChildPSystemRenderingRun*) sharedRuns->getRun(ILLUMRUN_HPP_IMPOSTOR)->asOgreRenderingRun())->setNode(node); 38 47 impostorChanged(sharedRuns->getRun(ILLUMRUN_HPP_IMPOSTOR)); 39 48 } … … 65 74 } 66 75 76 void OgreHierarchicalParticleSystemTechnique::update(unsigned long frameNum) 77 { 78 HierarchicalParticleSystemTechnique::update(frameNum); 79 80 OgreChildPSystemRenderingRun* r = (OgreChildPSystemRenderingRun*) 81 sharedRuns->getRun(ILLUMRUN_HPP_IMPOSTOR)->asOgreRenderingRun(); 82 float radius = r->getSmallSysRadius(); 83 if(useVParam) 84 pass->getVertexProgramParameters()->setNamedConstant(VParamRadius, radius); 85 if(useFParam) 86 pass->getFragmentProgramParameters()->setNamedConstant(FParamRadius, radius); 87 } 88 67 89 ///Technique Parsers 68 90 namespace HPSParsers … … 129 151 f->childPSysScriptName = params; 130 152 } 153 void parseVparamRadius(String& params, RenderTechniqueFactory* factory) 154 { 155 OgreHierarchicalParticleSystemTechniqueFactory* f = (OgreHierarchicalParticleSystemTechniqueFactory*) factory; 156 f->VParamRadius = params; 157 } 158 void parseFparamRadius(String& params, RenderTechniqueFactory* factory) 159 { 160 OgreHierarchicalParticleSystemTechniqueFactory* f = (OgreHierarchicalParticleSystemTechniqueFactory*) factory; 161 f->FParamRadius = params; 162 } 131 163 132 164 … … 148 180 this->attributeParsers.insert(AttribParserList::value_type("particle_script", (ILLUM_ATTRIBUTE_PARSER) parseScriptName)); 149 181 this->attributeParsers.insert(AttribParserList::value_type("material", (ILLUM_ATTRIBUTE_PARSER) parseMaterialName)); 182 this->attributeParsers.insert(AttribParserList::value_type("vparam_radius", (ILLUM_ATTRIBUTE_PARSER) parseFparamRadius)); 183 this->attributeParsers.insert(AttribParserList::value_type("fparam_radius", (ILLUM_ATTRIBUTE_PARSER) parseVparamRadius)); 150 184 151 185 } … … 165 199 impostorMaterialName = ""; 166 200 childPSysScriptName = ""; 167 bool useOwnMaterial = true; 201 useOwnMaterial = true; 202 VParamRadius = ""; 203 FParamRadius = ""; 204 useVParam = false; 205 useFParam = false; 168 206 169 207 parseParams(params); … … 179 217 useOwnMaterial, 180 218 impostorMaterialName, 219 useVParam, 220 VParamRadius, 221 useFParam, 222 FParamRadius, 181 223 pass, 182 224 parentRenderable, -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreChildParticlesystemRenderingRun.cpp
r1062 r1330 47 47 RenderTarget* rt = hpb->getRenderTarget(); 48 48 Viewport* v = rt->addViewport(impostorCamera); 49 v->setBackgroundColour(ColourValue(0,1,0,0)); 49 //Viewport* v = rt->addViewport(OgreIlluminationManager::getSingleton().getMainCamera()); 50 v->setBackgroundColour(ColourValue(0,0,0,0)); 50 51 v->setOverlaysEnabled(false); 51 52 rt->setAutoUpdated(false); … … 62 63 63 64 sharedRuns->getRoot()->updateBounds(); 64 Sphere boundSphere = ((OgreSharedRuns*)sharedRuns->getRoot(ILLUMRUN_HPP_IMPOSTOR))->getBoundingSphere();65 Vector3 center = sharedRuns->getRootPosition(ILLUMRUN_HPP_IMPOSTOR); 65 66 Camera* mainCam = OgreIlluminationManager::getSingleton().getMainCamera(); 66 67 impostorCamera->setPosition(mainCam->getPosition()); 67 Vector3 dir = boundSphere.getCenter() - mainCam->getPosition(); 68 float r = boundSphere.getRadius(); 69 r = 200; 68 69 psysNode->setPosition(center); 70 ParticleSystem* psys = Root::getSingleton()._getCurrentSceneManager()->getParticleSystem(childParticleSystemName); 71 psys->_notifyCurrentCamera(impostorCamera); 72 73 psysNode->_updateBounds(); 74 AxisAlignedBox bb = psysNode->_getWorldAABB(); 75 76 float r = (bb.getMaximum() - bb.getMinimum()).length() / 2.0; 77 sysRad = r; 78 center = bb.getCenter(); 79 Vector3 dir = center - mainCam->getPosition(); 70 80 float d = dir.normalise(); 71 impostorCamera->setDirection(dir); 81 82 if (d <= r * 1.2)//too close 83 { 84 d = r * 1.2; 85 impostorCamera->setPosition(center - dir * d); 86 } 72 87 88 impostorCamera->setDirection(dir); 89 90 //r = 200; 91 73 92 if(perspectiveRendering) 74 93 { … … 76 95 impostorCamera->setAspectRatio(1.0); 77 96 Radian a = Math::ASin(r / d) * 2.0; 78 impostorCamera->setFOVy( /*a*/ Radian(Degree(90)));79 impostorCamera->setNearClipDistance( /*std::max(0.01f, d - r)*/0.1);80 impostorCamera->setFarClipDistance( /*r + d*/1000);97 impostorCamera->setFOVy( a ); 98 impostorCamera->setNearClipDistance(d - r); 99 impostorCamera->setFarClipDistance(d + r); 81 100 } 82 101 else 83 102 { 84 impostorCamera->setPosition( boundSphere.getCenter());103 impostorCamera->setPosition(center); 85 104 impostorCamera->setProjectionType(PT_ORTHOGRAPHIC); 86 105 Matrix4 m; 87 106 m = Matrix4::IDENTITY; 88 float scale = 1.0 / boundSphere.getRadius();107 float scale = 1.0 / r; 89 108 m.setScale(Vector3(scale, scale, scale)); 90 109 impostorCamera->setCustomProjectionMatrix(true, m); 91 110 } 92 111 93 ParticleSystem* psys = Root::getSingleton()._getCurrentSceneManager()->getParticleSystem(childParticleSystemName); 94 psys->getParentSceneNode()->setPosition(boundSphere.getCenter()); 95 psys->_notifyCurrentCamera(impostorCamera); 112 // 96 113 psys->_updateRenderQueue(rq); 97 114 … … 100 117 101 118 RenderTarget* rt = impostorTexture->getBuffer().getPointer()->getRenderTarget(); 102 119 sm->setFindVisibleObjects(false); 103 120 rt->update(); 121 sm->setFindVisibleObjects(true); 104 122 105 123 … … 109 127 //filename.append(StringConverter::toString(framecount)); 110 128 filename.append(".dds"); 111 rt->writeContentsToFile(filename);129 //rt->writeContentsToFile(filename); 112 130 framecount++; 113 131
Note: See TracChangeset
for help on using the changeset viewer.