Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6222 in orxonox.OLD for trunk/src/world_entities/test_entity.cc


Ignore:
Timestamp:
Dec 21, 2005, 1:49:06 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the christmas branche to the trunk
merged with command:
svn merge -r6165:HEAD christmas_branche/ ../trunk/
no conflicts

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore set to
      Makefile.in
      Makefile
      configure
      *.kdevelop
      Doxyfile
      config.log
      config.h
      config.status
      stamp-h1
      autom4te.cache
      aclocal.m4
  • trunk/src

    • Property svn:ignore set to
      .deps
      orxonox
      Makefile
      Makefile.in

  • trunk/src/world_entities/test_entity.cc

    r6142 r6222  
    1818
    1919
     20#include "executor/executor.h"
     21#include "factory.h"
     22#include "load_param.h"
     23
    2024#include "test_entity.h"
    2125#include "stdincl.h"
     
    2428#include "obb_tree.h"
    2529#include "state.h"
    26 #include "list.h"
    2730
    2831using namespace std;
    2932
    3033
     34CREATE_FACTORY(TestEntity, CL_TEST_ENTITY);
     35
    3136
    3237TestEntity::TestEntity ()
    3338{
    34   this->setClassID(CL_TEST_ENTITY, "TestEntity");
    35   // TO SOME LIST!!
     39  this->init();
     40}
    3641
    37   this->md2Model = new MD2Model("models/droidika.md2", "models/droideka.pcx");
    38 //   this->md2Model = new MD2Model("models/tris.md2", "models/tris.pcx");
    39 // this->md2Model = new MD2Model("models/goblin.md2", "maps/goblin.bmp");
    4042
    41 /// FIXME
    42 //  this->obbTree = new OBBTree(4, (sVec3D*)this->md2Model->data->pVertices, this->md2Model->data->numVertices);
    4343
    44   this->md2Model->setAnim(RUN);
    45   this->md2Model->debug();
     44TestEntity::TestEntity(const TiXmlElement* root)
     45{
     46  this->init();
     47  if (root != NULL)
     48    this->loadParams(root);
     49
     50  this->init();
    4651}
    4752
    4853
    4954TestEntity::~TestEntity ()
     55{}
     56
     57
     58
     59void TestEntity::init()
    5060{
    51   delete this->md2Model;
     61  this->setClassID(CL_TEST_ENTITY, "TestEntity");
     62  this->toList(OM_COMMON);
     63}
     64
     65/**
     66 * loads the Settings of a MD2Creature from an XML-element.
     67 * @param root the XML-element to load the MD2Creature's properties from
     68 */
     69void TestEntity::loadParams(const TiXmlElement* root)
     70{
     71  static_cast<WorldEntity*>(this)->loadParams(root);
     72
     73  LoadParam(root, "md2animation", this, TestEntity, setAnim)
     74      .describe("sets the animation of the md2 model")
     75      .defaultValues(1, 1);
     76
    5277}
    5378
     
    5580void  TestEntity::setAnim(int animationIndex)
    5681{
    57   this->md2Model->setAnim(animationIndex);
     82  if( likely(this->getModel(0) != NULL))
     83    ((MD2Model*)this->getModel(0))->setAnim(animationIndex);
    5884}
    5985
     
    6187void TestEntity::tick (float time)
    6288{
    63   this->md2Model->tick(time);
     89  if( likely(this->getModel(0) != NULL))
     90    ((MD2Model*)this->getModel(0))->tick(time);
     91
    6492}
    6593
    6694
    6795void TestEntity::collidesWith(WorldEntity* entity, const Vector& location)
    68 {
    69   if (entity->isA(CL_PROJECTILE))
    70   {
    71     PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getName(), entity->getName(), location.x, location.y, location.z);
    72   this->setVisibiliy(false);
    73   this->toList(OM_DEAD);
    74   }
    75 }
    76 
    77 void TestEntity::destroy () {}
    78 
     96{}
    7997
    8098
     
    82100void TestEntity::draw () const
    83101{
    84   glMatrixMode(GL_MODELVIEW);
    85   glPushMatrix();
    86   float matrix[4][4];
    87 
    88 
    89   glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z);
    90   this->getAbsDir().matrix (matrix);
    91   glMultMatrixf((float*)matrix);
    92   this->md2Model->draw();
    93 
    94 
    95   glPopMatrix();
     102  this->drawLODsafe();
    96103}
    97104
Note: See TracChangeset for help on using the changeset viewer.