Changeset 9947 in orxonox.OLD for branches/ai/src/world_entities/npcs
- Timestamp:
- Nov 22, 2006, 5:36:10 PM (18 years ago)
- Location:
- branches/ai/src/world_entities/npcs
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ai/src/world_entities/npcs/npc_test.cc
r9869 r9947 19 19 20 20 #include "npc_test.h" 21 #include "obb_tree.h"22 21 23 #include "shader.h" 22 24 23 #include "state.h" 25 24 #include "debug.h" … … 28 27 #include "loading/load_param.h" 29 28 30 #include "effects/explosion.h" 29 #include "md2/md2Model.h" 30 #include "player.h" 31 #include "playable.h" 31 32 32 33 #include "class_id_DEPRECATED.h" 33 34 ObjectListDefinitionID(NPC2, CL_NPC_TEST2); 34 35 CREATE_FACTORY(NPC2); 36 35 37 36 38 NPC2::NPC2(const TiXmlElement* root) … … 39 41 this->registerObject(this, NPC2::_objectList); 40 42 41 if ((float)rand()/RAND_MAX > .5f)42 this->loadModel("models/ships/bolido.obj", 6);43 else44 this->loadModel("models/ships/gobblin.obj", 6);45 46 47 48 49 this->shader = NULL;50 // if (likely(Shader::checkShaderAbility()))51 //this->shader = Shader::getShader("shaders/toon.vert", "shaders/toon.frag");52 53 this->randomRotAxis = VECTOR_RAND(1);54 43 55 44 if (root != NULL) … … 69 58 70 59 71 void NPC2::destroy(WorldEntity* killer) 60 61 62 63 void NPC2::tick(float dt) 72 64 { 73 Explosion::explode(this, Vector(10,10,10)); 74 this->toList(OM_DEAD); 65 // animating the md2 model (uninteressant) 66 if( likely(this->getModel(0) != NULL)) 67 ((MD2Model*)this->getModel(0))->tick(dt); 68 69 70 71 PRINTF(0)("====================\n"); 72 PRINTF(0)("NPC2::tick(%f)\n", dt); 73 74 // information gathering 75 76 Vector absPosition = this->getAbsCoor(); 77 78 PRINTF(0)(" npc abs coor: %f, %f, %f\n", absPosition.x, absPosition.y, absPosition.z); 79 80 Player* pl = State::getPlayer(); 81 Vector playerAbsPos = pl->getPlayable()->getAbsCoor(); 82 83 PRINTF(0)(" player abs coor: %f, %f, %f\n", playerAbsPos.x, playerAbsPos.y, playerAbsPos.z); 84 85 86 // intelligent reaction 87 88 Vector distanceVector = playerAbsPos - absPosition; 89 distanceVector.normalize(); 90 91 float speed = 10.0f; 92 93 this->shiftCoor( distanceVector * speed * dt); 94 95 75 96 76 97 } … … 78 99 79 100 80 /**81 * the entity is drawn onto the screen with this function82 *83 * This is a central function of an entity: call it to let the entity painted to the screen.84 * Just override this function with whatever you want to be drawn.85 */86 void NPC2::draw() const87 {88 glMatrixMode(GL_MODELVIEW);89 glPushMatrix();90 float matrix[4][4];91 92 /* translate */93 glTranslatef (this->getAbsCoor ().x,94 this->getAbsCoor ().y,95 this->getAbsCoor ().z);96 /* rotate */97 this->getAbsDir ().matrix (matrix);98 glMultMatrixf((float*)matrix);99 100 // if (this->shader != NULL && this->shader != Shader::getActiveShader())101 // shader->activateShader();102 103 this->getModel()->draw();104 // shader->deactivateShader();105 106 107 /* if (this->model)108 this->model->draw();*/109 glPopMatrix();110 }111 112 113 void NPC2::tick(float dt)114 {115 // Vector direction = (State::getCameraTarget()->getAbsCoor() - this->getAbsCoor());116 117 //if (directin.len() < 100)118 // this->shiftCoor(direction *dt * 5 * exp(-direction.len() / 30.0));119 // this->shiftDir(Quaternion(dt, this->randomRotAxis));120 121 }122 123 124 -
branches/ai/src/world_entities/npcs/npc_test.h
r9869 r9947 17 17 virtual void loadParams(const TiXmlElement* root); 18 18 19 void addAI(AI* ai);20 21 virtual void destroy(WorldEntity* killer);22 19 23 20 virtual void tick(float dt); 24 virtual void draw() const;25 21 26 22 private: 27 Vector randomRotAxis; 28 Shader* shader; 23 29 24 }; 30 25
Note: See TracChangeset
for help on using the changeset viewer.