Changeset 7951 in orxonox.OLD for branches/atmospheric_engine
- Timestamp:
- May 29, 2006, 1:29:35 PM (19 years ago)
- Location:
- branches/atmospheric_engine/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/atmospheric_engine/src/lib/graphics/effects/atmospheric_engine.cc
r7836 r7951 127 127 for (it = weatherEffects->begin(); it != weatherEffects->end(); it++) 128 128 { 129 printf("%s::%s \n", (*it)->getClassName(), (*it)->getName());129 //printf("%s::%s \n", (*it)->getClassName(), (*it)->getName()); 130 130 dynamic_cast<WeatherEffect*>(*it)->tick(dt); 131 131 } -
branches/atmospheric_engine/src/lib/graphics/effects/lightening_effect.cc
r7810 r7951 18 18 #include "util/loading/load_param.h" 19 19 #include "util/loading/factory.h" 20 #include " render2D/image_plane.h"20 #include "effects/billboard.h" 21 21 22 22 #include "glincl.h" … … 32 32 33 33 34 lightening = new ImagePlane(NULL);35 lightening->setTexture("maps/lightning_bolt.png");36 lightening->setSize(50, 50);37 lightening->setAbsCoor2D(10,10);38 lightening->setVisibility(true);34 billboard = new Billboard(NULL); 35 billboard->setTexture("maps/lightning_bolt.png"); 36 //billboard->setSize(50, 50); 37 //billboard->setAbsCoor2D(10,10); 38 //billboard->setVisibility(true); 39 39 40 40 … … 50 50 { 51 51 this->deactivate(); 52 delete lightening;52 delete billboard; 53 53 } 54 54 -
branches/atmospheric_engine/src/lib/graphics/effects/lightening_effect.h
r7810 r7951 15 15 16 16 17 class ImagePlane;17 class Billboard; 18 18 19 19 class LighteningEffect : public WeatherEffect … … 33 33 34 34 private: 35 ImagePlane* lightening;35 Billboard* billboard; 36 36 37 37 }; -
branches/atmospheric_engine/src/world_entities/Makefile.am
r7155 r7951 28 28 \ 29 29 \ 30 effects/explosion.cc 30 effects/explosion.cc \ 31 effects/billboard.cc 31 32 32 33 … … 56 57 \ 57 58 effects/explosion.h \ 59 effects/billboard.h \ 58 60 \ 59 61 $(WorldEntities_HEADERS_) -
branches/atmospheric_engine/src/world_entities/effects/billboard.cc
r7810 r7951 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 4 Copyright (C) 200 4orx4 Copyright (C) 2006 orx 5 5 6 6 This program is free software; you can redistribute it and/or modify … … 9 9 any later version. 10 10 11 ### File Specific 12 main-programmer: Patrick Boenzli11 ### File Specific: 12 main-programmer: David Hasenfratz 13 13 */ 14 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON15 14 15 #include "billboard.h" 16 16 17 #include "lightning_bolt.h" 17 #include "util/loading/load_param.h" 18 #include "util/loading/factory.h" 18 19 19 #include " util/loading/factory.h"20 #include "graphics_engine.h" 20 21 #include "material.h" 21 22 #include "util/loading/resource_manager.h" 23 22 #include "glincl.h" 23 #include "state.h" 24 24 25 25 26 26 using namespace std; 27 27 28 CREATE_FACTORY(LightningBolt, CL_LIGHTNING_BOLT); 28 29 CREATE_FACTORY(Billboard, CL_BILLBOARD); 29 30 30 31 31 32 /** 32 * standardconstructor33 */34 LightningBolt::LightningBolt(const TiXmlElement* root)33 * standart constructor 34 */ 35 Billboard::Billboard (const TiXmlElement* root) 35 36 { 36 this-> setClassID(CL_LIGHTNING_BOLT, "LightningBolt");37 this->init(); 37 38 38 this->toList(OM_COMMON); 39 40 this->bRender = false; 41 this->time = 0.0; 42 this->flashFrequency = 0.6f; 43 this->flashConstTime = 0.07f; 44 45 this->material = new Material(); 46 this->material->setDiffuseMap("maps/lightning_bolt.png"); 47 //this->offset = Vector(-1440.00, 100.00, 280.00); 48 49 this->setAbsCoor(offset); 50 this->width = 100.0f; 51 this->height = 300.0f; 52 this->bNewCoordinate = false; 53 54 this->seedX = 200.f; 55 this->seedZ = 500.0f; 56 this->seedTime = 4.0f; 57 58 this->soundSource.setSourceNode(this); 59 60 //load sound 61 if (this->thunderBuffer != NULL) 62 ResourceManager::getInstance()->unload(this->thunderBuffer); 63 this->thunderBuffer = (SoundBuffer*)ResourceManager::getInstance()->load("sound/thunder.wav", WAV); 39 if( root) 40 this->loadParams(root); 64 41 } 65 42 66 43 67 44 /** 68 * standard deconstructor69 */70 LightningBolt::~LightningBolt()45 * destroys a Billboard 46 */ 47 Billboard::~Billboard () 71 48 { 72 } 73 74 void LightningBolt::activate() 75 { 76 } 77 78 79 void LightningBolt::deactivate() 80 { 81 49 if (this->material) 50 delete this->material; 82 51 } 83 52 84 53 85 54 /** 86 * signal tick, time dependent things will be handled here 87 * @param time since last tick 88 */ 89 void LightningBolt::tick (float dt) 55 * initializes the Billboard 56 */ 57 void Billboard::init() 90 58 { 91 this->time += dt; 59 this->setClassID(CL_BILLBOARD, "Billboard"); 60 this->setName("Billboard"); 92 61 93 if( this->time > this->flashFrequency) 94 { 95 this->bRender = true; 96 this->time = 0.0f; 97 this->soundSource.play(this->thunderBuffer); 98 } 99 else if( this->bRender && this->time > this->flashConstTime) 100 { 101 this->bRender = false; 102 this->time = 0.0f; 103 this->bNewCoordinate = true; 104 } 105 106 if( this->bNewCoordinate) 107 { 108 this->flashFrequency = this->seedTime * (float)rand()/(float)RAND_MAX + 0.1; 109 this->setAbsCoor( - 800.0f - this->seedX * (float)rand()/(float)RAND_MAX, 250.00, -200.0f + this->seedZ * (float)rand()/(float)RAND_MAX); 110 this->bNewCoordinate = false; 111 } 62 this->material = new Material(); 63 this->setTexture("pictures/error_texture.png"); 64 this->setAbsCoor(0, 0, 0); 65 this->setVisibiliy(true); 66 this->setSize(10, 10); 112 67 } 113 68 114 69 115 void LightningBolt::draw() const 70 /** 71 * load params 72 * @param root TiXmlElement object 73 */ 74 void Billboard::loadParams(const TiXmlElement* root) 116 75 { 117 if( this->bRender)118 {76 LoadParam(root, "texture", this->material, Material, setDiffuseMap) 77 .describe("the texture-file to load onto the Billboard"); 119 78 120 glPushMatrix(); 121 glTranslatef (this->getAbsCoor ().x, 122 this->getAbsCoor ().y, 123 this->getAbsCoor ().z); 124 125 glRotatef(90, 0.0f,1.0f,0.0f); 126 127 // Vector tmpRot = drawPart->orientation.getSpacialAxis(); 128 // glRotatef (drawPart->orientation.getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z ); 129 130 // glPushAttrib(GL_ENABLE_BIT); 131 // glDisable(GL_LIGHTING); 132 // glDisable(GL_BLEND); 133 134 this->material->select(); 135 136 glBegin(GL_QUADS); 137 glTexCoord2f(1.0f, 1.0f); glVertex3f(-width/2, -height/2, 0.0f); 138 glTexCoord2f(0.0f, 1.0f); glVertex3f( width/2, -height/2, 0.0f); 139 glTexCoord2f(0.0f, 0.0f); glVertex3f( width/2, height/2, 0.0f); 140 glTexCoord2f(1.0f, 0.0f); glVertex3f(-width/2, height/2, 0.0f); 141 glEnd(); 142 143 // glPopAttrib(); 144 145 glPopMatrix(); 146 } 79 LoadParam(root, "size", this, Billboard, setSize) 80 .describe("the size of the Billboard in Pixels"); 147 81 } 148 82 149 83 84 /** 85 * sets the size of the Billboard. 86 * @param size the size in pixels 87 */ 88 void Billboard::setSize(float sizeX, float sizeY) 89 { 90 this->sizeX = sizeX; 91 this->sizeY = sizeY; 92 } 93 94 95 /** 96 * sets the material to load 97 * @param textureFile The texture-file to load 98 */ 99 void Billboard::setTexture(const std::string& textureFile) 100 { 101 this->material->setDiffuseMap(textureFile); 102 } 103 104 105 /** 106 * ticks the Billboard 107 * @param dt the time to ticks 108 */ 109 void Billboard::tick(float dt) 110 {/* 111 float z = 0.0f; 112 glReadPixels ((int)this->getAbsCoor2D().x, 113 GraphicsEngine::getInstance()->getResolutionY()-(int)this->getAbsCoor2D().y-1, 114 1, 115 1, 116 GL_DEPTH_COMPONENT, 117 GL_FLOAT, 118 &z); 119 120 GLdouble objX=.0, objY=.0, objZ=.0; 121 gluUnProject(this->getAbsCoor2D().x, 122 GraphicsEngine::getInstance()->getResolutionY()-this->getAbsCoor2D().y-1, 123 .99, // z 124 GraphicsEngine::modMat, 125 GraphicsEngine::projMat, 126 GraphicsEngine::viewPort, 127 &objX, 128 &objY, 129 &objZ );*/ 130 } 131 132 133 /** 134 * draws the billboard 135 */ 136 void Billboard::draw() const 137 { 138 if( !this->isVisible()) 139 return; 140 141 glPushMatrix(); 142 143 glTranslatef(this->getAbsCoor().x, this->getAbsCoor().y, this->getAbsCoor().z); 144 this->material->select(); 145 146 glBegin(GL_QUADS); 147 glTexCoord2f(1.0f, 1.0f); glVertex3f(-sizeX/2, -sizeY/2, 0.0f); 148 glTexCoord2f(0.0f, 1.0f); glVertex3f( sizeX/2, -sizeY/2, 0.0f); 149 glTexCoord2f(0.0f, 0.0f); glVertex3f( sizeX/2, sizeY/2, 0.0f); 150 glTexCoord2f(1.0f, 0.0f); glVertex3f(-sizeX/2, sizeY/2, 0.0f); 151 glEnd(); 152 153 glPopMatrix(); 154 } -
branches/atmospheric_engine/src/world_entities/effects/billboard.h
r7810 r7951 1 1 /*! 2 * @file lightning_bolt.h 3 * @brief a LightningBolt Projectile 2 * @file billboard.h 4 3 */ 5 4 6 #ifndef _ LIGHTNING_BOLT_H7 #define _ LIGHTNING_BOLT_H5 #ifndef _BILLBOARD_H 6 #define _BILLBOARD_H 8 7 9 8 #include "world_entity.h" 10 9 11 #include "sound_buffer.h" 12 #include "sound_source.h" 10 class Material; 11 class TiXmlElement; 13 12 14 class Material; 15 16 class LightningBolt : public WorldEntity 13 class Billboard : public WorldEntity 17 14 { 18 15 public: 19 LightningBolt(const TiXmlElement* root = NULL);20 virtual ~ LightningBolt();16 Billboard(const TiXmlElement* root = NULL); 17 virtual ~Billboard(); 21 18 22 v irtual void activate();23 v irtual void deactivate();19 void init(); 20 void loadParams(const TiXmlElement* root); 24 21 25 virtual void tick(float time); 22 void setSize(float sizeX, float sizeY); 23 void setTexture(const std::string& textureFile); 24 25 virtual void tick(float dt); 26 26 virtual void draw() const; 27 27 28 28 private: 29 float flashFrequency; //!< frequency to activate itself 30 float flashRisingTime; //!< time to rise 31 float flashConstTime; //!< time to be drawn 32 float flashFallTime; //!< time to fall 33 34 float time; //!< time 35 36 bool bRender; 37 bool bNewCoordinate; 38 Material* material; 39 Vector offset; 40 float width; 41 float height; 42 43 float seedX; 44 float seedZ; 45 float seedTime; 46 47 SoundSource soundSource; 48 SoundBuffer* thunderBuffer; 29 Material* material; 30 float sizeX; 31 float sizeY; 49 32 }; 50 33 51 #endif /* _ LIGHTNING_BOLT_H */34 #endif /* _BILLBOARD_H */
Note: See TracChangeset
for help on using the changeset viewer.