Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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/world_entities
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 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.