Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6222 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
Dec 21, 2005, 1:49:06 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the christmas branche to the trunk
merged with command:
svn merge -r6165:HEAD christmas_branche/ ../trunk/
no conflicts

Location:
trunk
Files:
81 edited
3 copied

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore set to
      Makefile.in
      Makefile
      configure
      *.kdevelop
      Doxyfile
      config.log
      config.h
      config.status
      stamp-h1
      autom4te.cache
      aclocal.m4
  • trunk/src

    • Property svn:ignore set to
      .deps
      orxonox
      Makefile
      Makefile.in

  • trunk/src/Makefile.am

    r6139 r6222  
    8686                  world_entities/space_ships/space_ship.cc \
    8787                  world_entities/space_ships/helicopter.cc \
     88                  world_entities/creatures/md2_creature.cc \
    8889                  world_entities/spawning_point.cc \
    8990                  subprojects/benchmark.cc
     
    133134                 world_entities/space_ships/space_ship.h \
    134135                 world_entities/space_ships/helicopter.h \
     136                 world_entities/creatures/md2_creature.h \
    135137                 world_entities/spawning_point.h \
    136138                 defs/stdincl.h \
  • trunk/src/defs/class_id.h

    r6162 r6222  
    149149  CL_SPACE_SHIP                 =    0x0000020a,
    150150  CL_HELICOPTER                 =    0x0000020b,
    151   CL_SPAWNING_POINT             =    0x0000020b,
     151  CL_SPAWNING_POINT             =    0x0000020c,
     152  CL_MD2_CREATURE               =    0x0000020d,
    152153
    153154  CL_TURRET_POWER_UP            =    0x00000211,
  • trunk/src/lib

    • Property svn:ignore set to
      Makefile
      Makefile.in
      .deps
      libORXlibs.a
  • trunk/src/lib/collision_detection

    • Property svn:ignore set to
      Makefile
      Makefile.in
      .deps
      libORX*

  • trunk/src/lib/collision_detection/cd_engine.cc

    r6151 r6222  
    1919#include "obb_tree.h"
    2020#include "debug.h"
    21 #include "list.h"
    2221
    2322#include "model.h"
  • trunk/src/lib/collision_detection/obb.cc

    r5120 r6222  
    1717
    1818#include "obb.h"
    19 #include "list.h"
    2019#include "vector.h"
    2120
  • trunk/src/lib/event

    • Property svn:ignore set to
      Makefile
      Makefile.in
      .deps
      libORX*
  • trunk/src/lib/graphics

    • Property svn:ignore set to
      Makefile
      Makefile.in
      .deps
      libORX*

  • trunk/src/lib/graphics/graphics_engine.cc

    r6162 r6222  
    3737#ifdef __WIN32__
    3838 #include "class_list.h"
    39  #include "list.h"
    4039 #include "static_model.h"
    4140#endif
     
    579578  std::list<WorldEntity*>::const_iterator entity;
    580579  for (entity = drawList.begin(); entity != drawList.end(); entity++)
    581     if ((*entity)->isVisible()) 
    582       (*entity)->draw(); 
     580    if ((*entity)->isVisible())
     581      (*entity)->draw();
    583582}
    584583
  • trunk/src/lib/graphics/importer

    • Property svn:ignore set to
      Makefile
      Makefile.in
      .deps
      libORX*

  • trunk/src/lib/graphics/importer/md2Model.cc

    r6022 r6222  
    2121#include "resource_manager.h"
    2222
    23 //#include <fstream>
    24 
    2523
    2624using namespace std;
     
    3634};
    3735
    38 //! again one of these strange id software parts
    39 static float *shadeDots = MD2Model::anormsDots[0];
    4036
    4137//! the angle under which the model is viewd, used internaly
     
    4642sAnim MD2Model::animationList[21] =
    4743  {
    48  // begin, end, fps
    49     {   0,  39,  9 },   //!< STAND
    50     {  40,  45, 10 },   //!< RUN
    51     {  46,  53, 10 },   //!< ATTACK
    52     {  54,  57,  7 },   //!< PAIN_A
    53     {  58,  61,  7 },   //!< PAIN_B
    54     {  62,  65,  7 },   //!< PAIN_C
    55     {  66,  71,  7 },   //!< JUMP
    56     {  72,  83,  7 },   //!< FLIP
    57     {  84,  94,  7 },   //!< SALUTE
    58     {  95, 111, 10 },   //!< FALLBACK
    59     { 112, 122,  7 },   //!< WAVE
    60     { 123, 134,  6 },   //!< POINTT
    61     { 135, 153, 10 },   //!< CROUCH_STAND
    62     { 154, 159,  7 },   //!< CROUCH_WALK
    63     { 160, 168, 10 },   //!< CROUCH_ATTACK
    64     { 196, 172,  7 },   //!< CROUCH_PAIN
    65     { 173, 177,  5 },   //!< CROUCH_DEATH
    66     { 178, 183,  7 },   //!< DEATH_FALLBACK
    67     { 184, 189,  7 },   //!< DEATH_FALLFORWARD
    68     { 190, 197,  7 },   //!< DEATH_FALLBACKSLOW
    69     { 198, 198,  5 },   //!< BOOM
     44 // begin, end, fps, interruptable
     45    {   0,  39,  9, 1 },   //!< STAND
     46    {  40,  45, 10, 1 },   //!< RUN
     47    {  46,  53, 10, 0 },   //!< ATTACK
     48    {  54,  57,  7, 1 },   //!< PAIN_A
     49    {  58,  61,  7, 1 },   //!< PAIN_B
     50    {  62,  65,  7, 1 },   //!< PAIN_C
     51    {  66,  71,  7, 0 },   //!< JUMP
     52    {  72,  83,  7, 1 },   //!< FLIP
     53    {  84,  94,  7, 1 },   //!< SALUTE
     54    {  95, 111, 10, 1 },   //!< FALLBACK
     55    { 112, 122,  7, 1 },   //!< WAVE
     56    { 123, 134,  6, 1 },   //!< POINTT
     57    { 135, 153, 10, 1 },   //!< CROUCH_STAND
     58    { 154, 159,  7, 1 },   //!< CROUCH_WALK
     59    { 160, 168, 10, 1 },   //!< CROUCH_ATTACK
     60    { 196, 172,  7, 1 },   //!< CROUCH_PAIN
     61    { 173, 177,  5, 0 },   //!< CROUCH_DEATH
     62    { 178, 183,  7, 0 },   //!< DEATH_FALLBACK
     63    { 184, 189,  7, 0 },   //!< DEATH_FALLFORWARD
     64    { 190, 197,  7, 0 },   //!< DEATH_FALLBACKSLOW
     65    { 198, 198,  5, 1 },   //!< BOOM
    7066  };
    7167
     
    8783
    8884  this->scaleFactor = this->data->scaleFactor;
     85
     86  shadeDots = MD2Model::anormsDots[0];
     87  /* set the animation stat mannualy */
     88  this->animationState.type = STAND;
     89  this->animationState.numPlays = 1;
    8990  this->setAnim(STAND);
     91
     92  this->debug();
    9093}
    9194
     
    103106/**
    104107 *  initializes an array of vert with the current frame scaled vertices
    105  * @param verticesList: the list of vertices to interpolate between
     108 * @param this->verticesList: the list of vertices to interpolate between
    106109
    107110   we won't use the pVertices array directly, since its much easier and we need
    108111   saving of data anyway
    109112*/
    110 void MD2Model::interpolate(sVec3D* verticesList)
     113void MD2Model::interpolate(/*sVec3D* this->verticesList*/)
    111114{
    112115  sVec3D* currVec;
     
    118121  for( int i = 0; i < this->data->numVertices; ++i)
    119122    {
    120       verticesList[i][0] = currVec[i][0] + this->animationState.interpolationState * (nextVec[i][0] - currVec[i][0]);
    121       verticesList[i][1] = currVec[i][1] + this->animationState.interpolationState * (nextVec[i][1] - currVec[i][1]);
    122       verticesList[i][2] = currVec[i][2] + this->animationState.interpolationState * (nextVec[i][2] - currVec[i][2]);
     123      this->verticesList[i][0] = currVec[i][0] + this->animationState.interpolationState * (nextVec[i][0] - currVec[i][0]);
     124      this->verticesList[i][1] = currVec[i][1] + this->animationState.interpolationState * (nextVec[i][1] - currVec[i][1]);
     125      this->verticesList[i][2] = currVec[i][2] + this->animationState.interpolationState * (nextVec[i][2] - currVec[i][2]);
    123126    }
    124127}
     
    135138  if( (type < 0) || (type > MAX_ANIMATIONS) )
    136139    type = STAND;
     140
     141  if( MD2Model::animationList[this->animationState.type].bStoppable == 0)
     142  {
     143    if( this->animationState.numPlays == 0 )
     144      return;
     145  }
    137146
    138147  this->animationState.startFrame = animationList[type].firstFrame;
     
    141150  this->animationState.fps = animationList[type].fps;
    142151  this->animationState.type = type;
     152  this->animationState.numPlays = 0;
    143153
    144154  this->animationState.interpolationState = 0.0f;
     
    155165void MD2Model::tick(float time)
    156166{
    157   this->animationState.localTime += time;
     167  this->animate(time);
     168  this->processLighting();
     169  this->interpolate(/*this->verticesList*/);
    158170}
    159171
     
    164176 * FIXME
    165177 */
    166 void MD2Model::draw()
    167 {
    168   if( likely(this->animationState.localTime > 0.0))
    169     this->animate();
    170 
     178void MD2Model::draw() const
     179{
    171180  glPushMatrix();
    172 
    173181  this->renderFrame();
    174 
     182  // renderFrameTriangles();
    175183  glPopMatrix();
    176184}
     
    180188  \brief this is an internal function to render this special frame selected by animate()
    181189*/
    182 void MD2Model::renderFrame()
    183 {
    184   static sVec3D verticesList[MD2_MAX_VERTICES]; /* performance: created only once in a lifetime */
     190void MD2Model::renderFrame() const
     191{
    185192  int* pCommands = this->data->pGLCommands;
    186193
     
    191198  glCullFace(GL_BACK);
    192199
    193   this->processLighting();
    194   this->interpolate(verticesList);
    195200  this->data->material->select();
    196201
     
    208213        }
    209214
    210 
    211215      for(; i > 0; i--, pCommands += 3) /* down counting for loop, next 3 gl commands */
    212216        {
    213217          glTexCoord2f( ((float *)pCommands)[0], ((float *)pCommands)[1] );
    214218          glNormal3fv(anorms[this->data->pLightNormals[pCommands[2]]]);
    215           glVertex3fv(verticesList[pCommands[2]]);
     219          glVertex3fv(this->verticesList[pCommands[2]]);
    216220        }
    217221      glEnd();
     
    223227
    224228
     229void MD2Model::renderFrameTriangles() const
     230{
     231  //static sVec3D this->verticesList[MD2_MAX_VERTICES]; /* performance: created only once in a lifetime */
     232  int* pCommands = this->data->pGLCommands;
     233  /* some face culling stuff */
     234//   glPushAttrib(GL_POLYGON_BIT);
     235//   glFrontFace(GL_CW);
     236//   glEnable(GL_CULL_FACE);
     237//   glCullFace(GL_BACK);
     238//
     239//   this->processLighting();
     240//   this->interpolate(/*this->verticesList*/);
     241  this->data->material->select();
     242
     243  /* draw the triangles */
     244  glBegin(GL_TRIANGLES);
     245
     246  for( int i = 0, k = 0; i < this->data->numTriangles; ++i, k += 3)
     247  {
     248    float* v = this->data->pVertices[this->data->pTriangles[i].indexToVertices[0]];
     249
     250    printf("triangle: %i\n", i);
     251    printf("     v0: (%f, %f, %f)\n", v[0], v[1], v[2]);
     252    v = this->data->pVertices[this->data->pTriangles[i].indexToVertices[1]];
     253    printf("     v1: (%f, %f, %f)\n", v[0], v[1], v[2]);
     254    v = this->data->pVertices[this->data->pTriangles[i].indexToVertices[2]];
     255    printf("     v2: (%f, %f, %f)\n", v[0], v[1], v[2]);
     256
     257
     258    glNormal3f(anorms[i][0], anorms[i][1], anorms[i][2]);
     259    glVertex3fv(this->data->pVertices[this->data->pTriangles[i].indexToVertices[0]]);
     260
     261    glNormal3f(anorms[i][0], anorms[i][1], anorms[i][2]);
     262    glVertex3fv(this->data->pVertices[this->data->pTriangles[i].indexToVertices[1]]);
     263
     264    glNormal3f(anorms[i][0], anorms[i][1], anorms[i][2]);
     265    glVertex3fv(this->data->pVertices[this->data->pTriangles[i].indexToVertices[2]]);
     266  }
     267
     268  glEnd();
     269}
     270
     271
    225272/**
    226273  \brief animates the current model
     
    228275  depending on the time passed (tick function), the player will select another model
    229276*/
    230 void MD2Model::animate()
    231 {
     277void MD2Model::animate(float time)
     278{
     279  this->animationState.localTime += time;
     280
    232281  if( this->animationState.localTime - this->animationState.lastTime > (1.0f / this->animationState.fps))
    233282    {
     
    236285
    237286      if( this->animationState.nextFrame > this->animationState.endFrame)
     287      {
    238288        this->animationState.nextFrame = this->animationState.startFrame;
     289        this->animationState.numPlays++;
     290      }
    239291      this->animationState.lastTime = this->animationState.localTime;
    240292    }
     
    297349  this->numTexCoor = 0;
    298350
    299   this->scaleFactor = 0.2f;
     351//   this->scaleFactor = 1.0f;
     352  this->scaleFactor = 0.1f;
    300353
    301354  this->fileName = NULL;
     
    399452        {
    400453          /* SPEEDUP: *(pVerts + i + 0) = (*(frame->pVertices + i + 0)...  */
    401           pVertex[j][0] = ((frame->pVertices[j].v[0] * frame->scale[0] ) + frame->translate[0] )* this->scaleFactor;
    402           pVertex[j][1] = ((frame->pVertices[j].v[2] * frame->scale[2]) + frame->translate[2]) * this->scaleFactor;
    403           pVertex[j][2] = (-1.0 * (frame->pVertices[j].v[1] * frame->scale[1] + frame->translate[1])) * this->scaleFactor;
     454           pVertex[j][0] = ((frame->pVertices[j].v[0] * frame->scale[0] ) + frame->translate[0] )* this->scaleFactor;
     455           pVertex[j][1] = ((frame->pVertices[j].v[2] * frame->scale[2]) + frame->translate[2]) * this->scaleFactor;
     456           pVertex[j][2] = (-1.0 * (frame->pVertices[j].v[1] * frame->scale[1] + frame->translate[1])) * this->scaleFactor;
     457
     458          //printf("vertex %i/%i: (%f, %f, %f)\n", j, this->numVertices, pVertex[j][0], pVertex[j][1], pVertex[j][2]);
    404459
    405460          pNormals[j] = frame->pVertices[j].lightNormalIndex;
    406461        }
    407462    }
     463    PRINTF(4)("Finished loading the md2 file\n");
    408464
    409465  delete [] buffer;
  • trunk/src/lib/graphics/importer/md2Model.h

    r6022 r6222  
    6565};
    6666
     67
     68//! compressed vertex data: char insetead of float, the value will be expanded by the scale value. only for loading
     69typedef struct
     70{
     71  unsigned char    v[3];                 //!< the vector of the vertex
     72  unsigned char    lightNormalIndex;     //!< the index of the light normal
     73} sVertex;
     74
     75
     76//! compressed texture offset data: coords scaled by the texture size. Only for loading
     77typedef struct
     78{
     79  short            s;                    //!< the s,t coordinates of a texture
     80  short            t;                    //!< the s,t coordinates of a texture
     81} sTexCoor;
     82
     83
     84//! holds tha informations about a md2 frame
     85typedef struct
     86{
     87  sVec3D           scale;                //!< scales values of the model
     88  sVec3D           translate;            //!< translates the model
     89  char             name[16];             //!< frame name: something like "run32"
     90  sVertex          pVertices[1];         //!< first vertex of thes frame
     91} sFrame;
     92
     93
     94//! holds the information about a triangle
     95typedef struct
     96{
     97  unsigned short   indexToVertices[3];   //!< index to the verteces of the triangle
     98  unsigned short   indexToTexCoor[3];    //!< index to the texture coordinates
     99} sTriangle;
     100
     101
     102
     103//! the command list of the md2 model, very md2 specific
     104typedef struct
     105{
     106  float            s;                    //!< texture coordinate 1
     107  float            t;                    //!< texture coordinate 2
     108  int              vertexIndex;          //!< index of the vertex in the vertex list
     109} glCommandVertex;
     110
     111
     112//! a md2 animation definition
     113typedef struct
     114{
     115  int              firstFrame;           //!< first frame of the animation
     116  int              lastFrame;            //!< last frame of the animation
     117  int              fps;                  //!< speed: number of frames per second
     118  int              bStoppable;           //!< 1 if the animation is stoppable 0 else
     119} sAnim;
     120
     121
     122//! animation state definition
     123typedef struct
     124{
     125  int              startFrame;           //!< the start frame of an animation
     126  int              endFrame;             //!< last frame of the animation
     127  int              fps;                  //!< fps of the animaion (speed)
     128
     129  float            localTime;            //!< the local time
     130  float            lastTime;             //!< last time stamp
     131  float            interpolationState;   //!< the state of the animation [0..1]
     132
     133  int              type;                 //!< animation type
     134
     135  int              currentFrame;         //!< the current frame
     136  int              nextFrame;            //!< the next frame in the list
     137  int              numPlays;             //!< the number of times, this has been played in series
     138} sAnimState;
    67139
    68140
     
    143215  virtual ~MD2Model();
    144216
    145   void draw();
     217  virtual void draw() const;
     218  void renderFrameTriangles() const;
     219
    146220
    147221  void setAnim(int type);
    148   /**
    149    *  scales the current model
    150    * @param scaleFactor: the factor [0..1] to use for scaling
    151   */
     222  /**  returns the current animation @returns animation type */
     223  inline int MD2Model::getAnim() { return this->animationState.type; }
     224  /**  scales the current model @param scaleFactor: the factor [0..1] to use for scaling */
    152225  void scaleModel(float scaleFactor) { this->scaleFactor = scaleFactor;}
    153226
    154   void tick(float dtS);
     227  virtual void tick(float dtS);
    155228  void debug();
    156229
    157230
    158231private:
    159   void animate();
     232  void animate(float time);
    160233  void processLighting();
    161   void interpolate(sVec3D* verticesList);
    162   void renderFrame();
     234  void interpolate(/*sVec3D* verticesList*/);
     235  void renderFrame() const ;
    163236
    164237
     
    168241  static float        anormsDots[SHADEDOT_QUANT][256];  //!< the anormals dot products
    169242  static sAnim        animationList[21];                //!< the anomation list
     243   //! again one of these strange id software parts
     244  float*              shadeDots;
    170245
    171246  MD2Data*            data;                             //!< the md2 data pointer
     
    174249  float               scaleFactor;                      //!< the scale factor (individual)
    175250  sAnimState          animationState;                   //!< animation state of the model
     251  sVec3D              verticesList[MD2_MAX_VERTICES];   //!< place to temp sav the vert
    176252};
    177253
  • trunk/src/lib/graphics/importer/model.h

    r6033 r6222  
    2929
    3030
    31 
    32 //! compressed vertex data: char insetead of float, the value will be expanded by the scale value. only for loading
    33 typedef struct
    34 {
    35   char             v[3];                 //!< the vector of the vertex
    36   unsigned char    lightNormalIndex;     //!< the index of the light normal
    37 } sVertex;
    38 
    39 
    40 //! compressed texture offset data: coords scaled by the texture size. Only for loading
    41 typedef struct
    42 {
    43   short            s;                    //!< the s,t coordinates of a texture
    44   short            t;                    //!< the s,t coordinates of a texture
    45 } sTexCoor;
    46 
    47 
    48 //! holds tha informations about a md2 frame
    49 typedef struct
    50 {
    51   sVec3D           scale;                //!< scales values of the model
    52   sVec3D           translate;            //!< translates the model
    53   char             name[16];             //!< frame name: something like "run32"
    54   sVertex          pVertices[1];         //!< first vertex of thes frame
    55 } sFrame;
    56 
    57 
    58 //! holds the information about a triangle
    59 typedef struct
    60 {
    61   unsigned short   indexToVertices[3];   //!< index to the verteces of the triangle
    62   unsigned short   indexToTexCoor[3];    //!< index to the texture coordinates
    63 } sTriangle;
    64 
    65 
    6631//! holds the information about a triangle
    6732typedef struct
     
    7237} sTriangleExt;
    7338
    74 
    75 //! the command list of the md2 model, very md2 specific
    76 typedef struct
    77 {
    78   float            s;                    //!< texture coordinate 1
    79   float            t;                    //!< texture coordinate 2
    80   int              vertexIndex;          //!< index of the vertex in the vertex list
    81 } glCommandVertex;
    82 
    83 
    84 //! a md2 animation definition
    85 typedef struct
    86 {
    87   int              firstFrame;           //!< first frame of the animation
    88   int              lastFrame;            //!< last frame of the animation
    89   int              fps;                  //!< speed: number of frames per second
    90 } sAnim;
    91 
    92 
    93 //! animation state definition
    94 typedef struct
    95 {
    96   int              startFrame;           //!< the start frame of an animation
    97   int              endFrame;             //!< last frame of the animation
    98   int              fps;                  //!< fps of the animaion (speed)
    99 
    100   float            localTime;            //!< the local time
    101   float            lastTime;             //!< last time stamp
    102   float            interpolationState;   //!< the state of the animation [0..1]
    103 
    104   int              type;                 //!< animation type
    105 
    106   int              currentFrame;         //!< the current frame
    107   int              nextFrame;            //!< the next frame in the list
    108 } sAnimState;
    10939
    11040//! Model Information definitions
     
    12252
    12353} modelInfo;
    124 
    12554
    12655
  • trunk/src/lib/graphics/render2D/render_2d.cc

    r5417 r6222  
    2020#include "graphics_engine.h"
    2121#include "class_list.h"
    22 #include "list.h"
    2322#include "element_2d.h"
    2423
  • trunk/src/lib/graphics/spatial_separation

    • Property svn:ignore set to
      Makefile
      Makefile.in
      .deps
      libORX*

  • trunk/src/lib/graphics/text_engine/text_engine.cc

    r5885 r6222  
    3737
    3838#include "debug.h"
    39 #include "list.h"
    4039
    4140///////////////////
  • trunk/src/lib/gui

    • Property svn:ignore set to
      Makefile
      Makefile.in
      .deps
      libORX*

  • trunk/src/lib/gui/gl_gui

    • Property svn:ignore set to
      Makefile
      Makefile.in
      .deps
      libORX*

  • trunk/src/lib/gui/gtk_gui

    • Property svn:ignore set to
      Makefile
      Makefile.in
      .deps
      libORX*

  • trunk/src/lib/network

    • Property svn:ignore set to
      Makefile
      Makefile.in
      .deps
      libORX*

  • trunk/src/lib/parser

    • Property svn:ignore set to
      Makefile
      Makefile.in
      .deps
      libORX*

  • trunk/src/lib/parser/ini_parser

    • Property svn:ignore set to
      Makefile
      Makefile.in
      .deps
      lib*
  • trunk/src/lib/parser/tinyxml

    • Property svn:ignore set to
      Makefile
      Makefile.in
      .deps
      libtinyxml*

  • trunk/src/lib/particles

    • Property svn:ignore set to
      Makefile
      Makefile.in
      .deps
      libORX*

  • trunk/src/lib/particles/particle_system.cc

    r5994 r6222  
    130130  LoadParam(root, "type", this, ParticleSystem, setType)
    131131      .describe("sets the type of the Particles, (dot, spark, sprite or model)");
     132
     133  LoadParam(root, "texture", this, ParticleSystem, setMaterialTexture);
    132134
    133135  LOAD_PARAM_START_CYCLE(root, element);
  • trunk/src/lib/physics

    • Property svn:ignore set to
      Makefile
      Makefile.in
      .deps
      libORX*
  • trunk/src/lib/shell

    • Property svn:ignore set to
      Makefile
      Makefile.in
      .deps
      libORX*

  • trunk/src/lib/shell/shell.cc

    r5787 r6222  
    2323
    2424#include "text.h"
    25 #include "list.h"
    2625#include "graphics_engine.h"
    2726#include "material.h"
  • trunk/src/lib/shell/shell_buffer.cc

    r5783 r6222  
    1818#include "shell_buffer.h"
    1919#include "debug.h"
    20 #include "list.h"
    2120#include "shell.h"
    2221
  • trunk/src/lib/shell/shell_command.cc

    r5885 r6222  
    1919#include "shell_command_class.h"
    2020
    21 #include "list.h"
     21#include "compiler.h"
    2222#include "debug.h"
    2323#include "class_list.h"
  • trunk/src/lib/shell/shell_input.cc

    r5787 r6222  
    2626
    2727#include "debug.h"
    28 #include "list.h"
    2928#include "compiler.h"
    3029#include "stdlibincl.h"
  • trunk/src/lib/sound

    • Property svn:ignore set to
      Makefile
      Makefile.in
      .deps
      libORX*

  • trunk/src/lib/sound/sound_engine.cc

    r6142 r6222  
    2424
    2525#include "p_node.h"
    26 #include "list.h"
    2726#include "resource_manager.h"
    2827#include "debug.h"
  • trunk/src/lib/util/executor/executor.cc

    r5659 r6222  
    1818#include "executor.h"
    1919
    20 #include "list.h"
    2120#include "debug.h"
    2221#include "class_list.h"
  • trunk/src/story_entities/debug_world.cc

    r6150 r6222  
    4848
    4949#include "glmenu_imagescreen.h"
    50 #include "list.h"
    5150#include "game_loader.h"
    5251
  • trunk/src/story_entities/network_world.cc

    r6142 r6222  
    4848
    4949#include "glmenu_imagescreen.h"
    50 #include "list.h"
    5150#include "game_loader.h"
    5251
  • trunk/src/story_entities/world.cc

    r6155 r6222  
    4646
    4747#include "glmenu_imagescreen.h"
    48 #include "list.h"
    4948#include "game_loader.h"
    5049
     
    348347//  tn->addChild(this->localCamera);
    349348  localCamera->setClipRegion(1, 10000.0);
    350   localCamera->lookAt(playable);
     349//  localCamera->lookAt(playable);
    351350//  this->localPlayer->setParentMode(PNODE_ALL);
    352351  if (sky != NULL)
     
    356355  }
    357356
     357  this->localCamera->getTarget()->getParent()->debugNode(0);
    358358  SoundEngine::getInstance()->setListener(this->localCamera);
    359359
  • trunk/src/subprojects

    • Property svn:ignore set to
      Makefile
      Makefile.in
      .deps

  • trunk/src/subprojects/collision_detection

    • Property svn:ignore set to
      Makefile
      Makefile.in
      .deps
      collision
  • trunk/src/subprojects/importer

    • Property svn:ignore set to
      Makefile
      Makefile.in
      .deps
      importer
      multitex

  • trunk/src/subprojects/importer/Makefile.am

    r5865 r6222  
    2424                  $(MAINSRCDIR)/lib/math/vector.cc \
    2525                  $(MAINSRCDIR)/util/loading/resource_manager.cc \
    26                   $(MAINSRCDIR)/lib/util/ini_parser.cc \
     26                  $(MAINSRCDIR)/lib/parser/ini_parser/ini_parser.cc \
    2727                  $(MAINSRCDIR)/lib/coord/p_node.cc \
    28                   $(MAINSRCDIR)/lib/coord/null_parent.cc \
    2928                  $(MAINSRCDIR)/util/loading/load_param.cc \
    3029                  $(MAINSRCDIR)/util/loading/load_param_description.cc \
     
    5251                  $(MAINSRCDIR)/lib/math/vector.cc \
    5352                  $(MAINSRCDIR)/util/loading/resource_manager.cc \
    54                   $(MAINSRCDIR)/lib/util/ini_parser.cc \
     53                  $(MAINSRCDIR)/lib/parser/ini_parser/ini_parser.cc \
    5554                  $(MAINSRCDIR)/lib/coord/p_node.cc \
    56                   $(MAINSRCDIR)/lib/coord/null_parent.cc \
    5755                  $(MAINSRCDIR)/util/loading/load_param.cc \
    5856                  $(MAINSRCDIR)/util/loading/load_param_description.cc \
  • trunk/src/subprojects/importer/importer.cc

    r4741 r6222  
    2121
    2222#include "objModel.h"
     23#include "md2Model.h"
    2324#include "primitive_model.h"
    2425#include <stdlib.h>
     
    4041
    4142  if (argc>=3)
    42     obj = new OBJModel (argv[1], atof(argv[2]));
     43  {
     44    if( strstr(argv[1], ".obj") != NULL)
     45      obj = new OBJModel (argv[1], atof(argv[2]));
     46    else if( strstr(argv[1], ".md2") != NULL)
     47    {
     48      obj = new MD2Model(argv[1], argv[2]);
     49      ((MD2Model*)obj)->tick(0.1f);
     50    }
     51  }
    4352  else if (argc>=2)
    44     obj = new OBJModel(argv[1]);
     53  {
     54    if( strstr(argv[1], ".obj") != NULL)
     55      obj = new OBJModel(argv[1]);
     56    else if( strstr(argv[1], ".md2") != NULL) {
     57      obj = new MD2Model(argv[1], "fake_texture.bad");
     58      obj = new MD2Model(argv[1], argv[2]);
     59      ((MD2Model*)obj)->tick(0.1f);
     60    }
     61  }
    4562  else
    4663    obj = new PrimitiveModel(PRIM_CYLINDER);
  • trunk/src/subprojects/network

    • Property svn:ignore set to
      Makefile
      Makefile.in
      .deps
      network
  • trunk/src/subprojects/particles

    • Property svn:ignore set to
      Makefile
      Makefile.in
      .deps
      particles
  • trunk/src/subprojects/testmain

    • Property svn:ignore set to
      Makefile
      Makefile.in
      .deps
      testmain
  • trunk/src/util

    • Property svn:ignore set to
      Makefile
      Makefile.in
      .deps
      libORX*

  • trunk/src/util/animation/animation.h

    r5777 r6222  
    77#define _ANIMATION_H
    88
    9 #include "list.h"
    109#include "base_object.h"
    11 #include "confincl.h"  // must be here to determin the DEBUG-level
    1210#include "debug.h"
    1311
     12#include "list.h"
    1413// FORWARD DECLARATION
    1514
  • trunk/src/util/loading/resource_manager.cc

    r5994 r6222  
    1919
    2020#include "debug.h"
     21
     22#include <algorithm>
    2123
    2224// different resource Types
     
    4042#endif /* NO_SHADERS */
    4143
    42 #include "list.h"
    43 #include "sdlincl.h"
    44 
    4544// File Handling Includes
    4645#include <sys/types.h>
     
    6160  strcpy(this->dataDir, "./");
    6261  this->tryDataDir("./data");
    63   this->imageDirs = new tList<char>;
    64   this->resourceList = new tList<Resource>;
    6562}
    6663
     
    7673  this->unloadAllByPriority(RP_GAME);
    7774
    78   if (this->resourceList->getSize() > 0)
    79     PRINTF(1)("Not removed all Resources, since there are still %d resources registered\n", this->resourceList->getSize());
    80 
    81   delete this->resourceList;
     75  if (!this->resourceList.empty())
     76    PRINTF(1)("Not removed all Resources, since there are still %d resources registered\n", this->resourceList.size());
     77
    8278  // deleting the Directorie Lists
    83   tIterator<char>* tmpIt = imageDirs->getIterator();
    84   char* tmpDir = tmpIt->firstElement();
    85   while(tmpDir)
    86     {
    87       delete[] tmpDir;
    88       tmpDir = tmpIt->nextElement();
    89     }
    90   delete tmpIt;
    91   delete this->imageDirs;
     79  while (!this->imageDirs.empty())
     80    {
     81      delete[] this->imageDirs.front();
     82      this->imageDirs.pop_front();
     83    }
    9284
    9385  delete[] this->dataDir;
     
    211203    {
    212204      // check if the Directory has been added before
    213       tIterator<char>* tmpImageDirs = imageDirs->getIterator();
    214       char* tmpDir = tmpImageDirs->firstElement();
    215       while(tmpDir)
    216         {
    217           if (!strcmp(tmpDir, newDir))
    218             {
    219               PRINTF(3)("Path %s already loaded\n", newDir);
    220               delete[] newDir;
    221               delete tmpImageDirs;
    222               return true;
    223             }
    224           tmpDir = tmpImageDirs->nextElement();
    225         }
    226       delete tmpImageDirs;
    227 
     205      std::list<char*>::const_iterator imageDir;
     206      for (imageDir = this->imageDirs.begin(); imageDir != this->imageDirs.end(); imageDir++)
     207      {
     208         if (!strcmp(*imageDir, newDir))
     209         {
     210           PRINTF(3)("Path %s already loaded\n", newDir);
     211           delete[] newDir;
     212           return true;
     213         }
     214      }
    228215      // adding the directory to the List
    229       this->imageDirs->add(newDir);
     216      this->imageDirs.push_back(newDir);
    230217      return true;
    231218    }
     
    389376              else
    390377                tmpResource->secFileName = NULL;
    391               tmpResource->pointer = new MD2Data(fullName, tmpResource->secFileName);
     378                tmpResource->pointer = new MD2Data(fullName, tmpResource->secFileName);
     379//               tmpResource->pointer = new MD2Model(fullName, tmpResource->secFileName);
     380
    392381            }
    393382              break;
     
    425414          else
    426415            {
    427               char* tmpDir;
    428               tIterator<char>* iterator = imageDirs->getIterator();
    429               tmpDir = iterator->firstElement();
    430               while(tmpDir)
     416              std::list<char*>::iterator imageDir;
     417              for (imageDir = this->imageDirs.begin(); imageDir != this->imageDirs.end(); imageDir++)
    431418                {
    432                   char* imgName = new char[strlen(tmpDir)+strlen(fileName)+1];
    433                   sprintf(imgName, "%s%s", tmpDir, fileName);
     419                  char* imgName = new char[strlen(*imageDir)+strlen(fileName)+1];
     420                  sprintf(imgName, "%s%s", *imageDir, fileName);
    434421                  if(isFile(imgName))
    435422                    {
     
    440427                    }
    441428                  delete[] imgName;
    442                   tmpDir = iterator->nextElement();
    443429                }
    444               delete iterator;
    445430            }
    446431          if(!tmpResource)
     
    477462        }
    478463      if (tmpResource->pointer != NULL)
    479         this->resourceList->add(tmpResource);
     464        this->resourceList.push_back(tmpResource);
    480465      delete[] fullName;
    481466    }
     
    572557          PRINTF(4)("Resource %s safely removed.\n", resource->name);
    573558          delete[] resource->name;
    574           this->resourceList->remove(resource);
     559          std::list<Resource*>::iterator resourceIT = std::find(this->resourceList.begin(), this->resourceList.end(), resource);
     560          this->resourceList.erase(resourceIT);
    575561          delete resource;
    576562        }
     
    590576bool ResourceManager::unloadAllByPriority(ResourcePriority prio)
    591577{
    592   tIterator<Resource>* iterator = resourceList->getIterator();
    593   Resource* enumRes = iterator->lastElement();
    594   while (enumRes)
    595     {
    596       if (enumRes->prio <= prio)
    597         if (enumRes->count == 0)
    598           unload(enumRes, prio);
    599         else
    600           PRINTF(2)("unable to unload %s because there are still %d references to it\n",
    601                    enumRes->name, enumRes->count);
    602       //enumRes = resourceList->nextElement();
    603       enumRes = iterator->prevElement();
    604     }
    605   delete iterator;
     578  std::list<Resource*>::iterator resource, pre;
     579  pre = --this->resourceList.end();
     580  unsigned int removeCount;
     581  for (unsigned int round = 0; round < 3; round++)
     582  {
     583    removeCount = 0;
     584    while (pre != resourceList.end())
     585    {
     586      resource = pre;
     587      pre--;
     588        if ((*resource)->prio <= prio)
     589        {
     590          if ((*resource)->count == 0)
     591            unload((*resource), prio);
     592          else
     593          {
     594            PRINTF(2)("unable to unload %s because there are still %d references to it\n",
     595                     (*resource)->name, (*resource)->count);
     596            removeCount++;
     597          }
     598        }
     599     }
     600     if (removeCount == 0) break;
     601  }
    606602}
    607603
     
    619615                                                void* param1, void* param2, void* param3) const
    620616{
    621   //  Resource* enumRes = resourceList->enumerate();
    622   tIterator<Resource>* iterator = resourceList->getIterator();
    623   Resource* enumRes = iterator->firstElement();
    624   while (enumRes)
    625     {
    626       if (enumRes->type == type && !strcmp(fileName, enumRes->name))
     617  std::list<Resource*>::const_iterator resource;
     618  for (resource = this->resourceList.begin(); resource != this->resourceList.end(); resource++)
     619  {
     620    if ((*resource)->type == type && !strcmp(fileName, (*resource)->name))
    627621        {
    628622          bool match = false;
     
    635629              if (!param1)
    636630                {
    637                   if (enumRes->modelSize == 1.0)
     631                  if ((*resource)->modelSize == 1.0)
    638632                    match = true;
    639633                }
    640               else if (enumRes->modelSize == *(float*)param1)
     634              else if ((*resource)->modelSize == *(float*)param1)
    641635                match = true;
    642636              break;
     
    644638              if (!param1)
    645639                {
    646                   if (enumRes->secFileName == NULL)
     640                  if ((*resource)->secFileName == NULL)
    647641                    match = true;
    648642                }
    649               else if (!strcmp(enumRes->secFileName, (const char*)param1))
     643              else if (!strcmp((*resource)->secFileName, (const char*)param1))
    650644                match = true;
    651645              break;
     
    655649              if (param1 == NULL)
    656650                {
    657                   if (enumRes->ttfSize == FONT_DEFAULT_RENDER_SIZE)
     651                  if ((*resource)->ttfSize == FONT_DEFAULT_RENDER_SIZE)
    658652                    match = true;
    659653                }
    660               else if (enumRes->ttfSize == *(unsigned int*)param1)
     654              else if ((*resource)->ttfSize == *(unsigned int*)param1)
    661655                match = true;
    662656              break;
     
    666660                if (!param1)
    667661                {
    668                   if (enumRes->secFileName == NULL)
     662                  if ((*resource)->secFileName == NULL)
    669663                    match = true;
    670664                }
    671                 else if (!strcmp(enumRes->secFileName, (const char*)param1))
     665                else if (!strcmp((*resource)->secFileName, (const char*)param1))
    672666                  match = true;
    673667#endif /* NO_SHADERS */
     
    678672          if (match)
    679673            {
    680               delete iterator;
    681               return enumRes;
     674              return (*resource);
    682675            }
    683676        }
    684       enumRes = iterator->nextElement();
    685     }
    686   delete iterator;
     677    }
    687678  return NULL;
    688679}
     
    696687{
    697688  //  Resource* enumRes = resourceList->enumerate();
    698   tIterator<Resource>* iterator = resourceList->getIterator();
    699   Resource* enumRes = iterator->firstElement();
    700   while (enumRes)
    701     {
    702       if (pointer == enumRes->pointer)
    703         {
    704           delete iterator;
    705           return enumRes;
    706         }
    707       enumRes = iterator->nextElement();
    708     }
    709   delete iterator;
     689  std::list<Resource*>::const_iterator resource;
     690  for (resource = this->resourceList.begin(); resource != this->resourceList.end(); resource++)
     691    if (pointer == (*resource)->pointer)
     692        return (*resource);
    710693  return NULL;
    711694}
     
    920903  PRINT(0)(" Data-Directory is: %s\n", this->dataDir);
    921904  PRINT(0)(" List of Image-Directories: ");
    922   tIterator<char>* tmpIt = imageDirs->getIterator();
    923   char* tmpDir = tmpIt->firstElement();
    924   while(tmpDir)
    925     {
    926       PRINT(0)("%s ",tmpDir);
    927       tmpDir = tmpIt->nextElement();
    928     }
    929   delete tmpIt;
     905  std::list<char*>::const_iterator imageDir;
     906  for (imageDir = this->imageDirs.begin(); imageDir != this->imageDirs.end(); imageDir++)
     907      PRINT(0)("%s ", (*imageDir));
    930908  PRINT(0)("\n");
    931909
    932910  PRINT(0)("List of all stored Resources:\n");
    933   tIterator<Resource>* iterator = resourceList->getIterator();
    934   Resource* enumRes = iterator->firstElement();
    935   while (enumRes)
     911  std::list<Resource*>::const_iterator resource;
     912  for (resource = this->resourceList.begin(); resource != this->resourceList.end(); resource++)
     913
    936914    {
    937915      PRINT(0)("-----------------------------------------\n");
    938       PRINT(0)("Name: %s; References: %d; Type: %s ", enumRes->name, enumRes->count, ResourceManager::ResourceTypeToChar(enumRes->type));
     916      PRINT(0)("Name: %s; References: %d; Type: %s ", (*resource)->name, (*resource)->count, ResourceManager::ResourceTypeToChar((*resource)->type));
    939917
    940918      PRINT(0)("gets deleted at ");
    941       switch(enumRes->prio)
     919      switch((*resource)->prio)
    942920        {
    943921        default:
     
    955933          break;
    956934        }
    957       enumRes = iterator->nextElement();
    958     }
    959   delete iterator;
     935    }
    960936
    961937
  • trunk/src/util/loading/resource_manager.h

    r5994 r6222  
    2121#include "base_object.h"
    2222
    23 #include "stdlibincl.h"
    2423
    25 // FORWARD DECLARATION
    26 template<class T> class tList;
     24#include <list>
    2725
    2826//! An eumerator for different fileTypes the resourceManager supports
     
    144142
    145143  char*                    dataDir;            //!< The Data Directory, where all relevant Data is stored.
    146   tList<Resource>*         resourceList;       //!< The List of Resources, that has already been loaded.
    147   tList<char>*             imageDirs;          //!< A list of directories in which images are stored.
     144  std::list<Resource*>     resourceList;       //!< The List of Resources, that has already been loaded.
     145  std::list<char*>         imageDirs;          //!< A list of directories in which images are stored.
    148146
    149147};
  • trunk/src/util/state.cc

    r6142 r6222  
    2626
    2727
    28 const PNode* State::camera = NULL;
    29 const PNode* State::cameraTarget = NULL;
     28PNode* State::camera = NULL;
     29PNode* State::cameraTarget = NULL;
    3030
    3131ObjectManager* State::objectManager = NULL;
     
    3434 *  sets camera and target of the current Camera
    3535*/
    36 void State::setCamera(const PNode* camera, const PNode* cameraTarget)
     36void State::setCamera(PNode* camera, PNode* cameraTarget)
    3737{
    3838  State::camera = camera;
  • trunk/src/util/state.h

    r6142 r6222  
    2525   //////////////
    2626  /** @param camera the PNode to the Camera, @param cameraTarget the PNode to the Camera's target */
    27   static void setCamera(const PNode* camera, const PNode* cameraTarget);
     27  static void setCamera(PNode* camera, PNode* cameraTarget);
    2828  /** @returns a Pointer to the PNode of the Camera */
    29   static inline const PNode* getCamera() { return State::camera; };
     29  static inline PNode* getCamera() { return State::camera; };
    3030  /** @returns a Pointer to the CameraTarget */
    31   static inline const PNode* getCameraTarget() { return State::cameraTarget; };
     31  static inline PNode* getCameraTarget() { return State::cameraTarget; };
    3232
    3333  //////////////////////
     
    4646  State();
    4747
    48   static const PNode*           camera;             //!< A reference to the camera
    49   static const PNode*           cameraTarget;       //!< A reference to the cameraTarget
     48  static PNode*                 camera;             //!< A reference to the camera
     49  static PNode*                 cameraTarget;       //!< A reference to the cameraTarget
    5050  static PNode*                 nullParent;         //!< A reference to the Null-PNode.
    5151  static ObjectManager*         objectManager;      //!< A referenct to the current ObjectManager
  • trunk/src/world_entities/Makefile.am

    r6139 r6222  
    88                  camera.cc \
    99                  playable.cc \
    10                               player.cc \
     10                  player.cc \
    1111                  npc.cc \
    1212                  npc2.cc \
     
    1818                  character_attributes.cc \
    1919                  test_entity.cc \
    20                               space_ships/space_ship.cc \
     20                  space_ships/space_ship.cc \
     21                  creatures/md2_creature.cc \
    2122                  weapons/weapon_manager.cc \
    2223                  weapons/weapon.cc \
     
    2728                  weapons/rocket.cc \
    2829                  weapons/laser.cc \
    29                               weapons/ground_turret.cc \
     30                  weapons/ground_turret.cc \
    3031                  weapons/crosshair.cc \
    31                               weapons/ground_turret.cc \
     32                  weapons/ground_turret.cc \
    3233                  power_ups/power_up.cc \
    3334                  power_ups/turret_power_up.cc \
     
    3839                 camera.h \
    3940                 playable.h \
    40                              player.h \
     41                 player.h \
    4142                 npc.h \
    4243                 npc2.h \
     
    4950                 test_entity.h \
    5051                 space_ships/space_ship.h \
     52                 creatures/md2_creature.cc \
    5153                 weapons/weapon_manager.h \
    5254                 weapons/weapon.h \
  • trunk/src/world_entities/camera.cc

    r6034 r6222  
    119119    case VIEW_NORMAL:
    120120      this->toFovy = 60.0;
    121       this->setParentSoft("TrackNode");
    122       this->target->setParentSoft("TrackNode");
     121/*      this->setParentSoft("TrackNode");
     122      this->target->setParentSoft("TrackNode"); */
    123123      this->setRelCoorSoft(-10, 5, 0);
    124124      this->target->setRelCoorSoft(0,0,0);
     
    129129  //    this->target->setRelCoorSoft(Vector(10,0,0));
    130130
    131       if (!strcmp(this->target->getParent()->getName(), "Player"))
    132         this->target->setParentSoft("TrackNode");
    133       else
    134         this->target->setParentSoft("Player");
    135       this->getParent()->debugNode(0);
     131//       if (!strcmp(this->target->getParent()->getName(), "Player"))
     132//         this->target->setParentSoft("TrackNode");
     133//       else
     134//         this->target->setParentSoft("Player");
     135//       this->getParent()->debugNode(0);
    136136
    137137//      this->setParent("main-Turret");
     
    142142    case VIEW_FRONT:
    143143      this->toFovy = 120.0;
    144        this->setParentSoft("Player");
    145        this->target->setParentSoft("Player");
     144/*       this->setParentSoft("Player");
     145       this->target->setParentSoft("Player");*/
    146146       this->setRelCoorSoft(4, 0, 0, 5);
    147147       this->target->setRelCoorSoft(Vector(10,0,0), 5);
     
    150150    case VIEW_LEFT:
    151151      this->toFovy = 90;
    152       this->setParentSoft("TrackNode");
    153       this->target->setParentSoft("TrackNode");
     152/*      this->setParentSoft("TrackNode");
     153      this->target->setParentSoft("TrackNode");*/
    154154      this->setRelCoorSoft(0, 1, -10, .5);
    155155      this->target->setRelCoorSoft(0,0,0);
     
    157157    case VIEW_RIGHT:
    158158      this->toFovy = 90;
    159       this->setParentSoft("TrackNode");
    160       this->target->setParentSoft("TrackNode");
     159/*      this->setParentSoft("TrackNode");
     160      this->target->setParentSoft("TrackNode");*/
    161161      this->setRelCoorSoft(Vector(0, 1, 10));
    162162      this->target->setRelCoorSoft(0,0,0);
     
    164164    case VIEW_TOP:
    165165      this->toFovy= 120;
    166       this->setParentSoft("TrackNode");
    167       this->target->setParentSoft("TrackNode");
     166/*      this->setParentSoft("TrackNode");
     167      this->target->setParentSoft("TrackNode");*/
    168168      this->setRelCoorSoft(Vector(30, 50, 0));
    169169      this->target->setRelCoorSoft(35,0,0);
  • trunk/src/world_entities/npcs/npc.cc

    r6142 r6222  
    2222
    2323#include "state.h"
    24 #include "list.h"
    2524#include "stdlibincl.h"
    2625#include "power_ups/turret_power_up.h"
  • trunk/src/world_entities/npcs/npc_test.cc

    r6054 r6222  
    2323#include "shader.h"
    2424#include "state.h"
    25 #include "list.h"
    2625#include "stdlibincl.h"
    2726#include "debug.h"
  • trunk/src/world_entities/npcs/npc_test1.cc

    r6054 r6222  
    2222
    2323#include "state.h"
    24 #include "list.h"
    25 #include "stdlibincl.h"
    2624#include "power_ups/turret_power_up.h"
    2725#include "power_ups/laser_power_up.h"
  • trunk/src/world_entities/playable.h

    r6162 r6222  
    2525    virtual ~Playable();
    2626
     27    virtual void enter() {};
     28    virtual void leave() {};
    2729
    2830    virtual void addWeapon(Weapon* weapon )  {}//= 0;
     
    3436
    3537    virtual void process(const Event &event) = 0;
    36    
     38
    3739
    3840
  • trunk/src/world_entities/player.cc

    r5915 r6222  
    1919#include "event_handler.h"
    2020
     21
     22#include "class_list.h"
     23#include "state.h"
     24
    2125using namespace std;
    2226
     
    2832{
    2933  this->init();
     34
     35  EventHandler::getInstance()->subscribe(this, ES_GAME, SDLK_l);
    3036}
    3137
     
    7985 void Player::process(const Event &event)
    8086 {
     87   if (event.type == SDLK_l && event.bPressed)
     88   {
     89     /// FIXME this should be in the ObjectManager
     90     const std::list<BaseObject*>* objectList = ClassList::getList(CL_PLAYABLE);
     91     if (objectList != NULL)
     92     {
     93       list<BaseObject*>::const_iterator node;
     94       for (node = objectList->begin(); node != objectList->end(); node++)
     95         if (this->controllable != (*node) && (dynamic_cast<PNode*>(*node)->getAbsCoor() - this->controllable->getAbsCoor()).len() < 10.0)
     96       {
     97         this->controllable->leave();
     98         this->disconnectControllable();
     99         this->setControllable(dynamic_cast<Playable*>(*node));
     100         this->controllable->enter();
     101         State::getCamera()->setParentSoft(this->controllable);
     102         State::getCameraTarget()->setParentSoft(this->controllable);
     103
     104         break;
     105       }
     106     }
     107   }
     108
    81109   if (likely(this->controllable != NULL))
    82110     this->controllable->process(event);
  • trunk/src/world_entities/power_ups/laser_power_up.cc

    r6142 r6222  
    1919#include "factory.h"
    2020#include "state.h"
    21 #include "list.h"
    2221
    2322#include "primitive_model.h"
  • trunk/src/world_entities/power_ups/param_power_up.cc

    r6113 r6222  
    1919#include "factory.h"
    2020#include "state.h"
    21 #include "list.h"
    2221
    2322#include "primitive_model.h"
  • trunk/src/world_entities/power_ups/turret_power_up.cc

    r6142 r6222  
    1919#include "factory.h"
    2020#include "state.h"
    21 #include "list.h"
    2221
    2322#include "primitive_model.h"
  • trunk/src/world_entities/power_ups/weapon_power_up.cc

    r6113 r6222  
    1919#include "factory.h"
    2020#include "state.h"
    21 #include "list.h"
    2221
    2322#include "primitive_model.h"
  • trunk/src/world_entities/satellite.cc

    r5994 r6222  
    2121
    2222#include "objModel.h"
    23 #include "list.h"
    2423#include "vector.h"
    2524
  • trunk/src/world_entities/space_ships/helicopter.cc

    r6162 r6222  
    9595
    9696  this->getWeaponManager()->changeWeaponConfig(1);
     97  dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( false);
    9798}
    9899
     
    184185
    185186
     187
     188
     189void Helicopter::enter()
     190{
     191  dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( true);
     192
     193
     194}
     195
     196void Helicopter::leave()
     197{
     198  dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( false);
     199
     200
     201}
     202
     203
    186204/**
    187205 * adds a weapon to the weapon list of the spaceship
     
    324342         if(this->getAbsDirZ().y > 0.02) this->shiftDir(Quaternion(time/5, Vector(1,0,0)));
    325343   }
    326    
     344
    327345  if( this->bRight /* > this->getRelCoor().z*2*/)
    328346  {
  • trunk/src/world_entities/space_ships/helicopter.h

    r6162 r6222  
    2424    void loadParams(const TiXmlElement* root);
    2525
     26    virtual void enter();
     27    virtual void leave();
     28
    2629    void addWeapon(Weapon* weapon );
    2730    void removeWeapon(Weapon* weapon);
     
    3942
    4043  private:
    41 
    4244    void calculateVelocity(float time);
    4345    void weaponAction();
     
    6567    float                 travelSpeed;        //!< the current speed of the player (to make soft movement)
    6668    float                 acceleration;       //!< the acceleration of the player.
    67    
     69
    6870    float                 airViscosity;
    6971
  • trunk/src/world_entities/space_ships/space_ship.cc

    r6162 r6222  
    112112  PRINTF(4)("SPACESHIP INIT\n");
    113113
    114   EventHandler::getInstance()->grabEvents(true);
     114//   EventHandler::getInstance()->grabEvents(true);
    115115
    116116  bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = false;
     
    177177  this->getWeaponManager()->getFixedTarget()->setRelCoor(100000,0,0);
    178178
     179  dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( false);
    179180}
    180181
     
    188189}
    189190
     191
     192void SpaceShip::enter()
     193{
     194  dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( true);
     195
     196
     197}
     198
     199void SpaceShip::leave()
     200{
     201  dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( false);
     202
     203
     204}
    190205
    191206/**
     
    267282  velocity += ((this->getAbsDirX())*travelSpeed-velocity)*airViscosity;
    268283  velocity = (velocity.getNormalized())*travelSpeed;
    269  
     284
    270285  //orient the spaceship in direction of the mouse
    271286   rotQuat = Quaternion::quatSlerp( this->getAbsDir(),mouseDir,fabsf(time)*3);
    272    if (this->getAbsDir().distance(rotQuat) > 0.001) 
     287   if (this->getAbsDir().distance(rotQuat) > 0.001)
    273288    this->setAbsDir( rotQuat);
    274289   //this->setAbsDirSoft(mouseDir,5);
    275    
     290
    276291  // this is the air friction (necessary for a smooth control)
    277292  if(velocity.len() != 0) velocity -= velocity*0.01;
     
    308323  /* calculate the direction in which the craft is heading  */
    309324
     325  Plane plane(Vector(0,1,0), Vector(0,0,0));
     326
    310327  if( this->bUp )
    311328   {
    312329     //this->shiftCoor(this->getAbsDirX());
    313330      accel += (this->getAbsDirX())*2;
    314      
     331
    315332      /* Heli-Steuerung
    316333         accel += (this->getAbsDirX()*2;
  • trunk/src/world_entities/space_ships/space_ship.h

    r6162 r6222  
    2626    void init();
    2727    void loadParams(const TiXmlElement* root);
     28
     29    virtual void enter();
     30    virtual void leave();
    2831
    2932    void addWeapon(Weapon* weapon );
  • trunk/src/world_entities/test_entity.cc

    r6142 r6222  
    1818
    1919
     20#include "executor/executor.h"
     21#include "factory.h"
     22#include "load_param.h"
     23
    2024#include "test_entity.h"
    2125#include "stdincl.h"
     
    2428#include "obb_tree.h"
    2529#include "state.h"
    26 #include "list.h"
    2730
    2831using namespace std;
    2932
    3033
     34CREATE_FACTORY(TestEntity, CL_TEST_ENTITY);
     35
    3136
    3237TestEntity::TestEntity ()
    3338{
    34   this->setClassID(CL_TEST_ENTITY, "TestEntity");
    35   // TO SOME LIST!!
     39  this->init();
     40}
    3641
    37   this->md2Model = new MD2Model("models/droidika.md2", "models/droideka.pcx");
    38 //   this->md2Model = new MD2Model("models/tris.md2", "models/tris.pcx");
    39 // this->md2Model = new MD2Model("models/goblin.md2", "maps/goblin.bmp");
    4042
    41 /// FIXME
    42 //  this->obbTree = new OBBTree(4, (sVec3D*)this->md2Model->data->pVertices, this->md2Model->data->numVertices);
    4343
    44   this->md2Model->setAnim(RUN);
    45   this->md2Model->debug();
     44TestEntity::TestEntity(const TiXmlElement* root)
     45{
     46  this->init();
     47  if (root != NULL)
     48    this->loadParams(root);
     49
     50  this->init();
    4651}
    4752
    4853
    4954TestEntity::~TestEntity ()
     55{}
     56
     57
     58
     59void TestEntity::init()
    5060{
    51   delete this->md2Model;
     61  this->setClassID(CL_TEST_ENTITY, "TestEntity");
     62  this->toList(OM_COMMON);
     63}
     64
     65/**
     66 * loads the Settings of a MD2Creature from an XML-element.
     67 * @param root the XML-element to load the MD2Creature's properties from
     68 */
     69void TestEntity::loadParams(const TiXmlElement* root)
     70{
     71  static_cast<WorldEntity*>(this)->loadParams(root);
     72
     73  LoadParam(root, "md2animation", this, TestEntity, setAnim)
     74      .describe("sets the animation of the md2 model")
     75      .defaultValues(1, 1);
     76
    5277}
    5378
     
    5580void  TestEntity::setAnim(int animationIndex)
    5681{
    57   this->md2Model->setAnim(animationIndex);
     82  if( likely(this->getModel(0) != NULL))
     83    ((MD2Model*)this->getModel(0))->setAnim(animationIndex);
    5884}
    5985
     
    6187void TestEntity::tick (float time)
    6288{
    63   this->md2Model->tick(time);
     89  if( likely(this->getModel(0) != NULL))
     90    ((MD2Model*)this->getModel(0))->tick(time);
     91
    6492}
    6593
    6694
    6795void TestEntity::collidesWith(WorldEntity* entity, const Vector& location)
    68 {
    69   if (entity->isA(CL_PROJECTILE))
    70   {
    71     PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getName(), entity->getName(), location.x, location.y, location.z);
    72   this->setVisibiliy(false);
    73   this->toList(OM_DEAD);
    74   }
    75 }
    76 
    77 void TestEntity::destroy () {}
    78 
     96{}
    7997
    8098
     
    82100void TestEntity::draw () const
    83101{
    84   glMatrixMode(GL_MODELVIEW);
    85   glPushMatrix();
    86   float matrix[4][4];
    87 
    88 
    89   glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z);
    90   this->getAbsDir().matrix (matrix);
    91   glMultMatrixf((float*)matrix);
    92   this->md2Model->draw();
    93 
    94 
    95   glPopMatrix();
     102  this->drawLODsafe();
    96103}
    97104
  • trunk/src/world_entities/test_entity.h

    r5500 r6222  
    1010struct t3DModel;
    1111class Material;
     12class TiXmlElement;
    1213
    1314class TestEntity : public WorldEntity, PhysicsInterface
     
    1718 public:
    1819  TestEntity ();
     20  TestEntity(const TiXmlElement* root);
    1921  virtual ~TestEntity ();
     22
     23  void init();
     24  void loadParams(const TiXmlElement* root);
    2025
    2126  void setAnim(int animationIndex);
    2227
    2328  virtual void tick (float time);
    24   virtual void destroy ();
    2529  virtual void collidesWith(WorldEntity* entity, const Vector& location);
    2630  virtual void draw () const;
  • trunk/src/world_entities/weapons/aim.cc

    r6142 r6222  
    2121#include "graphics_engine.h"
    2222#include "state.h"
    23 #include "list.h"
    2423#include "material.h"
    2524#include "t_animation.h"
     
    104103void Aim::searchTarget(float range)
    105104{
    106   //FIXME//
    107 /*  tIterator<WorldEntity>* iterator = State::getWorldEntityList()->getIterator();
    108   WorldEntity* entity = iterator->firstElement();
    109   while (likely(entity != NULL))
     105  std::list<WorldEntity*>::iterator entity;
     106
     107  for (entity = State::getObjectManager()->getObjectList(OM_GROUP_00).begin();
     108       entity != State::getObjectManager()->getObjectList(OM_GROUP_00).end();
     109       entity ++)
    110110  {
    111     if (entity->isA(CL_NPC) && this->source->getAbsCoor().x < entity->getAbsCoor().x && (this->source->getAbsCoor() - entity->getAbsCoor()).len() < range)
     111    if (this->source->getAbsCoor().x < (*entity)->getAbsCoor().x && (this->source->getAbsCoor() - (*entity)->getAbsCoor()).len() < range)
    112112    {
    113       if (this->getParent() != entity)
     113      if (this->getParent() != (*entity))
    114114      {
    115115        this->anim->replay();
    116         this->setParentSoft(entity, 5);
     116        this->setParentSoft(*entity, 5);
     117        return;
    117118      }
    118       delete iterator;
    119       return;
    120119    }
    121     entity = iterator->nextElement();
    122120  }
    123 
    124   delete iterator;*/
    125121}
    126122
  • trunk/src/world_entities/weapons/bomb.cc

    r6142 r6222  
    2121
    2222#include "fast_factory.h"
    23 #include "list.h"
     23
    2424
    2525#include "object_manager.h"
  • trunk/src/world_entities/weapons/guided_missile.cc

    r6162 r6222  
    2020#include "fast_factory.h"
    2121
    22 #include "model.h"
    2322#include "state.h"
    24 #include "list.h"
    2523#include "class_list.h"
    2624
  • trunk/src/world_entities/weapons/laser.cc

    r6162 r6222  
    2121
    2222#include "state.h"
    23 #include "list.h"
    2423#include "class_list.h"
    2524#include "model.h"
  • trunk/src/world_entities/weapons/rocket.cc

    r6142 r6222  
    2020#include "fast_factory.h"
    2121
    22 #include "model.h"
    2322#include "state.h"
    24 #include "list.h"
    2523#include "class_list.h"
    2624
  • trunk/src/world_entities/weapons/test_bullet.cc

    r6142 r6222  
    2020#include "fast_factory.h"
    2121
    22 #include "model.h"
    2322#include "state.h"
    24 #include "list.h"
    2523#include "class_list.h"
    2624
  • trunk/src/world_entities/weapons/test_gun.cc

    r6162 r6222  
    2929#include "factory.h"
    3030
    31 #include "vector.h"
    32 #include "list.h"
    3331#include "animation3d.h"
    3432
  • trunk/src/world_entities/weapons/turret.cc

    r6074 r6222  
    2323
    2424#include "state.h"
    25 #include "list.h"
    2625#include "animation3d.h"
    2726
  • trunk/src/world_entities/world_entity.cc

    r6142 r6222  
    2121
    2222#include "model.h"
     23#include "md2Model.h"
    2324#include "resource_manager.h"
    2425#include "load_param.h"
    25 #include "list.h"
    2626#include "vector.h"
    2727#include "obb_tree.h"
     
    8484  // Do the PNode loading stuff
    8585  static_cast<PNode*>(this)->loadParams(root);
     86
     87  LoadParam(root, "md2texture", this, WorldEntity, loadMD2Texture)
     88      .describe("the fileName of the texture, that should be loaded onto this world-entity. (must be relative to the data-dir)")
     89      .defaultValues(1, NULL);
    8690
    8791  // Model Loading
     
    8993      .describe("the fileName of the model, that should be loaded onto this world-entity. (must be relative to the data-dir)")
    9094      .defaultValues(3, NULL, 1.0f, 0);
    91 
    92 }
     95}
     96
    9397
    9498/**
     
    103107  if (fileName != NULL)
    104108  {
    105     // search for the special character # in the LoadParam
     109   // search for the special character # in the LoadParam
    106110    if (strchr(fileName, '#') != NULL)
     111    {
     112      PRINTF(4)("Found # in %s... searching for LOD's\n", fileName);
     113      char* lodFile = new char[strlen(fileName)+1];
     114      strcpy(lodFile, fileName);
     115      char* depth = strchr(lodFile, '#');
     116      for (unsigned int i = 0; i < 5; i++)
    107117      {
    108         PRINTF(4)("Found # in %s... searching for LOD's\n", fileName);
    109         char* lodFile = new char[strlen(fileName)+1];
    110         strcpy(lodFile, fileName);
    111         char* depth = strchr(lodFile, '#');
    112         for (unsigned int i = 0; i < 5; i++)
    113           {
    114             *depth = 48+(int)i;
    115             printf("-------%s\n", lodFile);
    116             if (ResourceManager::isInDataDir(lodFile))
    117               this->loadModel(lodFile, scaling, i);
    118           }
    119         return;
     118        *depth = 48+(int)i;
     119        printf("-------%s\n", lodFile);
     120        if (ResourceManager::isInDataDir(lodFile))
     121          this->loadModel(lodFile, scaling, i);
    120122      }
    121 
    122     PRINTF(4)("fetching %s\n", fileName);
    123     if (scaling == 1.0)
    124       this->setModel((Model*)ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN), modelNumber);
    125     else
    126       this->setModel((Model*)ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN, &scaling), modelNumber);
    127     if (modelNumber == 0)
    128     this->buildObbTree(4);
     123      return;
     124    }
     125
     126    if(strstr(fileName, ".obj"))
     127    {
     128      PRINTF(4)("fetching OBJ file: %s\n", fileName);
     129      if (scaling == 1.0)
     130        this->setModel((Model*)ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN), modelNumber);
     131      else
     132        this->setModel((Model*)ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN, &scaling), modelNumber);
     133
     134      if( modelNumber == 0)
     135        this->buildObbTree(4);
     136    }
     137    else if(strstr(fileName, ".md2"))
     138    {
     139      PRINTF(4)("fetching MD2 file: %s\n", fileName);
     140      Model* m = new MD2Model(fileName, this->md2TextureFileName);
     141        //this->setModel((Model*)ResourceManager::getInstance()->load(fileName, MD2, RP_CAMPAIGN), 0);
     142      this->setModel(m, 0);
     143    }
    129144  }
    130145  else
     
    145160  {
    146161    Resource* resource = ResourceManager::getInstance()->locateResourceByPointer(this->models[modelNumber]);
    147     if (resource != NULL)
    148       ResourceManager::getInstance()->unload(resource, RP_LEVEL);
    149     else
    150       delete this->models[modelNumber];
    151   }
     162//     if (resource != NULL)
     163    ResourceManager::getInstance()->unload(resource, RP_LEVEL);
     164  }
     165  else
     166    delete this->models[modelNumber];
     167
    152168  this->models[modelNumber] = model;
     169
    153170
    154171//   if (this->model != NULL)
     
    272289}
    273290
     291
     292/**
     293 *  this functions draws the model automaticaly in multiple LOD
     294 */
    274295void WorldEntity::drawLODsafe() const
    275296{
    276   if (!this->models.empty())
     297  if (!unlikely(this->models.empty()))
    277298  {
    278299    glMatrixMode(GL_MODELVIEW);
     
    291312    if (cameraDistance > 30 && this->models.size() >= 3 && this->models[2] != NULL)
    292313    {
    293        this->models[2]->draw();
     314      this->models[2]->draw();
    294315    }
    295316    else if (cameraDistance > 10 && this->models.size() >= 2 && this->models[1] != NULL)
  • trunk/src/world_entities/world_entity.h

    r6142 r6222  
    3737  Model* getModel(unsigned int modelNumber = 0) const { return (this->models.size() > modelNumber)? this->models[modelNumber] : NULL; };
    3838
     39  inline void loadMD2Texture(const char* fileName) { this->md2TextureFileName = fileName; }
     40
    3941  bool buildObbTree(unsigned int depth);
    4042  /** @returns a reference to the obb tree of this worldentity */
     
    7274  /** @returns a Reference to the Iterator */
    7375  std::list<WorldEntity*>::iterator& getEntityIterator() { return this->objectListIterator; }
     76
     77
    7478 protected:
    7579  //  CharacterAttributes*    charAttr;         //!< the character attributes of a world_entity
     
    7781 private:
    7882  std::vector<Model*>     models;             //!< The model that should be loaded for this entity.
     83  const char*             md2TextureFileName; //!< the file name of the md2 model texture, only if this
    7984  BVTree*                 obbTree;            //!< this is the obb tree reference needed for collision detection
    8085
Note: See TracChangeset for help on using the changeset viewer.