Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6184 in orxonox.OLD for branches


Ignore:
Timestamp:
Dec 20, 2005, 1:44:21 PM (19 years ago)
Author:
patrick
Message:

christmas: importer now supports also md2 models

Location:
branches/christmas_branche/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/christmas_branche/src/lib/graphics/importer/md2Model.cc

    r6181 r6184  
    9292  this->scaleFactor = this->data->scaleFactor;
    9393  this->setAnim(STAND);
     94
     95  this->debug();
    9496}
    9597
     
    119121  currVec = &this->data->pVertices[this->data->numVertices * this->animationState.currentFrame];
    120122  nextVec = &this->data->pVertices[this->data->numVertices * this->animationState.nextFrame];
     123  PRINTF(0)("current frame nr %i, next frame nr %i\n", this->animationState.currentFrame, this->animationState.nextFrame);
     124
    121125
    122126  for( int i = 0; i < this->data->numVertices; ++i)
     
    177181{
    178182  glPushMatrix();
    179 //   this->renderFrame();
     183  //this->renderFrame();
    180184  renderFrameTriangles();
    181185  glPopMatrix();
     
    231235void MD2Model::renderFrameTriangles() const
    232236{
    233   static sVec3D verticesList[MD2_MAX_VERTICES]; /* performance: created only once in a lifetime */
     237  //static sVec3D verticesList[MD2_MAX_VERTICES]; /* performance: created only once in a lifetime */
    234238  int* pCommands = this->data->pGLCommands;
    235239  /* some face culling stuff */
     
    248252  for( int i = 0, k = 0; i < this->data->numTriangles; ++i, k += 3)
    249253  {
    250     //printf("%i: (%f, %f)\n", i, (float)this->data->pTexCoor[this->data->pTriangles[i].indexToTexCoor[2]].s, (float)this->data->pTexCoor[this->data->pTriangles[i].indexToTexCoor[2]].t);
    251 
    252     glTexCoord2f((float)this->data->pTexCoor[this->data->pTriangles[i].indexToTexCoor[0]].s,
    253                   (float)this->data->pTexCoor[this->data->pTriangles[i].indexToTexCoor[0]].t);
    254  //glNormal3f(Md2Model.normal[i].x, Md2Model.normal[i].y, Md2Model.normal[i].z);
     254    float* v = this->data->pVertices[this->data->pTriangles[i].indexToVertices[0]];
     255
     256    printf("triangle: %i\n", i);
     257    printf("     v0: (%f, %f, %f)\n", v[0], v[1], v[2]);
     258    v = this->data->pVertices[this->data->pTriangles[i].indexToVertices[1]];
     259    printf("     v1: (%f, %f, %f)\n", v[0], v[1], v[2]);
     260    v = this->data->pVertices[this->data->pTriangles[i].indexToVertices[2]];
     261    printf("     v2: (%f, %f, %f)\n", v[0], v[1], v[2]);
     262
     263
     264    glNormal3f(anorms[i][0], anorms[i][1], anorms[i][2]);
    255265    glVertex3fv(this->data->pVertices[this->data->pTriangles[i].indexToVertices[0]]);
    256266
    257     glTexCoord2f((float)this->data->pTexCoor[this->data->pTriangles[i].indexToTexCoor[1]].s,
    258                   (float)this->data->pTexCoor[this->data->pTriangles[i].indexToTexCoor[1]].t);
    259 
    260  //    glNormal3f(Md2Model.normal[i].x, Md2Model.normal[i].y, Md2Model.normal[i].z);
     267    glNormal3f(anorms[i][0], anorms[i][1], anorms[i][2]);
    261268    glVertex3fv(this->data->pVertices[this->data->pTriangles[i].indexToVertices[1]]);
    262269
    263     glTexCoord2f((float)this->data->pTexCoor[this->data->pTriangles[i].indexToTexCoor[2]].s,
    264                   (float)this->data->pTexCoor[this->data->pTriangles[i].indexToTexCoor[2]].t);
    265  //    glNormal3f(Md2Model.normal[i].x, Md2Model.normal[i].y, Md2Model.normal[i].z);
     270    glNormal3f(anorms[i][0], anorms[i][1], anorms[i][2]);
    266271    glVertex3fv(this->data->pVertices[this->data->pTriangles[i].indexToVertices[2]]);
    267272  }
     
    269274  glEnd();
    270275}
    271 
    272 
    273 
    274 
    275 
    276 
    277 
    278 
    279 
    280276
    281277
     
    451447  for(int i = 0; i < this->numFrames; ++i)
    452448    {
     449      printf("==============vertex loading for frame %i/%i========\n", i, this->numFrames);
    453450      frame = (sFrame*)(buffer + this->header->frameSize * i);
    454451      pVertex = this->pVertices + this->numVertices  * i;
     
    462459          pVertex[j][2] = (-1.0 * (frame->pVertices[j].v[1] * frame->scale[1] + frame->translate[1])) * this->scaleFactor;
    463460
     461          printf("vertex %i/%i: (%f, %f, %f)\n", j, this->numVertices, pVertex[j][0], pVertex[j][1], pVertex[j][2]);
     462
    464463          pNormals[j] = frame->pVertices[j].lightNormalIndex;
    465464        }
  • branches/christmas_branche/src/subprojects/importer/Makefile.am

    r5865 r6184  
    2424                  $(MAINSRCDIR)/lib/math/vector.cc \
    2525                  $(MAINSRCDIR)/util/loading/resource_manager.cc \
    26                   $(MAINSRCDIR)/lib/util/ini_parser.cc \
     26                  $(MAINSRCDIR)/lib/parser/ini_parser/ini_parser.cc \
    2727                  $(MAINSRCDIR)/lib/coord/p_node.cc \
    28                   $(MAINSRCDIR)/lib/coord/null_parent.cc \
    2928                  $(MAINSRCDIR)/util/loading/load_param.cc \
    3029                  $(MAINSRCDIR)/util/loading/load_param_description.cc \
     
    5251                  $(MAINSRCDIR)/lib/math/vector.cc \
    5352                  $(MAINSRCDIR)/util/loading/resource_manager.cc \
    54                   $(MAINSRCDIR)/lib/util/ini_parser.cc \
     53                  $(MAINSRCDIR)/lib/parser/ini_parser/ini_parser.cc \
    5554                  $(MAINSRCDIR)/lib/coord/p_node.cc \
    56                   $(MAINSRCDIR)/lib/coord/null_parent.cc \
    5755                  $(MAINSRCDIR)/util/loading/load_param.cc \
    5856                  $(MAINSRCDIR)/util/loading/load_param_description.cc \
  • branches/christmas_branche/src/subprojects/importer/importer.cc

    r4741 r6184  
    2121
    2222#include "objModel.h"
     23#include "md2Model.h"
    2324#include "primitive_model.h"
    2425#include <stdlib.h>
     
    4041
    4142  if (argc>=3)
    42     obj = new OBJModel (argv[1], atof(argv[2]));
     43  {
     44    if( strstr(argv[1], ".obj") != NULL)
     45      obj = new OBJModel (argv[1], atof(argv[2]));
     46    else if( strstr(argv[1], ".md2") != NULL)
     47      obj = new MD2Model(argv[1], argv[2]);
     48  }
    4349  else if (argc>=2)
    44     obj = new OBJModel(argv[1]);
     50  {
     51    if( strstr(argv[1], ".obj") != NULL)
     52      obj = new OBJModel(argv[1]);
     53    else if( strstr(argv[1], ".md2") != NULL)
     54      obj = new MD2Model(argv[1], "fake_texture.bad");
     55  }
    4556  else
    4657    obj = new PrimitiveModel(PRIM_CYLINDER);
Note: See TracChangeset for help on using the changeset viewer.