Changeset 10107 in orxonox.OLD for branches/playability/src/world_entities/effects
- Timestamp:
- Dec 19, 2006, 10:03:19 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/playability/src/world_entities/effects/trail.cc
r10104 r10107 174 174 //glMatrixMode(GL_MODELVIEW); 175 175 //glLoadIdentity(); 176 177 glEnable( 176 /* 177 glEnable(GL_BLEND); 178 178 glBlendFunc(GL_SRC_ALPHA,GL_ONE); 179 glDisable( GL_ALPHA_TEST); 179 glDisable( GL_ALPHA_TEST);*/ 180 180 181 181 glTranslatef(-this->getAbsCoor().x,-this->getAbsCoor().y,-this->getAbsCoor().z); … … 183 183 this->material->select(); 184 184 185 float alphaStep = (trailAlphaMax - trailAlphaMin)/this->sections;185 //float alphaStep = 1.0 / this->sections; 186 186 187 187 glBegin(GL_TRIANGLE_STRIP); … … 190 190 for( int i = 1; i < this->sections-1; i++) 191 191 { 192 radone = this->radius * (1.0-i*fact );193 radzero = this->radius * (1.0-(i+1)*fact );192 radone = this->radius * (1.0-i*fact + 0.2 * (float)rand()/(float)RAND_MAX); 193 radzero = this->radius * (1.0-(i+1)*fact + 0.2 * (float)rand()/(float)RAND_MAX); 194 194 195 195 now = this->nodeList[i]; … … 204 204 Q[3] = now + Vector(0,-radone,0) ; 205 205 206 glTexCoord2f(0.0f, 0.0f); gl Color4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[0].x,Q[0].y,Q[0].z);207 glTexCoord2f(1.0f, 0.0f); gl Color4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[3].x,Q[3].y,Q[3].z);206 glTexCoord2f(0.0f, 0.0f); glVertex3f(Q[0].x,Q[0].y,Q[0].z); 207 glTexCoord2f(1.0f, 0.0f); glVertex3f(Q[3].x,Q[3].y,Q[3].z); 208 208 209 209 if( i == this->sections - 1) … … 212 212 Q[1] = later + Vector(0,radzero,0) ; 213 213 Q[2] = later + Vector(0,-radzero,0) ; 214 glTexCoord2f(0.0f, 1.0f); gl Color4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[1].x,Q[1].y,Q[1].z);215 glTexCoord2f(1.0f, 1.0f); gl Color4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[2].x,Q[2].y,Q[2].z);214 glTexCoord2f(0.0f, 1.0f); glVertex3f(Q[1].x,Q[1].y,Q[1].z); 215 glTexCoord2f(1.0f, 1.0f); glVertex3f(Q[2].x,Q[2].y,Q[2].z); 216 216 } 217 217 … … 222 222 for( int i = this->sections-1; i > 0; i--) 223 223 { 224 radone = this->radius * (1.0-i*fact );225 radzero = this->radius * (1.0-(i-1)*fact );224 radone = this->radius * (1.0-i*fact + 0.2 * (float)rand()/(float)RAND_MAX); 225 radzero = this->radius * (1.0-(i-1)*fact + 0.2 * (float)rand()/(float)RAND_MAX); 226 226 227 227 now = this->nodeList[i]; … … 236 236 Q[3] = now + Vector(0,-radone,0) ; 237 237 238 glTexCoord2f(1.0f, 0.0f); gl Color4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[3].x,Q[3].y,Q[3].z+0.01f);239 glTexCoord2f(0.0f, 0.0f); gl Color4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[0].x,Q[0].y,Q[0].z+0.01f);238 glTexCoord2f(1.0f, 0.0f); glVertex3f(Q[3].x,Q[3].y,Q[3].z+0.01f); 239 glTexCoord2f(0.0f, 0.0f); glVertex3f(Q[0].x,Q[0].y,Q[0].z+0.01f); 240 240 241 241 if( i == 1) … … 243 243 Q[1] = later + Vector(0,radzero,0) ; 244 244 Q[2] = later + Vector(0,-radzero,0) ; 245 glTexCoord2f(1.0f, 1.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[2].x,Q[2].y,Q[2].z+0.01f); 246 glTexCoord2f(0.0f, 1.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[1].x,Q[1].y,Q[1].z+0.01f); 245 246 glTexCoord2f(1.0f, 1.0f); glVertex3f(Q[2].x,Q[2].y,Q[2].z+0.01f); 247 glTexCoord2f(0.0f, 1.0f); glVertex3f(Q[1].x,Q[1].y,Q[1].z+0.01f); 247 248 } 248 249 … … 254 255 for( int i = 1; i < this->sections-1; i++) 255 256 { 256 radone = this->radius * (1.0-i*fact );257 radzero = this->radius * (1.0-(i+1)*fact );257 radone = this->radius * (1.0-i*fact + 0.2 * (float)rand()/(float)RAND_MAX); 258 radzero = this->radius * (1.0-(i+1)*fact + 0.2 * (float)rand()/(float)RAND_MAX); 258 259 259 260 now = this->nodeList[i]; … … 268 269 Q[3] = now + targ.cross(Vector(0,-radone,0)) ; 269 270 270 glTexCoord2f(0.0f, 0.0f); gl Color4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[0].x,Q[0].y,Q[0].z);271 glTexCoord2f(1.0f, 0.0f); gl Color4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[3].x,Q[3].y,Q[3].z);271 glTexCoord2f(0.0f, 0.0f); glVertex3f(Q[0].x,Q[0].y,Q[0].z); 272 glTexCoord2f(1.0f, 0.0f); glVertex3f(Q[3].x,Q[3].y,Q[3].z); 272 273 273 274 if( i == this->sections-1) … … 275 276 Q[1] = later + targ.cross(Vector(0,radzero,0)) ; 276 277 Q[2] = later + targ.cross(Vector(0,-radzero,0)) ; 277 glTexCoord2f(0.0f, 1.0f); gl Color4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[1].x,Q[1].y,Q[1].z);278 glTexCoord2f(1.0f, 1.0f); gl Color4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[2].x,Q[2].y,Q[2].z);278 glTexCoord2f(0.0f, 1.0f); glVertex3f(Q[1].x,Q[1].y,Q[1].z); 279 glTexCoord2f(1.0f, 1.0f); glVertex3f(Q[2].x,Q[2].y,Q[2].z); 279 280 } 280 281 … … 285 286 for( int i = this->sections-1; i > 0; i--) 286 287 { 287 radone = this->radius * (1.0-i*fact );288 radzero = this->radius * (1.0-(i-1)*fact );288 radone = this->radius * (1.0-i*fact + 0.2 * (float)rand()/(float)RAND_MAX); 289 radzero = this->radius * (1.0-(i-1)*fact + 0.2 * (float)rand()/(float)RAND_MAX); 289 290 290 291 now = this->nodeList[i]; … … 299 300 Q[3] = now + targ.cross(Vector(0,-radone,0)) ; 300 301 301 glTexCoord2f(0.0f, 0.0f); gl Color4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[0].x+0.01f,Q[0].y,Q[0].z);302 glTexCoord2f(1.0f, 0.0f); gl Color4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[3].x+0.01f,Q[3].y,Q[3].z);302 glTexCoord2f(0.0f, 0.0f); glVertex3f(Q[0].x+0.01f,Q[0].y,Q[0].z); 303 glTexCoord2f(1.0f, 0.0f); glVertex3f(Q[3].x+0.01f,Q[3].y,Q[3].z); 303 304 304 305 if( i == 1) … … 306 307 Q[1] = later + targ.cross(Vector(0,radzero,0)) ; 307 308 Q[2] = later + targ.cross(Vector(0,-radzero,0)) ; 308 glTexCoord2f(0.0f, 1.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[1].x+0.01f,Q[1].y,Q[1].z); 309 glTexCoord2f(1.0f, 1.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[2].x+0.01f,Q[2].y,Q[2].z); 309 310 glTexCoord2f(0.0f, 1.0f); glVertex3f(Q[1].x+0.01f,Q[1].y,Q[1].z); 311 glTexCoord2f(1.0f, 1.0f); glVertex3f(Q[2].x+0.01f,Q[2].y,Q[2].z); 310 312 } 311 313 … … 316 318 glPopMatrix(); 317 319 glPopAttrib(); 318 /* 319 //glTranslatef(this->getAbsCoor().x, this->getAbsCoor().y, this->getAbsCoor().z); 320 //glTranslatef(0,0,0); 321 322 const PNode* camera = State::getCameraNode(); //!< @todo MUST be different 323 Vector cameraPos = camera->getAbsCoor(); 324 Vector cameraTargetPos = State::getCameraTargetNode()->getAbsCoor(); 325 Vector view = cameraTargetPos - cameraPos; 326 Vector up = Vector(0, 1, 0); 327 up = camera->getAbsDir().apply(up); 328 Vector h = up.cross(view); 329 Vector v = h.cross(view); 330 h.normalize(); 331 v.normalize(); 332 333 v *= sizeX; 334 h *= sizeY; 335 336 //v += this->getAbsCoor(); 337 //PRINTF(0)("sizeX: %f sizeY: %f\n", sizeX, sizeY); 338 glBegin(GL_QUADS); 339 glTexCoord2f(0.0f, 0.0f); 340 glVertex3f(this->getAbsCoor().x - h.x - v.x, 341 this->getAbsCoor().y - h.y - v.y, 342 this->getAbsCoor().z - h.z - v.z); 343 glTexCoord2f(1.0f, 0.0f); 344 glVertex3f( this->getAbsCoor().x + h.x - v.x, 345 this->getAbsCoor().y + h.y - v.y, 346 this->getAbsCoor().z + h.z - v.z); 347 glTexCoord2f(1.0f, 1.0f); 348 glVertex3f(this->getAbsCoor().x + h.x + v.x, 349 this->getAbsCoor().y + h.y + v.y, 350 this->getAbsCoor().z + h.z + v.z); 351 glTexCoord2f(0.0f, 1.0f); 352 glVertex3f(this->getAbsCoor().x - h.x + v.x, 353 this->getAbsCoor().y - h.y + v.y, 354 this->getAbsCoor().z - h.z + v.z); 355 glEnd(); 356 357 358 glPopMatrix(); 359 360 glPopAttrib();*/ 361 } 320 }
Note: See TracChangeset
for help on using the changeset viewer.