Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals

pge::EffectTest Class Reference

#include <EffectTest.h>

Inheritance diagram for pge::EffectTest:

Inheritance graph
[legend]
Collaboration diagram for pge::EffectTest:

Collaboration graph
[legend]

Public Member Functions

 EffectTest (void)
 Constructor.

virtual ~EffectTest (void)
 Destructor.

bool init (void)
void render (void)
 Called when the object should render itself.

void timer (unsigned int delay)
 Called when the timer event comes.

void setBoundingBox (AABB *aabb)

Private Member Functions

void initLights (void)

Private Attributes

Spritem_sprite0
Spritem_sprite1
Spritem_sprite2
Lightm_light0
Lightm_light1
Lightm_light2
Vector3f m_direction0
Vector3f m_direction1
Vector3f m_direction2
unsigned int m_timePassed
AABBm_boundingBox

Constructor & Destructor Documentation

pge::EffectTest::EffectTest void   )  [inline]
 

Constructor.

Definition at line 33 of file EffectTest.h.

References initLights(), m_boundingBox, m_direction0, m_direction1, m_direction2, and m_timePassed.

00033                                  {
00034                         initLights();
00035 
00036                         m_timePassed = 0;
00037 
00038                         m_direction0 = Vector3f(1.0f, 0.0f, 0.0f);
00039                         m_direction1 = Vector3f(0.0f, 1.0f, 0.0f);
00040                         m_direction2 = Vector3f(-1.0f, 0.0f, 0.0f);
00041 
00042                         m_boundingBox = NULL;
00043                 }

Here is the call graph for this function:

virtual pge::EffectTest::~EffectTest void   )  [inline, virtual]
 

Destructor.

Definition at line 52 of file EffectTest.h.

00052                                           {
00053                 }


Member Function Documentation

bool pge::EffectTest::init void   )  [inline, virtual]
 

Implements pge::IRenderableObject.

Definition at line 64 of file EffectTest.h.

00064                                 {
00065                         return true;
00066                 }

void pge::EffectTest::initLights void   )  [inline, private]
 

Definition at line 164 of file EffectTest.h.

References pge::World::addLight(), pge::Light::m_diffuse, m_light0, m_light1, m_light2, pge::Light::m_position, m_sprite0, m_sprite1, m_sprite2, pge::Sprite::setColor(), and pge::Sprite::setTexture().

Referenced by EffectTest().

00164                                       {
00165                         //
00166                         // Variables
00167                         //
00168                         Vector4f lightStartPosition = Vector4f(0.0f, 10.0f, 0.0f, 1.0f);
00169                         World *world = NULL;
00170                         Texture *texture = NULL;
00171 
00172 
00173                         // Get the world.
00174                         world = CoreEngine::getInstance()->getCurrentWorld();
00175 
00176                         // Create the lights and add them to the world.
00177                         m_light0 = new Light();
00178                         m_light1 = new Light();
00179                         m_light2 = new Light();
00180 
00181                         // Light 0, a red light.
00182                         m_light0->m_position = lightStartPosition;
00183                         m_light0->m_diffuse = Vector4f(1.0f, 0.0f, 0.0f, 1.0f);
00184 
00185                         // Light 1, a green light.
00186                         m_light1->m_position = lightStartPosition;
00187                         m_light1->m_diffuse = Vector4f(0.0f, 1.0f, 0.0f, 1.0f);
00188 
00189                         // Light 2, a blue light.
00190                         m_light2->m_position = lightStartPosition;
00191                         m_light2->m_diffuse = Vector4f(0.0f, 0.0f, 1.0f, 1.0f);
00192 
00193                         m_sprite0 = new Sprite(Vector3f(m_light0->m_position), 1.0f);
00194                         m_sprite1 = new Sprite(Vector3f(m_light1->m_position), 1.0f);
00195                         m_sprite2 = new Sprite(Vector3f(m_light2->m_position), 1.0f);
00196 
00197                         texture = TextureDatabase::getInstance()->addTexture("waterparticle_0.tga");
00198 
00199                         m_sprite0->setTexture(texture);
00200                         m_sprite1->setTexture(texture);
00201                         m_sprite2->setTexture(texture);
00202 
00203                         m_sprite0->setColor(Vector4f(1.0f, 0.0f, 0.0f, 1.0f));
00204                         m_sprite1->setColor(Vector4f(0.0f, 1.0f, 0.0f, 1.0f));
00205                         m_sprite2->setColor(Vector4f(0.0f, 0.0f, 1.0f, 1.0f));
00206 
00207                         world->addLight(m_light0);
00208                         world->addLight(m_light1);
00209                         world->addLight(m_light2);
00210                 }

Here is the call graph for this function:

void pge::EffectTest::render void   )  [inline, virtual]
 

Called when the object should render itself.

Implements pge::IRenderableObject.

Definition at line 72 of file EffectTest.h.

References m_sprite0, m_sprite1, m_sprite2, and pge::Sprite::render().

00072                                   {
00073                         if(DayNightCycle::getInstance()->getDayNightCycle() <= 0.1f) {
00074                                 m_sprite0->render();
00075                                 m_sprite1->render();
00076                                 m_sprite2->render();
00077                         }
00078                 }

Here is the call graph for this function:

void pge::EffectTest::setBoundingBox AABB aabb  )  [inline]
 

Definition at line 150 of file EffectTest.h.

References m_boundingBox.

Referenced by main().

00150                                                 {
00151                         m_boundingBox = aabb;
00152                 }

void pge::EffectTest::timer unsigned int  delay  )  [inline, virtual]
 

Called when the timer event comes.

Implements pge::IRenderableObject.

Definition at line 84 of file EffectTest.h.

References pge::AABB::isPointInside(), m_boundingBox, m_direction0, m_direction1, m_direction2, m_light0, m_light1, m_light2, pge::Light::m_position, m_sprite0, m_sprite1, m_sprite2, m_timePassed, pge::Vector3f::m_v, pge::Vector4f::m_v, pge::Vector3f::normalize(), and pge::Sprite::setCenter().

00084                                                {
00085                         if(DayNightCycle::getInstance()->getDayNightCycle() <= 0.1f) {
00086                                 //
00087                                 // Variables
00088                                 //
00089                                 float velocity = 0.1f;
00090 
00091 
00092                                 if(m_timePassed >= 400) {
00093                                         float maxChange = 0.5f;
00094 
00095                                         Vector3f dirChange0 = Vector3f(mathutils::random(-maxChange, maxChange),
00096                                                 mathutils::random(-maxChange, maxChange), mathutils::random(-maxChange, maxChange));
00097 
00098                                         Vector3f dirChange1 = Vector3f(mathutils::random(-maxChange, maxChange),
00099                                                 mathutils::random(-maxChange, maxChange), mathutils::random(-maxChange, maxChange));
00100 
00101                                         Vector3f dirChange2 = Vector3f(mathutils::random(-maxChange, maxChange),
00102                                                 mathutils::random(-maxChange, maxChange), mathutils::random(-maxChange, maxChange));
00103 
00104                                         m_direction0 = m_direction0 + dirChange0;
00105                                         m_direction0.normalize();
00106 
00107                                         m_direction1 = m_direction1 + dirChange1;
00108                                         m_direction1.normalize();
00109 
00110                                         m_direction2 = m_direction2 + dirChange2;
00111                                         m_direction2.normalize();
00112 
00113                                         m_timePassed = 0;
00114                                 }
00115                                 m_timePassed += delay;
00116 
00117                                 // Check for bounds.
00118                                 if(!m_boundingBox->isPointInside(m_light0->m_position)) {
00119                                         m_direction0 = m_direction0 * -1.0f;
00120                                 }
00121                                 if(!m_boundingBox->isPointInside(m_light1->m_position)) {
00122                                         m_direction1 = m_direction0 * -1.0f;
00123                                 }
00124                                 if(!m_boundingBox->isPointInside(m_light2->m_position)) {
00125                                         m_direction2 = m_direction0 * -1.0f;
00126                                 }
00127 
00128                                 m_light0->m_position.m_v[0] = m_light0->m_position.m_v[0] + (m_direction0.m_v[0] * velocity);
00129                                 m_light0->m_position.m_v[1] = m_light0->m_position.m_v[1] + (m_direction0.m_v[1] * velocity);
00130                                 m_light0->m_position.m_v[2] = m_light0->m_position.m_v[2] + (m_direction0.m_v[2] * velocity);
00131 
00132                                 m_light1->m_position.m_v[0] = m_light1->m_position.m_v[0] + (m_direction1.m_v[0] * velocity);
00133                                 m_light1->m_position.m_v[1] = m_light1->m_position.m_v[1] + (m_direction1.m_v[1] * velocity);
00134                                 m_light1->m_position.m_v[2] = m_light1->m_position.m_v[2] + (m_direction1.m_v[2] * velocity);
00135 
00136                                 m_light2->m_position.m_v[0] = m_light2->m_position.m_v[0] + (m_direction2.m_v[0] * velocity);
00137                                 m_light2->m_position.m_v[1] = m_light2->m_position.m_v[1] + (m_direction2.m_v[1] * velocity);
00138                                 m_light2->m_position.m_v[2] = m_light2->m_position.m_v[2] + (m_direction2.m_v[2] * velocity);
00139 
00140                                 m_sprite0->setCenter(Vector3f(m_light0->m_position));
00141                                 m_sprite1->setCenter(Vector3f(m_light1->m_position));
00142                                 m_sprite2->setCenter(Vector3f(m_light2->m_position));
00143                         }
00144                 }

Here is the call graph for this function:


Field Documentation

AABB* pge::EffectTest::m_boundingBox [private]
 

Definition at line 232 of file EffectTest.h.

Referenced by EffectTest(), setBoundingBox(), and timer().

Vector3f pge::EffectTest::m_direction0 [private]
 

Definition at line 226 of file EffectTest.h.

Referenced by EffectTest(), and timer().

Vector3f pge::EffectTest::m_direction1 [private]
 

Definition at line 227 of file EffectTest.h.

Referenced by EffectTest(), and timer().

Vector3f pge::EffectTest::m_direction2 [private]
 

Definition at line 228 of file EffectTest.h.

Referenced by EffectTest(), and timer().

Light* pge::EffectTest::m_light0 [private]
 

Definition at line 222 of file EffectTest.h.

Referenced by initLights(), and timer().

Light* pge::EffectTest::m_light1 [private]
 

Definition at line 223 of file EffectTest.h.

Referenced by initLights(), and timer().

Light* pge::EffectTest::m_light2 [private]
 

Definition at line 224 of file EffectTest.h.

Referenced by initLights(), and timer().

Sprite* pge::EffectTest::m_sprite0 [private]
 

Definition at line 218 of file EffectTest.h.

Referenced by initLights(), render(), and timer().

Sprite* pge::EffectTest::m_sprite1 [private]
 

Definition at line 219 of file EffectTest.h.

Referenced by initLights(), render(), and timer().

Sprite* pge::EffectTest::m_sprite2 [private]
 

Definition at line 220 of file EffectTest.h.

Referenced by initLights(), render(), and timer().

unsigned int pge::EffectTest::m_timePassed [private]
 

Definition at line 230 of file EffectTest.h.

Referenced by EffectTest(), and timer().


The documentation for this class was generated from the following file:
Generated on Mon Oct 16 12:09:06 2006 for Phobosengine by doxygen 1.3.4