Changeset 9927 in orxonox.OLD for trunk/src/world_entities
- Timestamp:
- Nov 14, 2006, 10:49:36 AM (18 years ago)
- Location:
- trunk/src/world_entities
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/test_entity.cc
r9869 r9927 12 12 13 13 ### File Specific 14 main-programmer: Patrick Boenzli14 main-programmer: 15 15 co-programmer: 16 16 */ … … 22 22 #include "util/loading/load_param.h" 23 23 24 #include "kill.h"25 #include "game_rules.h"26 24 27 25 #include "test_entity.h" 28 26 #include "debug.h" 29 27 30 #include "interactive_model.h" 31 #include "md2/md2Model.h" 28 29 32 30 33 31 #include "state.h" … … 39 37 CREATE_FACTORY(TestEntity); 40 38 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 );48 39 49 40 41 /** 42 * 43 */ 50 44 TestEntity::TestEntity () 51 45 { 52 46 this->init(); 53 this->md2Model = new MD2Model("models/droidika.md2", "models/droideka.pcx");54 47 } 55 48 56 49 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 */ 62 53 TestEntity::TestEntity(const TiXmlElement* root) 63 54 { 64 55 this->init(); 65 if (root != NULL) 56 57 if( root != NULL) 66 58 this->loadParams(root); 67 59 } 68 60 69 61 62 /** 63 * 64 */ 70 65 TestEntity::~TestEntity () 71 66 {} 72 67 73 68 74 69 /** 70 * 71 */ 75 72 void TestEntity::init() 76 73 { 77 74 this->registerObject(this, TestEntity::_objectList); 78 75 this->toList(OM_GROUP_00); 76 } 79 77 80 this->lastCollided = NULL;81 this->bDeath = false;82 }83 78 84 79 /** … … 90 85 WorldEntity::loadParams(root); 91 86 92 LoadParam(root, " md2animation", this, TestEntity, setAnim)93 .describe("set s 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); 95 90 96 91 } 97 92 98 93 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 }104 94 105 95 /** 96 * 97 */ 106 98 void TestEntity::tick (float time) 107 99 { 108 if( likely(this->getModel(0) != NULL)) 109 ((InteractiveModel*)this->getModel(0))->tick(time); 100 110 101 111 102 } 112 103 113 104 114 void TestEntity::collidesWith(WorldEntity* entity, const Vector& location) 105 /** 106 * 107 */ 108 void TestEntity::draw() const 115 109 { 116 if( this->lastCollided != entity)117 {118 this->destroy( entity );119 this->lastCollided = entity;120 110 121 if(State::getGameRules())122 State::getGameRules()->registerKill(Kill(entity, this));123 }124 111 } 125 112 126 113 127 114 128 void TestEntity::destroy(WorldEntity* killer)129 {130 if( this->bDeath)131 return;132 115 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 else147 this->setAnim(DEATH_FALLBACK, MD2_ANIM_ONCE);148 }149 -
trunk/src/world_entities/test_entity.h
r9869 r9927 3 3 4 4 #include "world_entity.h" 5 #include "physics_interface.h"6 5 7 class MD2Loader;8 class MD2Model;9 class MD2Model2;10 struct t3DModel;11 class Material;12 6 class TiXmlElement; 13 class WorldEntity;14 7 15 class TestEntity : public WorldEntity, public PhysicsInterface 8 9 class TestEntity : public WorldEntity 16 10 { 17 ObjectListDeclaration(TestEntity); 18 public: 19 TestEntity (); 20 TestEntity(const TiXmlElement* root); 21 virtual ~TestEntity (); 11 ObjectListDeclaration(TestEntity); 22 12 23 void init(); 24 virtual void loadParams(const TiXmlElement* root); 13 public: 14 TestEntity (); 15 TestEntity(const TiXmlElement* root); 16 virtual ~TestEntity (); 25 17 26 void setAnim(int animationIndex, int animPlaybackMode); 18 void init(); 19 virtual void loadParams(const TiXmlElement* root); 27 20 28 virtual void destroy(WorldEntity* killer);29 21 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; 32 24 33 private:34 /* TESTING TESTING TESTING */35 t3DModel* model;36 MD2Model* md2Model;37 Material* material;38 39 WorldEntity* lastCollided;40 41 bool bDeath;42 25 }; 43 26
Note: See TracChangeset
for help on using the changeset viewer.