Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Jul 5, 2006, 4:39:02 PM (19 years ago)
Author:
bensch
Message:

merged the presentation back

File:
1 edited

Legend:

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

    r8724 r9235  
    2323#include "shader.h"
    2424#include "state.h"
    25 #include "stdlibincl.h"
    2625#include "debug.h"
    2726
     27#include "loading/factory.h"
     28#include "loading/load_param.h"
    2829
    29 using namespace std;
     30#include "effects/explosion.h"
     31
     32CREATE_FACTORY(NPC2, CL_NPC_TEST2);
    3033
    3134
    32 NPC2::NPC2()
     35NPC2::NPC2(const TiXmlElement* root)
    3336  : NPC(NULL)
    3437{
     
    3639
    3740  if ((float)rand()/RAND_MAX > .5f)
    38     this->loadModel("models/ships/bolido.obj", 3);
     41    this->loadModel("models/ships/bolido.obj", 6);
    3942  else
    40     this->loadModel("models/ships/gobblin.obj", 3);
     43    this->loadModel("models/ships/gobblin.obj", 6);
     44
     45
     46
    4147
    4248  this->shader = NULL;
     
    4450    this->shader = Shader::getShader("shaders/toon.vert", "shaders/toon.frag");
    4551
    46   this->obj = gluNewQuadric();
     52  this->randomRotAxis = VECTOR_RAND(1);
    4753
    48   this->randomRotAxis = VECTOR_RAND(1);
     54  if (root != NULL)
     55    this->loadParams(root);
    4956}
    5057
     
    5461  if (this->shader)
    5562    Shader::unload(this->shader);
    56   gluDeleteQuadric(this->obj);
     63}
     64
     65
     66void NPC2::loadParams(const TiXmlElement* root)
     67{
     68  NPC::loadParams(root);
     69
     70}
     71
     72
     73void NPC2::destroy(WorldEntity* killer)
     74{
     75  Explosion::explode(this, Vector(10,10,10));
     76  this->toList(OM_DEAD);
     77
    5778}
    5879
     
    6788void NPC2::draw() const
    6889{
    69 //   glMatrixMode(GL_MODELVIEW);
    70 //   glPushMatrix();
    71 //   float matrix[4][4];
    72 //
    73 //   /* translate */
    74 //   glTranslatef (this->getAbsCoor ().x,
    75 //                 this->getAbsCoor ().y,
    76 //                 this->getAbsCoor ().z);
    77 //   /* rotate */
    78 //   this->getAbsDir ().matrix (matrix);
    79 //   glMultMatrixf((float*)matrix);
    80 //
     90  glMatrixMode(GL_MODELVIEW);
     91  glPushMatrix();
     92  float matrix[4][4];
     93
     94  /* translate */
     95  glTranslatef (this->getAbsCoor ().x,
     96                this->getAbsCoor ().y,
     97                this->getAbsCoor ().z);
     98  /* rotate */
     99  this->getAbsDir ().matrix (matrix);
     100  glMultMatrixf((float*)matrix);
     101
    81102//   if (this->shader != NULL && this->shader != Shader::getActiveShader())
    82103//     shader->activateShader();
    83 //   gluSphere(this->obj, 3, 10, 10);
     104
     105  this->getModel()->draw();
    84106//   shader->deactivateShader();
    85 //
    86 //
    87 // /*  if (this->model)
    88 //     this->model->draw();*/
    89 //   glPopMatrix();
     107
     108
     109/*  if (this->model)
     110    this->model->draw();*/
     111  glPopMatrix();
    90112}
    91113
     
    97119  //if (directin.len() < 100)
    98120//  this->shiftCoor(direction *dt * 5 * exp(-direction.len() / 30.0));
    99   this->shiftDir(Quaternion(dt, this->randomRotAxis));
     121//  this->shiftDir(Quaternion(dt, this->randomRotAxis));
    100122
    101123}
Note: See TracChangeset for help on using the changeset viewer.