lbm_reference
Particle.cpp
Go to the documentation of this file.
1 //! \file Particle.cpp
2 //! \date Mar 12, 2009
3 //! \author Florian Rathgeber
4 
5 #include "Particle.h"
6 
7 namespace particles {
8 
9 Particle::Particle ( scene::ISceneManager* mgr,
10  s32 id,
11  const core::vector3df &position,
12  std::vector< video::ITexture* >& textures,
13  int numSprites,
14  float temp,
15  video::SColor& color,
16  float size,
17  int lifetime,
18  bool dynamicLights) :
19  sprites_( numSprites ),
20  pos_( position ),
21  type_( FIRE ),
22  temp_( temp ),
23  lifetime_( lifetime ) {
24 
25  for ( int i = 0; i < numSprites; ++i ) {
26  // Add sprite as billboard scene node to the scene
27  sprites_[i] = mgr->addBillboardSceneNode( NULL,
28  core::dimension2df(size,size),
29  position,
30  id );
31  sprites_[i]->setColor( color );
32  sprites_[i]->setMaterialTexture( 0, textures[ rand() % textures.size() ] );
33  sprites_[i]->setMaterialFlag( video::EMF_LIGHTING, false );
34  sprites_[i]->setMaterialFlag( video::EMF_ZWRITE_ENABLE, false );
35  sprites_[i]->setMaterialType( video::EMT_TRANSPARENT_ADD_COLOR );
36 
37  // Add a light source to the billboard
38  if ( dynamicLights )
39  sprites_[i]->addChild(
40  mgr->addLightSceneNode( sprites_[i], position, color, temp / 50 ) );
41  }
42 }
43 
44 } // namespace particles