Changeset 8079 in orxonox.OLD for branches/atmospheric_engine/src/lib/graphics/effects
- Timestamp:
- Jun 1, 2006, 4:15:34 PM (18 years ago)
- Location:
- branches/atmospheric_engine/src/lib/graphics/effects
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.cc
r8056 r8079 11 11 ### File Specific: 12 12 main-programmer: hdavid, amaechler 13 Taken from SkySphere 13 14 */ 14 15 15 // TODO: Vektortextur erzeugen und Regionen ausw ählen, Sky...16 // TODO: Vektortextur erzeugen und Regionen auswaehlen, Sky... 16 17 17 18 #include "cloud_effect.h" … … 21 22 22 23 #include "glincl.h" 23 //#include "graphics_engine.h"24 24 #include "material.h" 25 25 #include <math.h> 26 26 #include "material.h" 27 #include "state.h" 28 #include "p_node.h" 27 29 28 30 #include "parser/tinyxml/tinyxml.h" … … 47 49 { 48 50 this->deactivate(); 51 52 //delete this->skyMaterial; 53 //gluDeleteQuadric(this->sphereObj); 49 54 } 55 56 57 bool CloudEffect::init() 58 { 59 PRINTF(1)("Initializing CloudEffect\n"); 60 61 this->sphereObj = gluNewQuadric(); 62 //this->setParentMode(PNODE_MOVEMENT); 63 64 gluQuadricTexture(this->sphereObj, GL_TRUE); 65 this->setRadius(2000.0); 66 67 mover = 0.0f; 68 69 // Initializing default values 70 this->cloudSpeed = 2.0f; 71 this->cloudTexture = "pictures/sky/cloud1.jpg"; 72 } 73 50 74 51 75 void CloudEffect::loadParams(const TiXmlElement* root) … … 53 77 WeatherEffect::loadParams(root); 54 78 55 LoadParam(root, " animSpeed", this, CloudEffect, setCloudAnimation);56 79 LoadParam(root, "speed", this, CloudEffect, setCloudAnimation); 80 LoadParam(root, "texture", this, CloudEffect, setCloudTexture); 57 81 } 58 82 59 83 60 bool CloudEffect::init()61 {62 // default values63 this->cloudAnimTimeStep = 0;64 65 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);66 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);67 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);68 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);69 70 glGenTextures(2, &texID[0]);71 72 // Generate noise map a73 //CloudEffect::genNoiseMap(cloudMap32_a);74 75 if (this->cloudAnimTimeStep > 0) {76 // Generate noise map b77 //CloudEffect::genNoiseMap(cloudMap32_b);78 }79 80 this->material = new Material();81 82 }83 84 84 bool CloudEffect::activate() 85 85 { 86 PRINTF(0)( "Activating CloudEffect \n");86 PRINTF(0)( "Activating CloudEffect with Material %s\n", this->cloudTexture.c_str()); 87 87 88 this->cloudMaterial = new Material("Sky"); 89 // this->setTexture(this->cloudTexture); 90 this->cloudMaterial->setIllum(3); 91 this->cloudMaterial->setAmbient(1.0, 1.0, 1.0); 92 93 this->cloudMaterial->setDiffuseMap(this->cloudTexture); 88 94 89 95 } … … 103 109 */ 104 110 105 // glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 111 glMatrixMode(GL_MODELVIEW); 112 glPushMatrix(); 106 113 107 this->material->setDiffuseMap("maps/lightning_bolt.png"); 108 this->material->select(); 114 // Move sphere along with the camera 115 Vector r = State::getCameraNode()->getAbsCoor(); 116 glTranslatef(r.x, r.y, r.z); 109 117 110 glPushMatrix();111 // glEnable(GL_TEXTURE_2D);118 // Sky movement 119 glRotatef(mover, 1, 0, 0); 112 120 113 // glBindTexture(GL_TEXTURE_2D, texID[0]); 114 PRINTF(0)("Draw tralala\n"); 115 116 // FIXME : Bind this to the sky - how do I do this? 117 glBegin(GL_QUADS); 118 glTexCoord2f(0.0f, 0.0f); 119 glVertex3f(20, 20, 60); // Bottom Left Of The Texture and Quad 120 121 glTexCoord2f(1.0f, 0.0f); 122 glVertex3f(60, 20, 60); // Bottom Right Of The Texture and Quad 123 124 glTexCoord2f(1.0f, 1.0f); 125 glVertex3f(60, 60, 60); // Top Right Of The Texture and Quad 126 127 glTexCoord2f(0.0f, 1.0f); 128 glVertex3f(20, 60, 60); // Top Left Of The Texture and Quad 129 glEnd(); 130 121 cloudMaterial->select(); 122 gluSphere(this->sphereObj, this->sphereRadius, 20, 20); 131 123 glPopMatrix(); 132 133 124 } 134 125 135 126 void CloudEffect::tick (float dt) 136 127 { 137 128 mover = mover + this->cloudSpeed * dt; 138 129 } 130 131 132 /** 133 * sets the Radius of the Sphere. 134 * @param radius The Radius of The Sphere 135 */ 136 void CloudEffect::setRadius(float radius) 137 { 138 this->sphereRadius = radius; 139 } 140 141 -
branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.h
r8052 r8079 6 6 #define _CLOUD_EFFECT 7 7 8 #include "vector.h"9 #include "vector2D.h"10 11 8 #include "weather_effect.h" 12 9 … … 14 11 #include "sound_source.h" 15 12 13 #include "world_entity.h" 14 #include "glincl.h" 15 16 16 class Material; 17 17 class Vector; 18 18 19 19 class CloudEffect : public WeatherEffect … … 33 33 virtual void tick(float dt); 34 34 35 inline void setCloudAnimation(float timestep) { this->cloudAnimTimeStep = timestep; } 35 void setRadius(float radius); 36 void setTexture(char* fileName); 37 36 38 37 39 private: 38 // Basic noise maps 32x32 39 float cloudMap32_a[32 * 32]; 40 float cloudMap32_b[32 * 32]; 41 float cloudMap32_c[32 * 32]; 40 void initialize(char* fileName); 42 41 43 // The cloud map 256x256 44 float cloudMap256[256 * 256]; 42 GLUquadricObj* sphereObj; // A Placeholder for the SkySphere. 43 Material* cloudMaterial; // A Material for the SkySphere. 44 float sphereRadius; // Radius of the SkySphere. 45 float mover; 46 float cloudSpeed; 47 std::string cloudTexture; 45 48 46 // Temporary array to hold texture RGB values 47 char cloudTexture[256][256][3]; 48 49 GLuint texID[2]; 50 float timer; 51 52 bool cloudAnimTimeStep; 53 54 float noise(int x, int y, int random); 55 float interpolate(float x, float y, float *map); 56 void overlapOctaves(); 57 void expFilter(); 58 59 void genNoiseMap(float *map); 60 void genCloudTexture(); 61 void calcAnimMap(float timer); 62 Material* material; 49 inline void setCloudTexture(const std::string& file) { this->cloudTexture = file; } 50 inline void setCloudAnimation(float speed) { this->cloudSpeed = speed; } 63 51 64 52 };
Note: See TracChangeset
for help on using the changeset viewer.