Changeset 8730 in orxonox.OLD for branches/atmospheric_engine
- Timestamp:
- Jun 22, 2006, 4:19:27 PM (18 years ago)
- Location:
- branches/atmospheric_engine/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/atmospheric_engine/src/defs/class_id.h
r8490 r8730 182 182 CL_MAPPED_WATER = 0x00000311, 183 183 CL_BSP_ENTITY = 0x00000312, 184 CL_SKYDOME = 0x00000313, 184 185 185 186 // Playables -
branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.cc
r8713 r8730 54 54 this->deactivate(); 55 55 56 if (glIsTexture(noise3DTexName)) 57 glDeleteTextures(1, &noise3DTexName); 58 56 59 delete shader; 57 60 } … … 87 90 0, GL_RGBA, GL_UNSIGNED_BYTE, noise3DTexPtr); 88 91 92 skydome = new Skydome(); 93 skydome->setTexture(noise3DTexName); 94 89 95 shader = new Shader(ResourceManager::getInstance()->getDataDir() + "/shaders/cloud.vert", 90 96 ResourceManager::getInstance()->getDataDir() + "/shaders/cloud.frag"); … … 99 105 100 106 this->shader->deactivateShader(); 107 108 skydome->setShader(shader); 101 109 } 102 110 … … 130 138 this->shader->deactivateShader(); 131 139 132 this->generateSkyPlane(this->divs, this->planetRadius, this->atmosphericRadius, 1, 1);140 skydome->generateSkyPlane(this->divs, this->planetRadius, this->atmosphericRadius, 1, 1); 133 141 134 142 this->cloudActivate = true; … … 144 152 void CloudEffect::draw() const 145 153 { 146 if (!this->cloudActivate)147 return;148 149 glPushAttrib(GL_ENABLE_BIT);150 151 glDisable(GL_LIGHTING);152 glDisable(GL_BLEND);153 154 glEnable(GL_TEXTURE_3D);155 glBindTexture(GL_TEXTURE_3D, noise3DTexName);156 157 this->shader->activateShader();158 offset->set(0.0f, 0.0f, offsetZ);159 160 161 /*glColor3f(1.0, 1.0, 1.0);162 glBegin(GL_QUADS);163 164 glTexCoord2f(1.0f, 1.0f); glVertex3f(0.0f, 0.0f, 0.0f);165 glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.0f, 10.0f, 0.0f);166 glTexCoord2f(0.0f, 0.0f); glVertex3f( 10.0f, 10.0f, 0.0f);167 glTexCoord2f(1.0f, 0.0f); glVertex3f(10.0f, 0.0f, 0.0f);168 169 glEnd();*/170 171 glPushMatrix();172 glTranslatef(0.0f,pRadius,0.0f);173 //glRotatef(timeGetTime()/2000.0f,0.0f, 1.0f, 0.0f);174 175 glBegin(GL_TRIANGLES);176 177 for (int i=0; i < numIndices; i++)178 {179 glColor3f(1.0f, 1.0f, 1.0f);180 181 glTexCoord2f(planeVertices[indices[i]].u, planeVertices[indices[i]].v);182 glVertex3f(planeVertices[indices[i]].x, planeVertices[indices[i]].y, planeVertices[indices[i]].z);183 }184 185 glEnd();186 187 glPopMatrix();188 189 this->shader->deactivateShader();190 191 glPopAttrib();192 193 154 } 194 155 … … 196 157 { 197 158 if (this->cloudActivate) 159 { 198 160 this->offsetZ += 0.05 * dt * this->animationSpeed; 199 } 200 201 void CloudEffect::generateSkyPlane(int divisions, float planetRadius, float atmosphereRadius, float hTile, float vTile) 202 { 203 // Make sure our vertex array is clear 204 if (planeVertices) 205 { 206 delete planeVertices; 207 planeVertices = NULL; 208 } 209 210 // Make sure our index array is clear 211 if (indices) 212 { 213 delete indices; 214 indices = NULL; 215 } 216 217 // Set the number of divisions into a valid range 218 int divs = divisions; 219 if (divisions < 1) 220 divs = 1; 221 222 if (divisions > 256) 223 divs = 256; 224 225 pRadius = planetRadius; 226 227 // Initialize the Vertex and indices arrays 228 numPlaneVertices = (divs + 1) * (divs + 1); // 1 division would give 4 verts 229 numIndices = divs * divs * 2 * 3; // 1 division would give 6 indices for 2 tris 230 231 planeVertices = new VERTEX[numPlaneVertices]; 232 memset(planeVertices, 0, sizeof(VERTEX)); 233 234 indices = new int[numIndices]; 235 memset(indices, 0, sizeof(int)*numIndices); 236 237 // Calculate some values we will need 238 float plane_size = 2.0f * (float)sqrt((SQR(atmosphereRadius)-SQR(planetRadius))); 239 float delta = plane_size/(float)divs; 240 float tex_delta = 2.0f/(float)divs; 241 242 // Variables we'll use during the dome's generation 243 float x_dist = 0.0f; 244 float z_dist = 0.0f; 245 float x_height = 0.0f; 246 float z_height = 0.0f; 247 float height = 0.0f; 248 249 VERTEX SV; // temporary vertex 250 251 for (int i=0;i <= divs;i++) 252 { 253 for (int j=0; j <= divs; j++) 254 { 255 x_dist = (-0.5f * plane_size) + ((float)j*delta); 256 z_dist = (-0.5f * plane_size) + ((float)i*delta); 257 258 x_height = (x_dist*x_dist) / atmosphereRadius; 259 z_height = (z_dist*z_dist) / atmosphereRadius; 260 height = x_height + z_height; 261 262 SV.x = x_dist; 263 SV.y = 0.0f - height; 264 SV.z = z_dist; 265 266 // Calculate the texture coordinates 267 SV.u = hTile*((float)j * tex_delta*0.5f); 268 SV.v = vTile*(1.0f - (float)i * tex_delta*0.5f); 269 270 planeVertices[i*(divs+1)+j] = SV; 271 } 272 } 273 274 // Calculate the indices 275 int index = 0; 276 for (int i=0; i < divs;i++) 277 { 278 for (int j=0; j < divs; j++) 279 { 280 int startvert = (i*(divs+1) + j); 281 282 // tri 1 283 indices[index++] = startvert; 284 indices[index++] = startvert+1; 285 indices[index++] = startvert+divs+1; 286 287 // tri 2 288 indices[index++] = startvert+1; 289 indices[index++] = startvert+divs+2; 290 indices[index++] = startvert+divs+1; 291 } 292 } 293 } 161 162 this->shader->activateShader(); 163 offset->set(0.0f, 0.0f, offsetZ); 164 this->shader->deactivateShader(); 165 } 166 } 167 294 168 295 169 void CloudEffect::make3DNoiseTexture() -
branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.h
r8713 r8730 11 11 #include "sound_source.h" 12 12 13 #include " world_entity.h"13 #include "skydome.h" 14 14 #include "material.h" 15 15 #include "shader.h" … … 30 30 #define at2(rx,ry) ( rx * q[0] + ry * q[1] ) 31 31 #define at3(rx,ry,rz) ( rx * q[0] + ry * q[1] + rz * q[2] ) 32 33 34 #define DTOR (PI/180.0f)35 #define SQR(x) (x*x)36 37 typedef struct {38 float x,y,z;39 unsigned int color;40 float u, v;41 } VERTEX;42 32 43 33 … … 100 90 101 91 // Material cloudMaterial; 92 Skydome* skydome; 102 93 103 94 // SHADER STUFF … … 123 114 int B; 124 115 int BM; 125 126 // SKYPLANE STUFF127 VERTEX *planeVertices;128 int numPlaneVertices;129 130 int *indices;131 int numIndices;132 133 float pRadius;134 135 VERTEX *vertices;136 int numVertices;137 116 }; 138 117 -
branches/atmospheric_engine/src/world_entities/WorldEntities.am
r8490 r8730 8 8 world_entities/skysphere.cc \ 9 9 world_entities/skybox.cc \ 10 world_entities/skydome.cc \ 10 11 world_entities/terrain.cc \ 11 12 world_entities/satellite.cc \ … … 64 65 skysphere.h \ 65 66 skybox.h \ 67 skydome.h \ 66 68 terrain.h \ 67 69 satellite.h \
Note: See TracChangeset
for help on using the changeset viewer.