Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 19, 2006, 10:03:19 PM (18 years ago)
Author:
marcscha
Message:

many additions, several fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/playability/src/world_entities/effects/trail.cc

    r10104 r10107  
    174174  //glMatrixMode(GL_MODELVIEW);
    175175  //glLoadIdentity();
    176 
    177   glEnable( GL_BLEND);
     176  /*
     177  glEnable(GL_BLEND);
    178178  glBlendFunc(GL_SRC_ALPHA,GL_ONE);
    179   glDisable( GL_ALPHA_TEST);
     179  glDisable( GL_ALPHA_TEST);*/
    180180
    181181  glTranslatef(-this->getAbsCoor().x,-this->getAbsCoor().y,-this->getAbsCoor().z);
     
    183183  this->material->select();
    184184
    185   float alphaStep = (trailAlphaMax - trailAlphaMin)/this->sections;
     185  //float alphaStep = 1.0 / this->sections;
    186186
    187187  glBegin(GL_TRIANGLE_STRIP);
     
    190190  for( int i = 1; i < this->sections-1; i++)
    191191  {
    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);
    194194
    195195    now   =  this->nodeList[i];
     
    204204    Q[3]  = now + Vector(0,-radone,0) ;
    205205   
    206     glTexCoord2f(0.0f, 0.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[0].x,Q[0].y,Q[0].z);
    207         glTexCoord2f(1.0f, 0.0f); glColor4f(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);
    208208
    209209    if( i == this->sections - 1)
     
    212212      Q[1]  = later + Vector(0,radzero,0) ;
    213213      Q[2]  = later + Vector(0,-radzero,0) ;
    214       glTexCoord2f(0.0f, 1.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[1].x,Q[1].y,Q[1].z);
    215       glTexCoord2f(1.0f, 1.0f); glColor4f(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);
    216216    }
    217217
     
    222222  for( int i = this->sections-1; i > 0; i--)
    223223  {
    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);
    226226
    227227    now   =  this->nodeList[i];
     
    236236    Q[3]  = now + Vector(0,-radone,0) ;
    237237
    238         glTexCoord2f(1.0f, 0.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[3].x,Q[3].y,Q[3].z+0.01f);
    239         glTexCoord2f(0.0f, 0.0f); glColor4f(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);
    240240
    241241    if( i == 1)
     
    243243        Q[1]  = later + Vector(0,radzero,0) ;
    244244        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);
    247248        }
    248249
     
    254255  for( int i = 1; i < this->sections-1; i++)
    255256  {
    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);
    258259
    259260    now   =  this->nodeList[i];
     
    268269    Q[3]  = now + targ.cross(Vector(0,-radone,0)) ;
    269270   
    270         glTexCoord2f(0.0f, 0.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[0].x,Q[0].y,Q[0].z);
    271         glTexCoord2f(1.0f, 0.0f); glColor4f(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);
    272273
    273274    if( i == this->sections-1)
     
    275276      Q[1]  = later + targ.cross(Vector(0,radzero,0)) ;
    276277      Q[2]  = later + targ.cross(Vector(0,-radzero,0)) ;
    277       glTexCoord2f(0.0f, 1.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[1].x,Q[1].y,Q[1].z);
    278       glTexCoord2f(1.0f, 1.0f); glColor4f(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);
    279280    }
    280281
     
    285286  for( int i = this->sections-1; i > 0; i--)
    286287  {
    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);
    289290
    290291    now   =  this->nodeList[i];
     
    299300    Q[3]  = now + targ.cross(Vector(0,-radone,0)) ;
    300301
    301         glTexCoord2f(0.0f, 0.0f); glColor4f(1,1,1, trailAlphaMax - i * alphaStep); glVertex3f(Q[0].x+0.01f,Q[0].y,Q[0].z);
    302         glTexCoord2f(1.0f, 0.0f); glColor4f(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);
    303304
    304305    if( i == 1)
     
    306307        Q[1]  = later + targ.cross(Vector(0,radzero,0)) ;
    307308        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);
    310312        }
    311313
     
    316318  glPopMatrix();
    317319  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.