
Public Member Functions | |
| virtual void | drawIndexed (Particles *part, DrawActionBase *action, Int32 *index, UInt32 length) |
| virtual void | draw (Particles *part, DrawActionBase *action, UInt32 length) |
Definition at line 1193 of file OSGParticles.cpp.
| virtual void drawViewDirQuads< posTrait, colTrait, texTrait, sizeTrait >::drawIndexed | ( | Particles * | part, | |
| DrawActionBase * | action, | |||
| Int32 * | index, | |||
| UInt32 | length | |||
| ) | [inline, virtual] |
Implements osg::ParticlesDrawer.
Definition at line 1195 of file OSGParticles.cpp.
References osg::Action::getActNode(), osg::DrawActionBase::getCameraToWorld(), osg::ParticlesBase::getPositions(), init(), osg::TransformationMatrix< ValueTypeT >::multLeft(), osg::RenderAction::top_matrix(), and osg::TransformationMatrix< ValueTypeT >::transpose().
01197 { 01198 // get ModelView matrix to define the direction vectors 01199 Matrix camera,toworld; 01200 camera = action->getCameraToWorld(); 01201 01202 RenderAction *ra = dynamic_cast<RenderAction *>(action); 01203 01204 if(ra != NULL) 01205 { 01206 toworld = ra->top_matrix(); 01207 } 01208 else 01209 { 01210 action->getActNode()->getToWorld(toworld); 01211 } 01212 01213 // normalize them, we don't want to neutralize scales in toworld 01214 toworld[0].normalize(); 01215 toworld[1].normalize(); 01216 toworld[2].normalize(); 01217 toworld.transpose(); 01218 camera.multLeft(toworld); 01219 01220 // Direction vectors 01221 Vec4f d1, d2, d3, d4; 01222 01223 d1 = -1.0f * camera[0] + -1.0f * camera[1]; 01224 d2 = 1.0f * camera[0] + -1.0f * camera[1]; 01225 d3 = 1.0f * camera[0] + 1.0f * camera[1]; 01226 d4 = -1.0f * camera[0] + 1.0f * camera[1]; 01227 01228 // some variables for faster access 01229 GeoPositionsPtr pos = part->getPositions(); 01230 01231 // init traits 01232 typename colTrait::dataType colData; 01233 colTrait::init(part, action, colData); 01234 01235 typename texTrait::dataType texData; 01236 texTrait::init(part, action, texData); 01237 01238 typename sizeTrait::dataType sizeData; 01239 sizeTrait::init(part, action, sizeData); 01240 01241 typename posTrait::dataType posData; 01242 posTrait::init(part, action, posData, part->getPositions()); 01243 01244 glBegin(GL_QUADS); 01245 01246 Int32 i; 01247 01248 for(UInt32 ii = 0; ii < length; ++ii) 01249 { 01250 i = index[ii]; 01251 01252 if(i < 0 || i > Int32(pos->getSize())) 01253 continue; 01254 01255 if(colTrait::particle (colData, i)) 01256 continue; 01257 01258 if(texTrait::particle (texData, i)) 01259 continue; 01260 01261 if(sizeTrait::particle(sizeData, i)) 01262 continue; 01263 01264 if(posTrait::particle(posData, i)) 01265 continue; 01266 01267 Real32 s = sizeTrait::size(sizeData, i)[0] / 2.f; 01268 01269 if(s == 0) 01270 continue; 01271 01272 colTrait::vertex(colData, i, 0); 01273 texTrait::vertex(texData, 0, 0, 0); 01274 posTrait::vertex(posData, 0, d1, s); 01275 01276 colTrait::vertex(colData, i, 1); 01277 texTrait::vertex(texData, 1, 1, 0); 01278 posTrait::vertex(posData, 1, d2, s); 01279 01280 colTrait::vertex(colData, i, 2); 01281 texTrait::vertex(texData, 2, 1, 1); 01282 posTrait::vertex(posData, 2, d3, s); 01283 01284 colTrait::vertex(colData, i, 3); 01285 texTrait::vertex(texData, 3, 0, 1); 01286 posTrait::vertex(posData, 3, d4, s); 01287 } 01288 01289 glEnd(); 01290 }
| virtual void drawViewDirQuads< posTrait, colTrait, texTrait, sizeTrait >::draw | ( | Particles * | part, | |
| DrawActionBase * | action, | |||
| UInt32 | length | |||
| ) | [inline, virtual] |
Implements osg::ParticlesDrawer.
Definition at line 1292 of file OSGParticles.cpp.
References osg::Action::getActNode(), osg::DrawActionBase::getCameraToWorld(), osg::ParticlesBase::getPositions(), init(), osg::TransformationMatrix< ValueTypeT >::multLeft(), osg::RenderAction::top_matrix(), and osg::TransformationMatrix< ValueTypeT >::transpose().
01293 { 01294 // get ModelView matrix to define the direction vectors 01295 Matrix camera,toworld; 01296 01297 camera = action->getCameraToWorld(); 01298 01299 RenderAction *ra = dynamic_cast<RenderAction *>(action); 01300 01301 if(ra != NULL) 01302 { 01303 toworld = ra->top_matrix(); 01304 } 01305 else 01306 { 01307 action->getActNode()->getToWorld(toworld); 01308 } 01309 01310 // normalize them, we don't want to neutralize scales in toworld 01311 toworld[0].normalize(); 01312 toworld[1].normalize(); 01313 toworld[2].normalize(); 01314 toworld.transpose(); 01315 camera.multLeft(toworld); 01316 01317 // Direction vectors 01318 Vec4f d1, d2, d3, d4; 01319 01320 d1 = -1.0f * camera[0] + -1.0f * camera[1]; 01321 d2 = 1.0f * camera[0] + -1.0f * camera[1]; 01322 d3 = 1.0f * camera[0] + 1.0f * camera[1]; 01323 d4 = -1.0f * camera[0] + 1.0f * camera[1]; 01324 01325 // some variables for faster access 01326 GeoPositionsPtr pos = part->getPositions(); 01327 01328 // init traits 01329 typename colTrait::dataType colData; 01330 colTrait::init(part, action, colData); 01331 01332 typename texTrait::dataType texData; 01333 texTrait::init(part, action, texData); 01334 01335 typename sizeTrait::dataType sizeData; 01336 sizeTrait::init(part, action, sizeData); 01337 01338 typename posTrait::dataType posData; 01339 posTrait::init(part, action, posData, part->getPositions()); 01340 01341 glBegin(GL_QUADS); 01342 01343 for(UInt32 i = 0; i < length; ++i) 01344 { 01345 if(colTrait::particle (colData, i)) 01346 continue; 01347 01348 if(texTrait::particle (texData, i)) 01349 continue; 01350 01351 if(sizeTrait::particle(sizeData, i)) 01352 continue; 01353 01354 if(posTrait::particle(posData, i)) 01355 continue; 01356 01357 Real32 s = sizeTrait::size(sizeData, i)[0] / 2.f; 01358 01359 if(s == 0) 01360 continue; 01361 01362 colTrait::vertex(colData, i, 0); 01363 texTrait::vertex(texData, 0, 0, 0); 01364 posTrait::vertex(posData, 0, d1, s); 01365 01366 colTrait::vertex(colData, i, 1); 01367 texTrait::vertex(texData, 1, 1, 0); 01368 posTrait::vertex(posData, 1, d2, s); 01369 01370 colTrait::vertex(colData, i, 2); 01371 texTrait::vertex(texData, 2, 1, 1); 01372 posTrait::vertex(posData, 2, d3, s); 01373 01374 colTrait::vertex(colData, i, 3); 01375 texTrait::vertex(texData, 3, 0, 1); 01376 posTrait::vertex(posData, 3, d4, s); 01377 } 01378 01379 glEnd(); 01380 }
1.5.5