Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9927 in orxonox.OLD for trunk/src/world_entities


Ignore:
Timestamp:
Nov 14, 2006, 10:49:36 AM (18 years ago)
Author:
patrick
Message:

test entity for pps

Location:
trunk/src/world_entities
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/test_entity.cc

    r9869 r9927  
    1212
    1313   ### File Specific
    14    main-programmer: Patrick Boenzli
     14   main-programmer:
    1515   co-programmer:
    1616*/
     
    2222#include "util/loading/load_param.h"
    2323
    24 #include "kill.h"
    25 #include "game_rules.h"
    2624
    2725#include "test_entity.h"
    2826#include "debug.h"
    2927
    30 #include "interactive_model.h"
    31 #include "md2/md2Model.h"
     28
     29
    3230
    3331#include "state.h"
     
    3937CREATE_FACTORY(TestEntity);
    4038
    41 #include "script_class.h"
    42 CREATE_SCRIPTABLE_CLASS(TestEntity,
    43                         addMethod("setAbsCoor", Executor3<PNode, lua_State*,float,float,float>(&PNode::setAbsCoor))
    44                         ->addMethod("getAbsCoorX", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorX))
    45                         ->addMethod("getAbsCoorY", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorY))
    46                         ->addMethod("getAbsCoorZ", Executor0ret<PNode, lua_State*, float>(&PNode::getAbsCoorZ))
    47                        );
    4839
    4940
     41/**
     42 *
     43 */
    5044TestEntity::TestEntity ()
    5145{
    5246  this->init();
    53   this->md2Model = new MD2Model("models/droidika.md2", "models/droideka.pcx");
    5447}
    5548
    5649
    57 //   this->md2Model = new MD2Model("models/tris.md2", "models/tris.pcx");
    58 // this->md2Model = new MD2Model("models/goblin.md2", "maps/goblin.bmp");
    59 //   this->obbTree = new OBBTree(4, (sVec3D*)this->md2Model->data->pVertices, this->md2Model->data->numVertices);
    60 
    61 
     50/**
     51 *
     52 */
    6253TestEntity::TestEntity(const TiXmlElement* root)
    6354{
    6455  this->init();
    65   if (root != NULL)
     56
     57  if( root != NULL)
    6658    this->loadParams(root);
    6759}
    6860
    6961
     62/**
     63 *
     64 */
    7065TestEntity::~TestEntity ()
    7166{}
    7267
    7368
    74 
     69/**
     70 *
     71 */
    7572void TestEntity::init()
    7673{
    7774  this->registerObject(this, TestEntity::_objectList);
    7875  this->toList(OM_GROUP_00);
     76}
    7977
    80   this->lastCollided = NULL;
    81   this->bDeath = false;
    82 }
    8378
    8479/**
     
    9085  WorldEntity::loadParams(root);
    9186
    92   LoadParam(root, "md2animation", this, TestEntity, setAnim)
    93   .describe("sets the animation of the md2 model")
    94   .defaultValues(1);
     87  LoadParam(root, "size", this, TestEntity, setAnim)
     88  .describe("set the size")
     89  .defaultValues(1.0);
    9590
    9691}
    9792
    9893
    99 void  TestEntity::setAnim(int animationIndex, int animPlaybackMode)
    100 {
    101   if( likely(this->getModel(0) != NULL))
    102     ((InteractiveModel*)this->getModel(0))->setAnimation(animationIndex, animPlaybackMode);
    103 }
    10494
    105 
     95/**
     96 *
     97 */
    10698void TestEntity::tick (float time)
    10799{
    108   if( likely(this->getModel(0) != NULL))
    109     ((InteractiveModel*)this->getModel(0))->tick(time);
     100
    110101
    111102}
    112103
    113104
    114 void TestEntity::collidesWith(WorldEntity* entity, const Vector& location)
     105/**
     106 *
     107 */
     108void TestEntity::draw() const
    115109{
    116   if( this->lastCollided != entity)
    117   {
    118     this->destroy( entity );
    119     this->lastCollided = entity;
    120110
    121     if(State::getGameRules())
    122       State::getGameRules()->registerKill(Kill(entity, this));
    123   }
    124111}
    125112
    126113
    127114
    128 void TestEntity::destroy(WorldEntity* killer)
    129 {
    130   if( this->bDeath)
    131     return;
    132115
    133   this->bDeath = true;
    134   int randi = (int)(5.0f * (float)rand()/(float)RAND_MAX);
    135 
    136   PRINTF(0)("randi = %i\n", randi);
    137 
    138   if( randi == 1)
    139     this->setAnim(DEATH_FALLBACK, MD2_ANIM_ONCE);
    140   else if( randi == 2)
    141     this->setAnim(DEATH_FALLFORWARD, MD2_ANIM_ONCE);
    142   else if( randi == 3)
    143     this->setAnim(DEATH_FALLBACKSLOW, MD2_ANIM_ONCE);
    144   else if( randi == 4)
    145     this->setAnim(CROUCH_DEATH, MD2_ANIM_ONCE);
    146   else
    147     this->setAnim(DEATH_FALLBACK, MD2_ANIM_ONCE);
    148 }
    149 
  • trunk/src/world_entities/test_entity.h

    r9869 r9927  
    33
    44#include "world_entity.h"
    5 #include "physics_interface.h"
    65
    7 class MD2Loader;
    8 class MD2Model;
    9 class MD2Model2;
    10 struct t3DModel;
    11 class Material;
    126class TiXmlElement;
    13 class WorldEntity;
    147
    15 class TestEntity : public WorldEntity, public PhysicsInterface
     8
     9class TestEntity : public WorldEntity
    1610{
    17   ObjectListDeclaration(TestEntity);
    18  public:
    19   TestEntity ();
    20   TestEntity(const TiXmlElement* root);
    21   virtual ~TestEntity ();
     11    ObjectListDeclaration(TestEntity);
    2212
    23   void init();
    24   virtual void loadParams(const TiXmlElement* root);
     13  public:
     14    TestEntity ();
     15    TestEntity(const TiXmlElement* root);
     16    virtual ~TestEntity ();
    2517
    26   void setAnim(int animationIndex, int animPlaybackMode);
     18    void init();
     19    virtual void loadParams(const TiXmlElement* root);
    2720
    28   virtual void destroy(WorldEntity* killer);
    2921
    30   virtual void tick (float time);
    31   virtual void collidesWith(WorldEntity* entity, const Vector& location);
     22    virtual void tick (float time);
     23    virtual void draw() const;
    3224
    33  private:
    34   /* TESTING TESTING TESTING */
    35   t3DModel* model;
    36   MD2Model* md2Model;
    37   Material* material;
    38 
    39   WorldEntity* lastCollided;
    40 
    41   bool bDeath;
    4225};
    4326
Note: See TracChangeset for help on using the changeset viewer.