Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6207 in orxonox.OLD for branches/christmas_branche


Ignore:
Timestamp:
Dec 21, 2005, 2:31:24 AM (19 years ago)
Author:
patrick
Message:

christmas: test_entity is now also loadable and heavily used in the christmas branche

Location:
branches/christmas_branche/src
Files:
4 edited

Legend:

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

    r6205 r6207  
    3333  #include "anormtab.h"
    3434};
    35 
    36 //! again one of these strange id software parts
    37 static float *shadeDots = MD2Model::anormsDots[0];
    38 
    39 
    40 static sVec3D verticesList[MD2_MAX_VERTICES];
    4135
    4236
     
    9084  this->scaleFactor = this->data->scaleFactor;
    9185
     86  shadeDots = MD2Model::anormsDots[0];
    9287  /* set the animation stat mannualy */
    9388  this->animationState.type = STAND;
     
    111106/**
    112107 *  initializes an array of vert with the current frame scaled vertices
    113  * @param verticesList: the list of vertices to interpolate between
     108 * @param this->verticesList: the list of vertices to interpolate between
    114109
    115110   we won't use the pVertices array directly, since its much easier and we need
    116111   saving of data anyway
    117112*/
    118 void MD2Model::interpolate(/*sVec3D* verticesList*/)
     113void MD2Model::interpolate(/*sVec3D* this->verticesList*/)
    119114{
    120115  sVec3D* currVec;
     
    126121  for( int i = 0; i < this->data->numVertices; ++i)
    127122    {
    128       verticesList[i][0] = currVec[i][0] + this->animationState.interpolationState * (nextVec[i][0] - currVec[i][0]);
    129       verticesList[i][1] = currVec[i][1] + this->animationState.interpolationState * (nextVec[i][1] - currVec[i][1]);
    130       verticesList[i][2] = currVec[i][2] + this->animationState.interpolationState * (nextVec[i][2] - currVec[i][2]);
     123      this->verticesList[i][0] = currVec[i][0] + this->animationState.interpolationState * (nextVec[i][0] - currVec[i][0]);
     124      this->verticesList[i][1] = currVec[i][1] + this->animationState.interpolationState * (nextVec[i][1] - currVec[i][1]);
     125      this->verticesList[i][2] = currVec[i][2] + this->animationState.interpolationState * (nextVec[i][2] - currVec[i][2]);
    131126    }
    132127}
     
    172167  this->animate(time);
    173168  this->processLighting();
    174   this->interpolate(/*verticesList*/);
     169  this->interpolate(/*this->verticesList*/);
    175170}
    176171
     
    185180  glPushMatrix();
    186181  this->renderFrame();
    187 //  renderFrameTriangles();
     182  // renderFrameTriangles();
    188183  glPopMatrix();
    189184}
     
    222217          glTexCoord2f( ((float *)pCommands)[0], ((float *)pCommands)[1] );
    223218          glNormal3fv(anorms[this->data->pLightNormals[pCommands[2]]]);
    224           glVertex3fv(verticesList[pCommands[2]]);
     219          glVertex3fv(this->verticesList[pCommands[2]]);
    225220        }
    226221      glEnd();
     
    234229void MD2Model::renderFrameTriangles() const
    235230{
    236   //static sVec3D verticesList[MD2_MAX_VERTICES]; /* performance: created only once in a lifetime */
     231  //static sVec3D this->verticesList[MD2_MAX_VERTICES]; /* performance: created only once in a lifetime */
    237232  int* pCommands = this->data->pGLCommands;
    238233  /* some face culling stuff */
     
    243238//
    244239//   this->processLighting();
    245 //   this->interpolate(/*verticesList*/);
     240//   this->interpolate(/*this->verticesList*/);
    246241  this->data->material->select();
    247242
  • branches/christmas_branche/src/lib/graphics/importer/md2Model.h

    r6199 r6207  
    241241  static float        anormsDots[SHADEDOT_QUANT][256];  //!< the anormals dot products
    242242  static sAnim        animationList[21];                //!< the anomation list
     243   //! again one of these strange id software parts
     244  float*              shadeDots;
    243245
    244246  MD2Data*            data;                             //!< the md2 data pointer
     
    247249  float               scaleFactor;                      //!< the scale factor (individual)
    248250  sAnimState          animationState;                   //!< animation state of the model
     251  sVec3D              verticesList[MD2_MAX_VERTICES];   //!< place to temp sav the vert
    249252};
    250253
  • branches/christmas_branche/src/world_entities/test_entity.cc

    r6187 r6207  
    1818
    1919
     20#include "executor/executor.h"
     21#include "factory.h"
     22
    2023#include "test_entity.h"
    2124#include "stdincl.h"
     
    2831
    2932
     33CREATE_FACTORY(TestEntity, CL_TEST_ENTITY);
     34
    3035
    3136TestEntity::TestEntity ()
    3237{
    33   this->setClassID(CL_TEST_ENTITY, "TestEntity");
    34   // TO SOME LIST!!
     38  this->init();
     39}
    3540
    36   this->md2Model = new MD2Model("models/droidika.md2", "models/droideka.pcx");
    37 //   this->md2Model = new MD2Model("models/tris.md2", "models/tris.pcx");
    38 // this->md2Model = new MD2Model("models/goblin.md2", "maps/goblin.bmp");
    3941
    40 /// FIXME
    41 //  this->obbTree = new OBBTree(4, (sVec3D*)this->md2Model->data->pVertices, this->md2Model->data->numVertices);
    4242
    43   this->md2Model->setAnim(RUN);
    44   this->md2Model->debug();
     43TestEntity::TestEntity(const TiXmlElement* root)
     44{
     45  this->init();
     46  if (root != NULL)
     47    this->loadParams(root);
     48
     49  this->init();
    4550}
    4651
    4752
    4853TestEntity::~TestEntity ()
     54{}
     55
     56
     57
     58void TestEntity::init()
    4959{
    50   delete this->md2Model;
     60  this->setClassID(CL_TEST_ENTITY, "TestEntity");
     61  this->toList(OM_COMMON);
     62}
     63
     64/**
     65 * loads the Settings of a MD2Creature from an XML-element.
     66 * @param root the XML-element to load the MD2Creature's properties from
     67 */
     68void TestEntity::loadParams(const TiXmlElement* root)
     69{
     70  static_cast<WorldEntity*>(this)->loadParams(root);
    5171}
    5272
    5373
    5474void  TestEntity::setAnim(int animationIndex)
    55 {
    56   this->md2Model->setAnim(animationIndex);
    57 }
     75{}
    5876
    5977
    6078void TestEntity::tick (float time)
    6179{
    62   this->md2Model->tick(time);
     80  if( likely(this->getModel(0) != NULL))
     81    ((MD2Model*)this->getModel(0))->tick(time);
     82
    6383}
    6484
    6585
    6686void TestEntity::collidesWith(WorldEntity* entity, const Vector& location)
    67 {
    68   if (entity->isA(CL_PROJECTILE))
    69   {
    70     PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getName(), entity->getName(), location.x, location.y, location.z);
    71   this->setVisibiliy(false);
    72   this->toList(OM_DEAD);
    73   }
    74 }
    75 
    76 void TestEntity::destroy () {}
    77 
     87{}
    7888
    7989
     
    8191void TestEntity::draw () const
    8292{
    83   glMatrixMode(GL_MODELVIEW);
    84   glPushMatrix();
    85   float matrix[4][4];
    86 
    87 
    88   glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z);
    89   this->getAbsDir().matrix (matrix);
    90   glMultMatrixf((float*)matrix);
    91   this->md2Model->draw();
    92 
    93 
    94   glPopMatrix();
     93  this->drawLODsafe();
    9594}
    9695
  • branches/christmas_branche/src/world_entities/test_entity.h

    r5500 r6207  
    1010struct t3DModel;
    1111class Material;
     12class TiXmlElement;
    1213
    1314class TestEntity : public WorldEntity, PhysicsInterface
     
    1718 public:
    1819  TestEntity ();
     20  TestEntity(const TiXmlElement* root);
    1921  virtual ~TestEntity ();
     22
     23  void init();
     24  void loadParams(const TiXmlElement* root);
    2025
    2126  void setAnim(int animationIndex);
    2227
    2328  virtual void tick (float time);
    24   virtual void destroy ();
    2529  virtual void collidesWith(WorldEntity* entity, const Vector& location);
    2630  virtual void draw () const;
Note: See TracChangeset for help on using the changeset viewer.