Changeset 8175 in orxonox.OLD for branches/atmospheric_engine
- Timestamp:
- Jun 6, 2006, 6:34:02 PM (18 years ago)
- Location:
- branches/atmospheric_engine/src/lib/graphics/effects
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.cc
r8119 r8175 11 11 ### File Specific: 12 12 main-programmer: hdavid, amaechler 13 Taken from SkySphere 13 14 INSPIRED BY http://www.codesampler.com/usersrc/usersrc_6.htm#oglu_sky_dome_shader 14 15 */ 15 16 // TODO: Vektortextur erzeugen und Regionen auswaehlen, Sky...17 16 18 17 #include "cloud_effect.h" … … 20 19 #include "util/loading/load_param.h" 21 20 #include "util/loading/factory.h" 21 #include "util/loading/resource_manager.h" 22 22 23 23 #include "glincl.h" 24 24 #include "material.h" 25 25 #include <math.h> 26 #include "material.h"27 26 #include "state.h" 28 27 #include "p_node.h" 28 #include "shader.h" 29 29 30 30 #include "parser/tinyxml/tinyxml.h" 31 32 #include "sglmodel.h" 31 33 32 34 using namespace std; … … 50 52 this->deactivate(); 51 53 52 //delete this->skyMaterial; 53 //gluDeleteQuadric(this->sphereObj); 54 delete this->cloudMaterial; 55 56 g_sky_model.Delete(); 57 Shader::unload(this->skyShader); 58 54 59 } 55 60 … … 59 64 PRINTF(1)("Initializing CloudEffect\n"); 60 65 61 this->sphereObj = gluNewQuadric(); 62 //this->setParentMode(PNODE_MOVEMENT); 63 64 gluQuadricTexture(this->sphereObj, GL_TRUE); 65 gluQuadricOrientation(this->sphereObj, GLU_INSIDE); 66 67 this->setRadius(1900.0); 68 69 mover = 0.0f; 70 71 // Initializing default values 72 this->cloudSpeed = 1.0f; 66 // glClearColor(0.0f, 0.0f, 0.0f, 0.0f); 67 glShadeModel(GL_SMOOTH); 68 glEnable(GL_DEPTH_TEST); 69 glEnable(GL_CULL_FACE); 70 glCullFace(GL_BACK); 71 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); 72 73 glLineWidth(3.0f); 74 75 float diffuse[] = {1.0f, 1.0f, 1.0f, 1.0f}; 76 float position[] = {0.0f, 2.0f, 0.0f, 1.0f}; 77 float specular[] = {1.0f, 1.0f, 1.0f, 1.0f}; 78 79 glEnable(GL_LIGHTING); 80 glEnable( GL_LIGHT0); 81 glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); 82 glLightfv(GL_LIGHT0, GL_POSITION, position); 83 glLightfv(GL_LIGHT0, GL_SPECULAR, specular); 84 85 float shininess = 5.0f; 86 glEnable(GL_COLOR_MATERIAL); 87 glMaterialf( GL_FRONT, GL_SHININESS, shininess); 88 glMaterialfv(GL_FRONT, GL_SPECULAR, specular); 89 73 90 this->cloudTexture = "pictures/sky/cloud1.jpg"; 91 92 g_sky_model.Load("sky.sgl"); 93 g_sky_model.Unitize(); 94 95 /* Get the bounding box of the sky dome. */ 96 float bbox[3] = {0}; 97 g_sky_model.GetDimensions(bbox[0], bbox[1], bbox[2]); 98 99 // this->skyShader = (Shader*)ResourceManager::getInstance()->load("shaders/sky.vert", SHADER, RP_GAME, "shaders/skyfrag"); 100 this->skyShader = new Shader( ResourceManager::getInstance()->getDataDir() + "/shaders/sky.vert", ResourceManager::getInstance()->getDataDir() +"/shaders/sky.frag"); 101 102 /* Tell the shader the bounding box of the sky dome. */ 103 this->skyShader->bindShader("bbox", bbox, 4); 104 105 //g_cloud_texture = 0; 106 107 g_tint[4] = ( 0.9f, 0.7f, 0.7f, 1.0f ); 108 g_scroll = 1.0f; 109 time = 0.0f; 74 110 } 75 111 … … 101 137 void CloudEffect::draw() const 102 138 { 103 /* TODO: 104 -Load a texture, for now from an existing image, a cloud texture 105 -Blend / Overlay this with a blue sky like in the tutorial 106 -Animate it (for now move it along the sky) 107 */ 139 140 // glMatrixMode(GL_MODELVIEW); 141 // glPushMatrix(); 142 // 143 // // Move sphere along with the camera 144 // Vector r = State::getCameraNode()->getAbsCoor(); 145 // glTranslatef(r.x, r.y, r.z); 146 // 147 // // Sky movement 148 // glRotatef(mover, 0, 0, 1); 149 // 150 // cloudMaterial->select(); 151 // gluSphere(this->sphereObj, this->sphereRadius, 20, 20); 152 // glPopMatrix(); 153 154 // ****** 108 155 109 156 glMatrixMode(GL_MODELVIEW); 110 157 glPushMatrix(); 111 158 112 // Move sphere along with the camera 113 Vector r = State::getCameraNode()->getAbsCoor(); 114 glTranslatef(r.x, r.y, r.z); 115 116 // Sky movement 117 glRotatef(mover, 0, 0, 1); 118 119 cloudMaterial->select(); 120 gluSphere(this->sphereObj, this->sphereRadius, 20, 20); 159 static float time = 0.0f; 160 // static vector3f eye = {0.0f, 0.0f, 0.0f}, look = {0.0f, 0.0f, 1.0f}, up = {0.0f, 1.0f, 0.0f}; 161 162 // glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 163 // glLoadIdentity(); 164 // gluLookAt(eye[x], eye[y], eye[z], look[x], look[y], look[z], up[x], up[y], up[z]); 165 166 /* Turn off the depth buffer when rendering the background. */ 167 // glDisable(GL_DEPTH_TEST); 168 169 this->skyShader->activateShader(); 170 171 /* Select the shader program and update parameters. */ 172 /* The "time" parameter controls the cloud scrolling. */ 173 this->skyShader->bindShader("time", &time, 1); 174 /* The "horizon" parameter controls the sky tinting. */ 175 this->skyShader->bindShader("horizon", g_tint, 4); 176 177 glActiveTexture(GL_TEXTURE0 + 0); 178 glActiveTexture(GL_TEXTURE0 + 1); 179 /* Load the cloud texture. */ 180 //glBindTexture(GL_TEXTURE_2D, g_cloud_texture); 181 this->cloudMaterial->select(); 182 183 /* Render the sky dome. */ 184 g_sky_model.Render(); 185 186 /* Unselect the shader. */ 187 Shader::deactivateShader(); 188 189 /* Turn on the depth buffer when rendering the foreground. */ 190 // glEnable(GL_DEPTH_TEST); 191 192 /* Render the forground, for example, a teapot or bunny. */ 193 // glEnable(GL_LIGHTING); 194 // glColor3f(0.0f, 1.0f, 0.0f); 195 // glBegin(GL_QUADS); 196 // glNormal3f( 0.0f, 1.0f, 0.0f); 197 // glVertex3f( 20.0f, -1.0f, 20.0f); 198 // glVertex3f( 20.0f, -1.0f, -20.0f); 199 // glVertex3f(-20.0f, -1.0f, -20.0f); 200 // glVertex3f(-20.0f, -1.0f, 20.0f); 201 // glEnd(); 202 // glDisable(GL_LIGHTING); 203 121 204 glPopMatrix(); 122 205 } … … 124 207 void CloudEffect::tick (float dt) 125 208 { 126 mover = mover + this->cloudSpeed * dt; 127 } 128 129 130 /** 131 * sets the Radius of the Sphere. 132 * @param radius The Radius of The Sphere 133 */ 134 void CloudEffect::setRadius(float radius) 135 { 136 this->sphereRadius = radius; 137 } 138 139 209 // mover = mover + this->cloudSpeed * dt; 210 211 /* Update the timer for scrolling the clouds. */ 212 time = time + ((1.0f / 2000.0f) * g_scroll); 213 } 214 -
branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.h
r8119 r8175 14 14 #include "glincl.h" 15 15 16 #include "sglmodel.h" 17 18 class Shader; 16 19 class Material; 17 20 class Vector; … … 33 36 virtual void tick(float dt); 34 37 35 void setRadius(float radius);36 void setTexture(char* fileName);38 // void setRadius(float radius); 39 // void setTexture(char* fileName); 37 40 38 41 … … 40 43 void initialize(char* fileName); 41 44 42 GLUquadricObj*sphereObj; // A Placeholder for the Sphere.45 // GLUquadricObj* sphereObj; // A Placeholder for the Sphere. 43 46 Material* cloudMaterial; // A Material for the Sphere. 44 47 float sphereRadius; // Radius of the Sphere. … … 51 54 inline void setCloudAnimation(float speed) { this->cloudSpeed = speed; } 52 55 56 Sglmodel_sgl g_sky_model; 57 Shader* skyShader; 58 59 float g_tint[4]; 60 float g_scroll; 61 62 float time; 63 64 53 65 }; 54 66
Note: See TracChangeset
for help on using the changeset viewer.