Changeset 4168 in orxonox.OLD for orxonox/branches
- Timestamp:
- May 11, 2005, 5:17:21 PM (20 years ago)
- Location:
- orxonox/branches/md2_loader/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/md2_loader/src/lib/graphics/importer/Makefile.in
r4156 r4168 42 42 subdir = src/lib/graphics/importer 43 43 DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ 44 $(srcdir)/Makefile.in TODO44 $(srcdir)/Makefile.in 45 45 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 46 46 am__aclocal_m4_deps = $(top_srcdir)/configure.ac -
orxonox/branches/md2_loader/src/lib/graphics/importer/md2Model.cc
r4163 r4168 36 36 { 37 37 this->setClassName ("MD2Model"); 38 39 MD2Loader* md2loader = new MD2Loader(); 40 this->model = new t3DModel; 41 md2loader->importMD2(this->model, "../data/models/tris.md2"); 38 42 } 39 43 … … 49 53 50 54 51 void MD2Model::animate( t3DModel *pModel)52 { 53 if( unlikely( pModel->objectList.size() <= 0)) return;55 void MD2Model::animate() 56 { 57 if( unlikely(this->model->objectList.size() <= 0)) return; 54 58 /* get current animation from the list */ 55 tAnimationInfo *pAnim = &( pModel->animationList[pModel->currentAnim]);56 57 int nextFrame = ( pModel->currentFrame + 1) % pAnim->endFrame;59 tAnimationInfo *pAnim = &(this->model->animationList[this->model->currentAnim]); 60 61 int nextFrame = (this->model->currentFrame + 1) % pAnim->endFrame; 58 62 if( unlikely(nextFrame == 0)) 59 63 nextFrame = pAnim->startFrame; 60 64 61 t3DObject *pFrame = & pModel->objectList[pModel->currentFrame];62 t3DObject *pNextFrame = & pModel->objectList[nextFrame];65 t3DObject *pFrame = &this->model->objectList[this->model->currentFrame]; 66 t3DObject *pNextFrame = &this->model->objectList[nextFrame]; 63 67 64 68 /* we have stored the texture and face information only in the first frame */ 65 t3DObject *pFirstFrame = & pModel->objectList[0];69 t3DObject *pFirstFrame = &this->model->objectList[0]; 66 70 67 71 /* get the current time as a value in the domain [0..1] :)) */ 68 float t = this->getCurrentTime( pModel, nextFrame);72 float t = this->getCurrentTime(this->model, nextFrame); 69 73 70 74 glBegin(GL_TRIANGLES); … … 78 82 if( likely(pFirstFrame->pTexVerts != NULL)) 79 83 { 80 glTexCoord2f(pFirstFrame->pTexVerts[ texIndex].x,81 pFirstFrame->pTexVerts[ texIndex].y);84 glTexCoord2f(pFirstFrame->pTexVerts[texIndex].x, 85 pFirstFrame->pTexVerts[texIndex].y); 82 86 } 83 87 … … 106 110 } 107 111 printf("t = %f\n", this->localTime); 108 return (this->localTime /kAnimationSpeed);112 return (this->localTime / kAnimationSpeed); 109 113 } 110 114 … … 112 116 void MD2Model::tick(float dtS) 113 117 { 114 /* TEMP TEMP TEMP: save the current step length */115 this->dtS = dtS;116 118 this->localTime += dtS; 117 119 } … … 122 124 these function will take NO argument in the final version, just for testing 123 125 */ 124 void MD2Model::draw( t3DModel *pModel)125 { 126 if( pModel->objectList.size() <= 0) return;127 128 t3DObject *pObject = & pModel->objectList[0];126 void MD2Model::draw() 127 { 128 if( this->model->objectList.size() <= 0) return; 129 130 t3DObject *pObject = &this->model->objectList[0]; 129 131 glBegin(GL_TRIANGLES); 130 132 for(int j = 0; j < pObject->numOfFaces; j++) -
orxonox/branches/md2_loader/src/lib/graphics/importer/md2Model.h
r4163 r4168 119 119 void drawModel(float time); 120 120 void drawFrame(int frame); 121 122 void draw(t3DModel *pModel); 121 void draw(); 123 122 124 123 void setAnim(int type); … … 127 126 void tick(float dtS); 128 127 129 void animate(/*float time*/ t3DModel *pModel);128 void animate(/*float time*/); 130 129 private: 131 130 void processLightning(); … … 134 133 float getCurrentTime(t3DModel *pModel, int nextFrame); 135 134 136 float dtS;135 t3DModel* model; 137 136 float localTime; 138 137 }; … … 145 144 virtual ~MD2Loader(); 146 145 147 bool importMD2(t3DModel *pModel, char *fileName, char *texture );146 bool importMD2(t3DModel *pModel, char *fileName, char *texture = NULL); 148 147 149 148 private: -
orxonox/branches/md2_loader/src/world_entities/test_entity.cc
r4163 r4168 28 28 TestEntity::TestEntity () : WorldEntity() 29 29 { 30 MD2Loader* md2loader = new MD2Loader();31 this->model = new t3DModel;32 30 this->md2Model = new MD2Model(); 33 31 34 md2loader->importMD2(this->model, "../data/models/tris.md2", "../data/models/tris.pcx"); 35 36 this->material = new Material("Sky"); 32 this->material = new Material("Clown"); 37 33 this->material->setDiffuseMap("../data/models/tris.pcx"); 38 34 this->material->setIllum(3); … … 70 66 glMultMatrixf((float*)matrix); 71 67 72 //this->model->draw(); 68 73 69 /* TESTGING TESTING TESTING */ 74 70 this->material->select(); 75 71 //this->md2Model->draw(this->model); 76 this->md2Model->animate( this->model);72 this->md2Model->animate(); 77 73 78 74 glPopMatrix();
Note: See TracChangeset
for help on using the changeset viewer.