Changeset 4682 in orxonox.OLD for orxonox/trunk/src/lib/graphics
- Timestamp:
- Jun 24, 2005, 12:50:34 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/graphics/importer/md2Model.cc
r4488 r4682 1 /* 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 … … 25 25 using namespace std; 26 26 27 //! the model anorms 27 //! the model anorms 28 28 sVec3D MD2Model::anorms[NUM_VERTEX_NORMALS] = { 29 29 #include "anorms.h" … … 38 38 static float *shadeDots = MD2Model::anormsDots[0]; 39 39 40 //! the angle under which the model is viewd, used internaly 40 //! the angle under which the model is viewd, used internaly 41 41 float md2Angle = 0.0f; 42 42 … … 45 45 sAnim MD2Model::animationList[21] = 46 46 { 47 // begin, end, fps 47 // begin, end, fps 48 48 { 0, 39, 9 }, //!< STAND 49 49 { 40, 45, 10 }, //!< RUN … … 115 115 for(int i = 0; i < this->data->numFrames; ++i) 116 116 { 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])); 120 120 } 121 121 } … … 138 138 this->animationState.fps = animationList[type].fps; 139 139 this->animationState.type = type; 140 140 141 141 this->animationState.interpolationState = 0.0; 142 142 this->animationState.localTime = 0.0; … … 169 169 170 170 glPopMatrix(); 171 } 171 } 172 172 173 173 … … 185 185 glEnable(GL_CULL_FACE); 186 186 glCullFace(GL_BACK); 187 187 188 188 this->processLighting(); 189 189 this->interpolate(verticesList); … … 194 194 { 195 195 if( i < 0) 196 197 198 199 196 { 197 glBegin(GL_TRIANGLE_FAN); 198 i = -i; 199 } 200 200 else 201 202 203 201 { 202 glBegin(GL_TRIANGLE_STRIP); 203 } 204 204 205 205 for(; i > 0; i--, pCommands += 3) /* down counting for loop, next 3 gl commands */ 206 207 208 209 210 206 { 207 glNormal3fv(anorms[this->data->pLightNormals[pCommands[2]]]); 208 glTexCoord2f( ((float *)pCommands)[0], ((float *)pCommands)[1] ); 209 glVertex3fv(verticesList[pCommands[2]]); 210 } 211 211 glEnd(); 212 212 } … … 227 227 this->animationState.currentFrame = this->animationState.nextFrame; 228 228 this->animationState.nextFrame++; 229 229 230 230 if( this->animationState.nextFrame > this->animationState.endFrame) 231 231 this->animationState.nextFrame = this->animationState.startFrame; 232 232 this->animationState.lastTime = this->animationState.localTime; 233 233 } … … 238 238 this->animationState.nextFrame = 0; 239 239 240 this->animationState.interpolationState = this->animationState.fps * 240 this->animationState.interpolationState = this->animationState.fps * 241 241 (this->animationState.localTime - this->animationState.lastTime); 242 242 } … … 282 282 this->pVertices = NULL; 283 283 this->pGLCommands = NULL; 284 this->pLightNormals = NULL; 284 this->pLightNormals = NULL; 285 285 286 286 this->numFrames = 0; 287 287 this->numVertices = 0; 288 288 this->numGLCommands = 0; 289 290 this->scaleFactor = 1.0f;289 290 this->scaleFactor = 0.2f; 291 291 292 292 this->loadModel(modelFileName); … … 328 328 329 329 pFile = fopen(fileName, "rb"); 330 if( unlikely(!pFile)) 330 if( unlikely(!pFile)) 331 331 { 332 332 PRINTF(1)("Couldn't open the MD2 File for loading. Exiting.\n"); … … 364 364 for(int i = 0; i < this->numFrames; ++i) 365 365 { 366 frame = (sFrame*)(buffer + this->header->frameSize * i); 366 frame = (sFrame*)(buffer + this->header->frameSize * i); 367 367 pVertex = this->pVertices + this->numVertices * i; 368 368 pNormals = this->pLightNormals + this->numVertices * i; 369 369 370 370 for(int j = 0; j < this->numVertices; ++j) 371 372 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 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 } 379 379 } 380 380
Note: See TracChangeset
for help on using the changeset viewer.