Changeset 10376 in orxonox.OLD for trunk/src/world_entities/npcs/npc_test.cc
- Timestamp:
- Jan 26, 2007, 12:17:26 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/npcs/npc_test.cc
r10147 r10376 19 19 20 20 #include "npc_test.h" 21 #include "obb_tree.h"21 #include <stdio.h> 22 22 23 #include "shader.h"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" 32 33 #include "weapons/test_gun.h" 34 #include "weapons/turret.h" 35 #include "weapons/cannon.h" 31 36 32 37 … … 34 39 CREATE_FACTORY(NPC2); 35 40 41 36 42 NPC2::NPC2(const TiXmlElement* root) 37 : NPC(NULL)38 43 { 39 44 this->registerObject(this, NPC2::_objectList); 40 45 41 // if ((float)rand()/RAND_MAX > .5f) 42 // this->loadModel("models/ships/bolido.obj", 6); 43 // else 44 // this->loadModel("models/ships/gobblin.obj", 6); 46 if (root != NULL) 47 this->loadParams(root); 45 48 46 49 50 // create the weapons and their manager 47 51 48 52 49 this->shader = NULL; 50 // if (likely(Shader::checkShaderAbility())) 51 //this->shader = Shader::getShader("shaders/toon.vert", "shaders/toon.frag"); 53 this->getWeaponManager().changeWeaponConfig(1); 54 Weapon* wpRight = new TestGun(0); 55 wpRight->setName("testGun Right"); 56 Weapon* wpLeft = new TestGun(1); 57 wpLeft->setName("testGun Left"); 52 58 53 this->randomRotAxis = VECTOR_RAND(1); 59 this->addWeapon(wpLeft, 1, 0); 60 this->addWeapon(wpRight,1 ,1); 54 61 55 if (root != NULL) 56 this->loadParams(root); 62 this->setHealthMax(100); 63 this->setHealth(80); 64 65 this->getWeaponManager().setSlotCount(7); 66 67 this->getWeaponManager().setSlotPosition(0, Vector(-2.6, .1, -3.0)); 68 this->getWeaponManager().setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 69 70 this->getWeaponManager().setSlotPosition(1, Vector(-2.6, .1, 3.0)); 71 this->getWeaponManager().setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 72 73 this->getWeaponManager().setSlotPosition(2, Vector(-1.5, .5, -.5)); 74 this->getWeaponManager().setSlotDirection(2, Quaternion(-M_PI_4*.5, Vector(1,0,0))); 75 76 this->getWeaponManager().setSlotPosition(3, Vector(-1.5, .5, .5)); 77 this->getWeaponManager().setSlotDirection(3, Quaternion(M_PI_4*.5, Vector(1,0,0))); 78 79 this->getWeaponManager().setSlotPosition(4, Vector(-1.5, -.5, .5)); 80 this->getWeaponManager().setSlotDirection(4, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0))); 81 82 this->getWeaponManager().setSlotPosition(5, Vector(-1.5, -.5, -.5)); 83 this->getWeaponManager().setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0))); 84 85 this->getWeaponManager().setSlotPosition(6, Vector(-1, 0.0, 0)); 86 this->getWeaponManager().setSlotCapability(6, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 87 88 this->getWeaponManager().getFixedTarget()->setParent(this); 89 this->getWeaponManager().getFixedTarget()->setRelCoor(100000,0,0); 90 57 91 } 58 92 59 60 NPC2::~NPC2 () 61 {} 62 93 NPC2::~NPC2() 94 { 95 } 63 96 64 97 void NPC2::loadParams(const TiXmlElement* root) … … 69 102 70 103 71 void NPC2::destroy(WorldEntity* killer) 104 105 void NPC2::tick(float dt) 72 106 { 73 Explosion::explode(this, Vector(10,10,10));74 this->toList(OM_DEAD);75 107 108 109 110 111 // animating the md2 model 112 if( likely(this->getModel(0) != NULL) && this->getModel(0)->isA(MD2Model::staticClassID())) 113 ((MD2Model*)this->getModel(0))->tick(dt); 76 114 } 77 115 78 116 79 117 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 // if( this->getModel())104 // this->getModel()->draw();105 // // shader->deactivateShader();106 //107 //108 // /* if (this->model)109 // this->model->draw();*/110 // glPopMatrix();111 // }112 113 114 void NPC2::tick(float dt)115 {116 // Vector direction = (State::getCameraTarget()->getAbsCoor() - this->getAbsCoor());117 118 //if (directin.len() < 100)119 // this->shiftCoor(direction *dt * 5 * exp(-direction.len() / 30.0));120 // this->shiftDir(Quaternion(dt, this->randomRotAxis));121 122 }123 124 125
Note: See TracChangeset
for help on using the changeset viewer.