Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10376 in orxonox.OLD for trunk/src/world_entities/npcs/npc_test.cc


Ignore:
Timestamp:
Jan 26, 2007, 12:17:26 AM (17 years ago)
Author:
patrick
Message:

merged branche ai to trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/npcs/npc_test.cc

    r10147 r10376  
    1919
    2020#include "npc_test.h"
    21 #include "obb_tree.h"
     21#include <stdio.h>
    2222
    23 #include "shader.h"
    2423#include "state.h"
    2524#include "debug.h"
     
    2827#include "loading/load_param.h"
    2928
    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"
    3136
    3237
     
    3439CREATE_FACTORY(NPC2);
    3540
     41
    3642NPC2::NPC2(const TiXmlElement* root)
    37   : NPC(NULL)
    3843{
    3944  this->registerObject(this, NPC2::_objectList);
    4045
    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);
    4548
    4649
     50  // create the weapons and their manager
    4751
    4852
    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");
    5258
    53   this->randomRotAxis = VECTOR_RAND(1);
     59  this->addWeapon(wpLeft, 1, 0);
     60  this->addWeapon(wpRight,1 ,1);
    5461
    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
    5791}
    5892
    59 
    60 NPC2::~NPC2 ()
    61 {}
    62 
     93NPC2::~NPC2()
     94{
     95}
    6396
    6497void NPC2::loadParams(const TiXmlElement* root)
     
    69102
    70103
    71 void NPC2::destroy(WorldEntity* killer)
     104
     105void NPC2::tick(float dt)
    72106{
    73   Explosion::explode(this, Vector(10,10,10));
    74   this->toList(OM_DEAD);
    75107
     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);
    76114}
    77115
    78116
    79117
    80 /**
    81  *  the entity is drawn onto the screen with this function
    82  *
    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() const
    87 // {
    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.