- Timestamp:
- 09/11/06 15:30:44 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.