Changeset 4682 in orxonox.OLD for orxonox/trunk
- Timestamp:
- Jun 24, 2005, 12:50:34 AM (19 years ago)
- Location:
- orxonox/trunk/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/collision_detection/obb_tree.cc
r4671 r4682 31 31 OBBTree::OBBTree () 32 32 { 33 this->init(); 34 } 35 36 OBBTree::OBBTree(int depth, sVec3D *verticesList, const int length) 37 { 38 this->init(); 39 this->spawnBVTree(depth, verticesList, length); 40 } 41 42 43 44 void OBBTree::init() 45 { 33 46 this->setClassID(CL_OBB_TREE, "OBBTree"); 34 47 … … 61 74 this->id = 0; 62 75 } 63 64 76 65 77 /** -
orxonox/trunk/src/lib/collision_detection/obb_tree.h
r4670 r4682 20 20 public: 21 21 OBBTree(); 22 OBBTree(int depth, sVec3D *verticesList, const int length); 22 23 virtual ~OBBTree(); 24 void init(); 23 25 24 26 virtual void spawnBVTree(int depth, sVec3D *verticesList, const int length); -
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 -
orxonox/trunk/src/subprojects/collision_detection/collision_detection.cc
r4679 r4682 241 241 { 242 242 entity->draw(); 243 entity->drawBVTree(depth, drawMode); 243 244 entity = iterator->nextElement(); /* give back the next element or NULL if last */ 244 245 } -
orxonox/trunk/src/world_entities/environment.cc
r4679 r4682 22 22 #include "vector.h" 23 23 #include "objModel.h" 24 #include "obb_tree.h" 24 25 25 26 using namespace std; … … 33 34 this->setClassID(CL_ENVIRONMENT, "Environment"); 34 35 this->model = (Model*)ResourceManager::getInstance()->load("models/reaplow.obj", OBJ, RP_CAMPAIGN); 36 37 this->obbTree = new OBBTree(4, (sVec3D*)this->model->getVertexArray(), this->model->getVertexCount()); 35 38 } 36 39 -
orxonox/trunk/src/world_entities/test_entity.cc
r4679 r4682 21 21 #include "model.h" 22 22 #include "md2Model.h" 23 #include "obb_tree.h" 23 24 24 25 using namespace std; … … 31 32 32 33 this->md2Model = new MD2Model("models/tris.md2", "models/tris.pcx"); 34 this->obbTree = new OBBTree(4, (sVec3D*)this->md2Model->data->pVertices, this->md2Model->data->numVertices); 33 35 this->md2Model->debug(); 34 36 } … … 72 74 this->getAbsDir().matrix (matrix); 73 75 glMultMatrixf((float*)matrix); 74 glScalef(0.2, 0.2, 0.2);75 76 this->md2Model->draw(); 76 77 -
orxonox/trunk/src/world_entities/world_entity.cc
r4680 r4682 21 21 #include "list.h" 22 22 #include "vector.h" 23 #include "obb_tree.h" 23 24 24 25 using namespace std; … … 32 33 33 34 this->model = NULL; 35 this->obbTree = NULL; 34 36 35 37 if (root) -
orxonox/trunk/src/world_entities/world_entity.h
r4680 r4682 12 12 #include "factory.h" 13 13 #include "load_param.h" 14 #include "bv_tree.h" 14 15 #include "model.h" 15 16 16 //class CollisionCluster; 17 18 17 19 class CharacterAttributes; 18 20 class SoundEngine; 19 21 class SoundBuffer; 20 22 class SoundSource; 23 21 24 22 25 //! Basic class from which all interactive stuff in the world is derived from … … 52 55 void processDraw (); 53 56 virtual void draw (); 57 inline void drawBVTree(int depth, int drawMode) { this->obbTree->drawBV(depth, drawMode); } 54 58 virtual void tick (float time); 55 59 56 60 protected: 57 Model* model; //!< The model that should be loaded for this entity.61 Model* model; //!< The model that should be loaded for this entity. 58 62 CharacterAttributes* charAttr; //!< the character attributes of a world_entity 63 BVTree* obbTree; //!< this is the obb tree reference needed for collision detection 59 64 60 65 private:
Note: See TracChangeset
for help on using the changeset viewer.