Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4682 in orxonox.OLD for orxonox/trunk/src/lib/graphics


Ignore:
Timestamp:
Jun 24, 2005, 12:50:34 AM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: now there is a possibility to render the bvtree through the world entities, the bvtree is a member of the worldentity

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/graphics/importer/md2Model.cc

    r4488 r4682  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    2525using namespace std;
    2626
    27 //! the model anorms 
     27//! the model anorms
    2828sVec3D MD2Model::anorms[NUM_VERTEX_NORMALS] = {
    2929 #include "anorms.h"
     
    3838static float *shadeDots = MD2Model::anormsDots[0];
    3939
    40 //! the angle under which the model is viewd, used internaly 
     40//! the angle under which the model is viewd, used internaly
    4141float md2Angle = 0.0f;
    4242
     
    4545sAnim MD2Model::animationList[21] =
    4646  {
    47  // begin, end, fps 
     47 // begin, end, fps
    4848    {   0,  39,  9 },   //!< STAND
    4949    {  40,  45, 10 },   //!< RUN
     
    115115  for(int i = 0; i < this->data->numFrames; ++i)
    116116    {
    117       verticesList[i][0] = (currVec[i][0] + this->animationState.interpolationState * (nextVec[i][0] - currVec[i][0])) * this->scaleFactor;
    118       verticesList[i][1] = (currVec[i][1] + this->animationState.interpolationState * (nextVec[i][1] - currVec[i][1])) * this->scaleFactor;
    119       verticesList[i][2] = (currVec[i][2] + this->animationState.interpolationState * (nextVec[i][2] - currVec[i][2])) * this->scaleFactor;
     117      verticesList[i][0] = (currVec[i][0] + this->animationState.interpolationState * (nextVec[i][0] - currVec[i][0]));
     118      verticesList[i][1] = (currVec[i][1] + this->animationState.interpolationState * (nextVec[i][1] - currVec[i][1]));
     119      verticesList[i][2] = (currVec[i][2] + this->animationState.interpolationState * (nextVec[i][2] - currVec[i][2]));
    120120    }
    121121}
     
    138138  this->animationState.fps = animationList[type].fps;
    139139  this->animationState.type = type;
    140  
     140
    141141  this->animationState.interpolationState = 0.0;
    142142  this->animationState.localTime = 0.0;
     
    169169
    170170  glPopMatrix();
    171 } 
     171}
    172172
    173173
     
    185185  glEnable(GL_CULL_FACE);
    186186  glCullFace(GL_BACK);
    187      
     187
    188188  this->processLighting();
    189189  this->interpolate(verticesList);
     
    194194    {
    195195      if( i < 0)
    196         {
    197           glBegin(GL_TRIANGLE_FAN);
    198           i = -i;
    199         }
     196        {
     197          glBegin(GL_TRIANGLE_FAN);
     198          i = -i;
     199        }
    200200      else
    201         {
    202           glBegin(GL_TRIANGLE_STRIP);
    203         }
     201        {
     202          glBegin(GL_TRIANGLE_STRIP);
     203        }
    204204
    205205      for(; i > 0; i--, pCommands += 3) /* down counting for loop, next 3 gl commands */
    206         {
    207           glNormal3fv(anorms[this->data->pLightNormals[pCommands[2]]]);
    208           glTexCoord2f( ((float *)pCommands)[0], ((float *)pCommands)[1] );
    209           glVertex3fv(verticesList[pCommands[2]]);
    210         }
     206        {
     207          glNormal3fv(anorms[this->data->pLightNormals[pCommands[2]]]);
     208          glTexCoord2f( ((float *)pCommands)[0], ((float *)pCommands)[1] );
     209          glVertex3fv(verticesList[pCommands[2]]);
     210        }
    211211      glEnd();
    212212    }
     
    227227      this->animationState.currentFrame = this->animationState.nextFrame;
    228228      this->animationState.nextFrame++;
    229      
     229
    230230      if( this->animationState.nextFrame > this->animationState.endFrame)
    231         this->animationState.nextFrame = this->animationState.startFrame;
     231        this->animationState.nextFrame = this->animationState.startFrame;
    232232      this->animationState.lastTime = this->animationState.localTime;
    233233    }
     
    238238    this->animationState.nextFrame = 0;
    239239
    240   this->animationState.interpolationState = this->animationState.fps * 
     240  this->animationState.interpolationState = this->animationState.fps *
    241241    (this->animationState.localTime - this->animationState.lastTime);
    242242}
     
    282282  this->pVertices = NULL;
    283283  this->pGLCommands = NULL;
    284   this->pLightNormals = NULL; 
     284  this->pLightNormals = NULL;
    285285
    286286  this->numFrames = 0;
    287287  this->numVertices = 0;
    288288  this->numGLCommands = 0;
    289  
    290   this->scaleFactor = 1.0f;
     289
     290  this->scaleFactor = 0.2f;
    291291
    292292  this->loadModel(modelFileName);
     
    328328
    329329  pFile = fopen(fileName, "rb");
    330   if( unlikely(!pFile)) 
     330  if( unlikely(!pFile))
    331331    {
    332332      PRINTF(1)("Couldn't open the MD2 File for loading. Exiting.\n");
     
    364364  for(int i = 0; i < this->numFrames; ++i)
    365365    {
    366       frame = (sFrame*)(buffer + this->header->frameSize * i); 
     366      frame = (sFrame*)(buffer + this->header->frameSize * i);
    367367      pVertex = this->pVertices + this->numVertices  * i;
    368368      pNormals = this->pLightNormals + this->numVertices * i;
    369369
    370370      for(int j = 0; j < this->numVertices; ++j)
    371         {
    372           /* SPEEDUP: *(pVerts + i + 0) = (*(frame->pVertices + i + 0)...  */
    373           pVertex[j][0] = (frame->pVertices[j].v[0] * frame->scale[0]) + frame->translate[0];
    374           pVertex[j][1] = (frame->pVertices[j].v[2] * frame->scale[2]) + frame->translate[2];
    375           pVertex[j][2] = -1.0 * (frame->pVertices[j].v[1] * frame->scale[1] + frame->translate[1]);
    376          
    377           pNormals[j] = frame->pVertices[j].lightNormalIndex;
    378         }
     371        {
     372          /* SPEEDUP: *(pVerts + i + 0) = (*(frame->pVertices + i + 0)...  */
     373          pVertex[j][0] = ((frame->pVertices[j].v[0] * frame->scale[0] ) + frame->translate[0] )* this->scaleFactor;
     374          pVertex[j][1] = ((frame->pVertices[j].v[2] * frame->scale[2]) + frame->translate[2]) * this->scaleFactor;
     375          pVertex[j][2] = (-1.0 * (frame->pVertices[j].v[1] * frame->scale[1] + frame->translate[1])) * this->scaleFactor;
     376
     377          pNormals[j] = frame->pVertices[j].lightNormalIndex;
     378        }
    379379    }
    380380
Note: See TracChangeset for help on using the changeset viewer.