Changeset 9491 for code/branches/shaders/src/orxonox
- Timestamp:
- Dec 4, 2012, 2:04:46 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/shaders/src/orxonox/graphics/LensFlare.cc
r9466 r9491 85 85 this->occlusionBillboard_ = new Billboard(this); 86 86 this->occlusionBillboard_->setMaterial("lensflare/hoq"); 87 this->occlusionBillboard_->setPosition(this->getPosition());88 87 this->occlusionBillboard_->setVisible(false); 89 88 this->occlusionBillboard_->disableFrustumCulling(); … … 93 92 Billboard* burst = new Billboard(this); 94 93 burst->setMaterial("lensflare/burst"); 95 burst->setPosition(this->getPosition());96 94 burst->disableFrustumCulling(); 97 95 burst->setVisible(true); … … 100 98 Billboard* bursthalo = new Billboard(this); 101 99 bursthalo->setMaterial("lensflare/bursthalo"); 102 bursthalo->setPosition(this->getPosition());103 100 bursthalo->disableFrustumCulling(); 104 101 bursthalo->setVisible(true); … … 107 104 bursthalo = new Billboard(this); 108 105 bursthalo->setMaterial("lensflare/halo1"); 109 bursthalo->setPosition(this->getPosition());110 106 bursthalo->disableFrustumCulling(); 111 107 bursthalo->setVisible(true); … … 114 110 bursthalo = new Billboard(this); 115 111 bursthalo->setMaterial("lensflare/halo2"); 116 bursthalo->setPosition(this->getPosition());117 112 bursthalo->disableFrustumCulling(); 118 113 bursthalo->setVisible(true); … … 121 116 bursthalo = new Billboard(this); 122 117 bursthalo->setMaterial("lensflare/halo3"); 123 bursthalo->setPosition(this->getPosition());124 118 bursthalo->disableFrustumCulling(); 125 119 bursthalo->setVisible(true); … … 143 137 int i=0; 144 138 float step=0.0f; 145 Vector3 position=CameraManager::getInstance().getActiveCamera()->getOgreCamera()->getDerivedPosition();146 139 for(std::set<WorldEntity*>::const_iterator it = this->getAttachedObjects().begin(); it != this->getAttachedObjects().end(); it++) { 147 140 Billboard* billboard=static_cast<Billboard*>(*it); 148 billboard->setPosition( this->getPosition()-viewDirection*step);141 billboard->setPosition(-viewDirection*step); 149 142 billboard->setVisible(lightIsVisible); 150 billboard->setDefaultDimensions((i <0?0.5f:1.0f)*(i>2?0.25f:1.0f)*dimension*std::pow((1.0f-step),-1.0f),(i<0?0.5f:1.0f)*(i>2?0.25f:1.0f)*dimension*std::pow((1.0f-step),-1.0f));143 billboard->setDefaultDimensions((i==0?0.5f:1.0f)*(i>2?0.25f:1.0f)*dimension*std::pow((1.0f-step),-1.0f),(i==0?0.5f:1.0f)*(i>2?0.25f:1.0f)*dimension*std::pow((1.0f-step),-1.0f)); 151 144 step=0.25f*(i>2?(i-2):0); 152 145 i++; … … 168 161 if(i==2) 169 162 { 170 this->colour_->a*=0. 5f;163 this->colour_->a*=0.33f; 171 164 } 172 165 Billboard* billboard=static_cast<Billboard*>(*it); … … 187 180 { 188 181 Ogre::Camera* camera=CameraManager::getInstance().getActiveCamera()->getOgreCamera(); 189 Vector3 position = this->get Position();182 Vector3 position = this->getWorldPosition(); 190 183 Vector3 nX = camera->getDerivedOrientation().xAxis().normalisedCopy(); 191 184 Vector3 nY = camera->getDerivedOrientation().yAxis().normalisedCopy(); … … 212 205 { 213 206 Ogre::Camera* camera=CameraManager::getInstance().getActiveCamera()->getOgreCamera(); //get active Ogre Camera Instance, so we can check whether the light source is visible 214 this->cameraDistance_=camera->get Position().distance(this->getPosition());207 this->cameraDistance_=camera->getDerivedPosition().distance(this->getPosition()); 215 208 float dimension=this->cameraDistance_*this->scale_; 216 209 if(!this->fadeOnViewBorder_) … … 218 211 this->fadeResolution_=3;//this is so we can still determine when the billboard has left the screen 219 212 } 220 unsigned int pointCount=this->getPointCount(dimension*0. 5f);221 Vector3 viewDirection=this->get Position()-camera->getDerivedPosition()-camera->getDerivedDirection()*this->cameraDistance_;213 unsigned int pointCount=this->getPointCount(dimension*0.25f*this->scale_); 214 Vector3 viewDirection=this->getWorldPosition()-camera->getDerivedPosition()-camera->getDerivedDirection()*this->cameraDistance_; 222 215 updateBillboardStates(viewDirection,dimension,pointCount>0); 223 216 if(pointCount>0) { 224 Ogre::Sphere* sphere=new Ogre::Sphere(this->getPosition(),dimension*0.25f );217 Ogre::Sphere* sphere=new Ogre::Sphere(this->getPosition(),dimension*0.25f*this->scale_); 225 218 float left, right, top, bottom; 226 219 camera->projectSphere(*sphere,&left,&top,&right,&bottom);//approximate maximum pixel count of billboard with a sphere
Note: See TracChangeset
for help on using the changeset viewer.