Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6180 in orxonox.OLD


Ignore:
Timestamp:
Dec 20, 2005, 3:21:19 AM (18 years ago)
Author:
patrick
Message:

christmas: cleaned up the model package

Location:
branches/christmas_branche/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/christmas_branche/src/lib/graphics/importer/md2Model.cc

    r6175 r6180  
    3838//! again one of these strange id software parts
    3939static float *shadeDots = MD2Model::anormsDots[0];
     40
     41
     42static sVec3D verticesList[MD2_MAX_VERTICES];
     43
    4044
    4145//! the angle under which the model is viewd, used internaly
     
    108112   saving of data anyway
    109113*/
    110 void MD2Model::interpolate(sVec3D* verticesList)
     114void MD2Model::interpolate(/*sVec3D* verticesList*/)
    111115{
    112116  sVec3D* currVec;
     
    149153
    150154
    151 static sVec3D verticesList[MD2_MAX_VERTICES]; /* performance: created only once in a lifetime */
     155
    152156
    153157/**
     
    159163  this->animationState.localTime += time;
    160164
    161   if( likely(this->animationState.localTime > 0.0))
    162     this->animate();
    163 
     165  this->animate();
    164166  this->processLighting();
    165   this->interpolate(verticesList);
     167  this->interpolate(/*verticesList*/);
    166168}
    167169
     
    192194  glEnable(GL_CULL_FACE);
    193195  glCullFace(GL_BACK);
    194 
    195196
    196197  this->data->material->select();
  • branches/christmas_branche/src/lib/graphics/importer/md2Model.h

    r6175 r6180  
    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  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} sAnim;
     119
     120
     121//! animation state definition
     122typedef struct
     123{
     124  int              startFrame;           //!< the start frame of an animation
     125  int              endFrame;             //!< last frame of the animation
     126  int              fps;                  //!< fps of the animaion (speed)
     127
     128  float            localTime;            //!< the local time
     129  float            lastTime;             //!< last time stamp
     130  float            interpolationState;   //!< the state of the animation [0..1]
     131
     132  int              type;                 //!< animation type
     133
     134  int              currentFrame;         //!< the current frame
     135  int              nextFrame;            //!< the next frame in the list
     136} sAnimState;
    67137
    68138
     
    159229  void animate();
    160230  void processLighting();
    161   void interpolate(sVec3D* verticesList);
     231  void interpolate(/*sVec3D* verticesList*/);
    162232  void renderFrame() const ;
    163233
  • branches/christmas_branche/src/lib/graphics/importer/model.h

    r6033 r6180  
    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
  • branches/christmas_branche/src/world_entities/creatures/md2_creature.cc

    r6176 r6180  
    254254
    255255
    256 //   // MD2Creature controlled movement
    257 //   this->calculateVelocity(time);
    258 //
    259 //   Vector move = (velocity)*time;
    260 //
    261 //   //orient the velocity in the direction of the MD2Creature.
    262 //   travelSpeed = velocity.len();
    263 //   velocity += ((this->getAbsDirX())*travelSpeed-velocity)*airViscosity;
    264 //   velocity = (velocity.getNormalized())*travelSpeed;
    265 //
    266 //   //orient the MD2Creature in direction of the mouse
    267 //    rotQuat = Quaternion::quatSlerp( this->getAbsDir(),mouseDir,fabsf(time)*3);
    268 //    if (this->getAbsDir().distance(rotQuat) > 0.001)
    269 //     this->setAbsDir( rotQuat);
    270 //    //this->setAbsDirSoft(mouseDir,5);
    271 //
    272 //   // this is the air friction (necessary for a smooth control)
    273 //   if(velocity.len() != 0) velocity -= velocity*0.01;
    274 //
    275 //   //hoover effect
    276 //   cycle += time;
    277 //   this->shiftCoor(Vector(0,1,0)*cos(this->cycle*2.0)*0.02);
    278 //
    279 //   //readjust
    280 // // if (this->getAbsDirZ().y > 0.1) this->shiftDir(Quaternion(time*0.3, Vector(1,0,0)));
    281 //   //else if (this->getAbsDirZ().y < -0.1) this->shiftDir(Quaternion(-time*0.3, Vector(1,0,0)));
    282 //
    283 //   //SDL_WarpMouse(GraphicsEngine::getInstance()->getResolutionX()/2, GraphicsEngine::getInstance()->getResolutionY()/2);
    284 //
    285 //   this->shiftCoor (move);
    286 //
    287 //   this->getWeaponManager()->tick(time);
    288 //   // weapon system manipulation
    289 //   this->weaponAction();
     256  // MD2Creature controlled movement
     257  this->calculateVelocity(time);
     258
     259  Vector move = (velocity)*time;
     260
     261  //orient the velocity in the direction of the MD2Creature.
     262  travelSpeed = velocity.len();
     263  velocity += ((this->getAbsDirX())*travelSpeed-velocity)*airViscosity;
     264  velocity = (velocity.getNormalized())*travelSpeed;
     265
     266  //orient the MD2Creature in direction of the mouse
     267   rotQuat = Quaternion::quatSlerp( this->getAbsDir(),mouseDir,fabsf(time)*3);
     268   if (this->getAbsDir().distance(rotQuat) > 0.001)
     269    this->setAbsDir( rotQuat);
     270   //this->setAbsDirSoft(mouseDir,5);
     271
     272  // this is the air friction (necessary for a smooth control)
     273  if(velocity.len() != 0) velocity -= velocity*0.01;
     274
     275  //hoover effect
     276  cycle += time;
     277  this->shiftCoor(Vector(0,1,0)*cos(this->cycle*2.0)*0.02);
     278
     279  //readjust
     280 // if (this->getAbsDirZ().y > 0.1) this->shiftDir(Quaternion(time*0.3, Vector(1,0,0)));
     281  //else if (this->getAbsDirZ().y < -0.1) this->shiftDir(Quaternion(-time*0.3, Vector(1,0,0)));
     282
     283  //SDL_WarpMouse(GraphicsEngine::getInstance()->getResolutionX()/2, GraphicsEngine::getInstance()->getResolutionY()/2);
     284
     285  this->shiftCoor (move);
     286
     287  this->getWeaponManager()->tick(time);
     288  // weapon system manipulation
     289  this->weaponAction();
    290290}
    291291
  • branches/christmas_branche/src/world_entities/world_entity.cc

    r6179 r6180  
    136136      PRINTF(4)("fetching MD2 file: %s\n", fileName);
    137137//         MD2Model* m = (MD2Model*)ResourceManager::getInstance()->load(fileName, MD2, RP_CAMPAIGN);
    138       MD2Model* m = new MD2Model(fileName, "");
    139       m->debug();
     138      Model* m = new MD2Model(fileName, "md2_fake_texture.bad");
    140139        //this->setModel((Model*)ResourceManager::getInstance()->load(fileName, MD2, RP_CAMPAIGN), 0);
    141       this->setModel((Model*)m, 0);
     140      this->setModel(m, 0);
    142141    }
    143142  }
Note: See TracChangeset for help on using the changeset viewer.