Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6004 in orxonox.OLD for trunk


Ignore:
Timestamp:
Dec 9, 2005, 11:12:04 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: new algorithm to rotate entities for drawing works (shifcoor ONLY takes normalized Vectors…)

Location:
trunk/src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/defs/class_id.h

    r6002 r6004  
    162162  CL_GUIDED_MISSILE             =    0x00000245,
    163163
     164  CL_NPC_TEST1                  =    0x00000301,
     165  CL_NPC_TEST2                  =    0x00000302,
     166
     167
    164168  // gamePlay (range from 0x00000500 0x000005ff)
    165169  CL_EVENT                      =    0x00000501,
  • trunk/src/lib/coord/p_node.cc

    r5915 r6004  
    679679    }
    680680
    681     if(this->children.size() > 0)
     681    if(!this->children.empty())
    682682    {
    683683      list<PNode*>::iterator child;
  • trunk/src/lib/sound/sound_engine.cc

    r5996 r6004  
    290290  // INITIALIZING THE DEVICE:
    291291
    292 #ifdef AL_VERSION_1_1
     292#ifndef AL_VERSION_1_1
    293293  ALubyte deviceName[] =
    294294#else
  • trunk/src/world_entities/npcs/npc.cc

    r5750 r6004  
    7070  }
    7171}
    72 
    73 
    74 void NPC::tick(float dt)
    75 {
    76 
    77 }
    78 
    79 
    80 
  • trunk/src/world_entities/npcs/npc.h

    r5750 r6004  
    1717  void addAI(AI* ai);
    1818
    19   virtual void tick(float dt);
    20 
    2119  virtual void collidesWith (WorldEntity* entity, const Vector& location);
    2220
  • trunk/src/world_entities/npcs/npc_test.cc

    r5750 r6004  
    3333NPC2::NPC2()
    3434{
    35   this->setClassID(CL_NPC, "NPC");
     35  this->setClassID(CL_NPC_TEST2, "NPC2");
    3636
    3737  if ((float)rand()/RAND_MAX > .5f)
     
    8383void NPC2::draw() const
    8484{
    85   glMatrixMode(GL_MODELVIEW);
    86   glPushMatrix();
    87   float matrix[4][4];
    88 
    89   /* translate */
    90   glTranslatef (this->getAbsCoor ().x,
    91                 this->getAbsCoor ().y,
    92                 this->getAbsCoor ().z);
    93   /* rotate */
    94   this->getAbsDir ().matrix (matrix);
    95   glMultMatrixf((float*)matrix);
    96 
    97   if (this->shader != NULL && this->shader != Shader::getActiveShader())
    98     shader->activateShader();
    99   gluSphere(this->obj, 3, 10, 10);
    100   shader->deactivateShader();
    101 
    102 
    103 /*  if (this->model)
    104     this->model->draw();*/
    105   glPopMatrix();
     85//   glMatrixMode(GL_MODELVIEW);
     86//   glPushMatrix();
     87//   float matrix[4][4];
     88//
     89//   /* translate */
     90//   glTranslatef (this->getAbsCoor ().x,
     91//                 this->getAbsCoor ().y,
     92//                 this->getAbsCoor ().z);
     93//   /* rotate */
     94//   this->getAbsDir ().matrix (matrix);
     95//   glMultMatrixf((float*)matrix);
     96//
     97//   if (this->shader != NULL && this->shader != Shader::getActiveShader())
     98//     shader->activateShader();
     99//   gluSphere(this->obj, 3, 10, 10);
     100//   shader->deactivateShader();
     101//
     102//
     103// /*  if (this->model)
     104//     this->model->draw();*/
     105//   glPopMatrix();
    106106}
    107107
  • trunk/src/world_entities/npcs/npc_test.h

    r5750 r6004  
    33#define _NPC2_H
    44
    5 #include "world_entity.h"
    6 #include "physics_interface.h"
    7 
    8 #include "glincl.h"
     5#include "npc.h"
    96
    107class AI;
    118class Shader;
    129
    13 class NPC2 : public WorldEntity, public PhysicsInterface {
     10class NPC2 : public NPC {
    1411
    1512 public:
  • trunk/src/world_entities/npcs/npc_test1.cc

    r5750 r6004  
    3232NPCTest1::NPCTest1()
    3333{
    34   this->setClassID(CL_NPC, "NPCTest1");
     34  this->setClassID(CL_NPC_TEST1, "NPCTest1");
    3535
    3636  if ((float)rand()/RAND_MAX > .5f)
     
    3939    this->loadModel("models/ships/gobblin.obj", 2);
    4040
    41   this->randomRotAxis =  VECTOR_RAND(1);
     41  this->randomRotAxis =  VECTOR_RAND(1).getNormalized();
    4242}
    4343
     
    8080void NPCTest1::tick(float dt)
    8181{
    82 //  Vector direction = (State::getCameraTarget()->getAbsCoor() - this->getAbsCoor());
    83 
    84   //if (directin.len() < 100)
    85 //  this->shiftCoor(direction *dt * 5 * exp(-direction.len() / 30.0));
    8682  this->shiftDir(Quaternion(dt, this->randomRotAxis));
    87 
    8883}
    8984
  • trunk/src/world_entities/npcs/npc_test1.h

    r5750 r6004  
    33#define _NPC_Test1_H
    44
    5 #include "world_entity.h"
    6 #include "physics_interface.h"
     5#include "npc.h"
    76
    87class AI;
    98
    10 class NPCTest1 : public WorldEntity, public PhysicsInterface {
     9class NPCTest1 : public NPC {
    1110
    1211 public:
  • trunk/src/world_entities/world_entity.cc

    r6002 r6004  
    118118
    119119  if (this->models[modelNumber] != NULL)
    120   { 
     120  {
    121121    Resource* resource = ResourceManager::getInstance()->locateResourceByPointer(this->models[modelNumber]);
    122122    if (resource != NULL)
     
    127127  this->models[modelNumber] = model;
    128128
    129 //   if (this->model != NULL) 
     129//   if (this->model != NULL)
    130130//     this->buildObbTree(4);
    131131}
     
    233233    glMatrixMode(GL_MODELVIEW);
    234234    glPushMatrix();
    235     float matrix[4][4];
    236235
    237236    /* translate */
     
    239238                  this->getAbsCoor ().y,
    240239                  this->getAbsCoor ().z);
    241    /* rotate */ // FIXME: devise a new Way to rotate this
    242     this->getAbsDir ().matrix (matrix);
    243     glMultMatrixf((float*)matrix);
    244 
     240    Vector tmpRot = this->getAbsDir().getSpacialAxis();
     241    glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
     242
     243
     244    // This Draws the LOD's
    245245    float cameraDistance = (State::getCamera()->getAbsCoor() - this->getAbsCoor()).len();
    246     if (this->isA(CL_HELICOPTER))
    247         printf("Test %f %d\n", cameraDistance, this->models.size());
    248     if (cameraDistance > 100 && this->models.size() >= 3 && this->models[2] != NULL)
     246    if (cameraDistance > 30 && this->models.size() >= 3 && this->models[2] != NULL)
    249247    {
    250       if (this->isA(CL_HELICOPTER))printf("====== 2 ===\n");
    251248       this->models[2]->draw();
    252     } 
    253     else if (cameraDistance > 50 && this->models.size() >= 2 && this->models[1] != NULL)
     249    }
     250    else if (cameraDistance > 10 && this->models.size() >= 2 && this->models[1] != NULL)
    254251    {
    255       if (this->isA(CL_HELICOPTER))printf("====== 1 ===\n");
    256252      this->models[1]->draw();
    257     } 
    258     else if (this->models.size() >= 1 && this->models[0] != NULL) 
     253    }
     254    else if (this->models.size() >= 1 && this->models[0] != NULL)
    259255    {
    260       if (this->isA(CL_HELICOPTER))printf("====== 0 ===\n");
    261256      this->models[0]->draw();
    262257    }
Note: See TracChangeset for help on using the changeset viewer.