Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8894 in orxonox.OLD for trunk/src/lib/graphics/importer


Ignore:
Timestamp:
Jun 29, 2006, 12:19:48 AM (19 years ago)
Author:
patrick
Message:

merged the branche single_player_map with the trunk

Location:
trunk/src/lib/graphics/importer
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/importer/bsp_file.cc

    r8490 r8894  
    214214    bspFile.read(this->visData, size);
    215215
    216     PRINTF(0)("BSP FILE: VisDataSize: %i Bytes. \n", size);
    217     PRINTF(0)("BSP FILE: NumVisData: %i. \n", size /1 - 8);
    218     PRINTF(0)("BSP FILE: Remainder: %i. \n", size % 1);
    219     PRINTF(0)("BSP FILE: VisDataOffset: %i. \n", offset);
     216    PRINTF(4)("BSP FILE: VisDataSize: %i Bytes. \n", size);
     217    PRINTF(4)("BSP FILE: NumVisData: %i. \n", size /1 - 8);
     218    PRINTF(4)("BSP FILE: Remainder: %i. \n", size % 1);
     219    PRINTF(4)("BSP FILE: VisDataOffset: %i. \n", offset);
    220220
    221221    // Get the Textures
     
    298298    this->VertexArrayModels  = new VertexArrayModel*[this->numPatches];
    299299
    300     PRINTF(0)("BSP FILE:NumberOfPatches: %i . \n", numPatches);
     300    PRINTF(4)("BSP FILE:NumberOfPatches: %i . \n", numPatches);
    301301
    302302    this->swapAllBspCoordinates();
     
    308308    }
    309309
    310     PRINTF(0)("BSP FILE:PatchOffset: %i . \n", this->patchOffset);
     310    PRINTF(4)("BSP FILE:PatchOffset: %i . \n", this->patchOffset);
    311311
    312312    return  1;
    313313  } else {
    314     PRINTF(0)("BSP FILE: Datei nicht gefunden. \n");
     314    PRINTF(4)("BSP FILE: Datei nicht gefunden. \n");
    315315    return -1;
    316316  }
     
    323323{
    324324
    325   PRINTF(0)("BSP FILE:\n");
    326   PRINTF(0)("BSP FILE: Building Tree...\n");
     325  PRINTF(4)("BSP FILE:\n");
     326  PRINTF(4)("BSP FILE: Building Tree...\n");
    327327  root = this->build_tree_rec(0);
    328   PRINTF(0)("BSP FILE: ...done. \n");
    329   PRINTF(0)("BSP FILE:  \n");
    330   PRINTF(0)("BSP FILE: Node #0: \n");
    331   PRINTF(0)("BSP FILE:  x: %f \n",root->plane.x);
    332   PRINTF(0)("BSP FILE:  y: %f\n",root->plane.y);
    333   PRINTF(0)("BSP FILE:  z: %f\n",root->plane.z);
     328  PRINTF(4)("BSP FILE: ...done. \n");
     329  PRINTF(4)("BSP FILE:  \n");
     330  PRINTF(4)("BSP FILE: Node #0: \n");
     331  PRINTF(4)("BSP FILE:  x: %f \n",root->plane.x);
     332  PRINTF(4)("BSP FILE:  y: %f\n",root->plane.y);
     333  PRINTF(4)("BSP FILE:  z: %f\n",root->plane.z);
    334334}
    335335
     
    400400  this->Materials = new AMat[this->numTextures];
    401401  for(int i = 0 ; i < this->numTextures; i++) {
    402     PRINTF(0)("BSP FILE: Texture : %s. \n", &this->textures[8+ 72*i]);
     402    PRINTF(4)("BSP FILE: Texture : %s. \n", &this->textures[8+ 72*i]);
    403403
    404404
     
    429429    strncat (fileName, ext, strlen(fileName) );
    430430
    431     PRINTF(0)("BSP FILE: Name %s . \n", fileName);
     431    PRINTF(4)("BSP FILE: Name %s . \n", fileName);
    432432
    433433    absFileName = ResourceManager::getFullName(fileName);
    434434
    435435    if(File(absFileName).exists()) {
    436       PRINTF(0)("BSP FILE: gefunden . \n");
     436      PRINTF(4)("BSP FILE: gefunden . \n");
    437437      this->Materials[i] = this->loadAVI(fileName);
    438438      continue;
     
    449449
    450450    if(File(absFileName).exists()) {
    451       PRINTF(0)("BSP FILE: gefunden . \n");
     451      PRINTF(4)("BSP FILE: gefunden . \n");
    452452      this->Materials[i] = this->loadAVI(fileName);
    453453      continue;
     
    479479
    480480    if(File(absFileName).exists()) {
    481       PRINTF(0)("BSP FILE: gefunden . \n");
     481      PRINTF(4)("BSP FILE: gefunden . \n");
    482482      this->Materials[i] = this->loadMat(fileName);
    483483      continue;
     
    492492
    493493    if(File(absFileName).exists()/*stat( absFileName.c_str() , &results) == 0*/) {
    494       PRINTF(0)("BSP FILE: gefunden . \n");
     494      PRINTF(4)("BSP FILE: gefunden . \n");
    495495      this->Materials[i] = this->loadMat(fileName);
    496496      continue;
     
    504504    absFileName = ResourceManager::getFullName(fileName);
    505505    if(File(absFileName).exists()) {
    506       PRINTF(0)("BSP FILE: gefunden . \n");
     506      PRINTF(4)("BSP FILE: gefunden . \n");
    507507      this->Materials[i] =this->loadMat(fileName);
    508508      continue;
     
    518518    absFileName = ResourceManager::getFullName(fileName);
    519519    if(File(absFileName).exists()) {
    520       PRINTF(0)("BSP FILE: gefunden . \n");
     520      PRINTF(4)("BSP FILE: gefunden . \n");
    521521      this->Materials[i] =this->loadMat(fileName);
    522522      continue;
     
    534534
    535535    if(File(absFileName).exists()) {
    536       PRINTF(0)("BSP FILE: gefunden . \n");
     536      PRINTF(4)("BSP FILE: gefunden . \n");
    537537      this->Materials[i] =this->loadMat(fileName);
    538538      continue;
     
    548548
    549549    if(File(absFileName).exists()) {
    550       PRINTF(0)("BSP FILE: gefunden . \n");
     550      PRINTF(4)("BSP FILE: gefunden . \n");
    551551      this->Materials[i] = this->loadMat(fileName);
    552552      continue;
    553553    }
    554554
    555 
     555    PRINTF(0)("BSP FILE: Textur %s nicht  gefunden . \n", &this->textures[8+72*i]);
    556556    //  Default Material
    557557    this->Materials[i].mat = new Material();
     
    10121012  Face->meshvert = patchOffset -sz;  //3*(patchOffset-sz)*level1*level1;
    10131013  Face->n_meshverts = sz;
    1014   PRINTF(0)("BSP FILE: sz: %i. \n", sz);
    1015   PRINTF(0)("BSP FILE: Face->meshvert %i . \n", Face->meshvert);
     1014  PRINTF(4)("BSP FILE: sz: %i. \n", sz);
     1015  PRINTF(4)("BSP FILE: Face->meshvert %i . \n", Face->meshvert);
    10161016
    10171017  //Face->n_meshverts = sz;
  • trunk/src/lib/graphics/importer/bsp_manager.cc

    r8796 r8894  
    4545
    4646#include "aabb.h"
    47 
     47#include "cr_defs.h"
    4848
    4949
     
    912912{
    913913  leaf& curLeaf = this->bspFile->leaves[node->leafIndex];
    914   for(int i = 0; i < curLeaf.n_leaffaces ; i++) {
    915   }
     914  for(int i = 0; i < curLeaf.n_leaffaces ; i++) {}
    916915  return 10.0f;
    917916}
    918917
    919918void BspManager::checkCollisionBox(void)
    920 {
    921 }
    922 ;
     919{}
     920
    923921
    924922void BspManager::TraceBox( Vector& inputStart, Vector& inputEnd,
     
    954952
    955953
    956   Vector forwardDir = worldEntity->getAbsDirX();
    957 
    958 
    959   Vector upDir = worldEntity->getAbsDirY();
    960   upDir.x = 0.0;
    961   upDir.y = 1.0;
    962   upDir.z = 0.0;
    963   Vector dest;
    964    
    965 
    966   Vector position = worldEntity->getAbsCoor();       //+ upDir*10.0f ;
    967   dest = worldEntity->getAbsCoor() - upDir*40.0f; //
    968   Vector out = dest;
    969 
    970 
     954  Vector forwardDir = Vector(0.0,0.0,1.0);
     955  Vector upDir = Vector(0.0,1.0,0.0);
     956  Vector position = worldEntity->getAbsCoor();
     957
     958  bool SolidFlag = false;
    971959  bool collision = false;
    972960  Vector position1 = position;
    973961  Vector position2 = position + Vector(0.0,1.0,0.0);
     962  Vector dest = worldEntity->getAbsCoor() - upDir*40.0f; //
    974963  Vector dest1 = position + forwardDir*4.0f;
    975964  Vector dest2 = position2 + forwardDir;
    976965  dest = position - Vector(0.0, 40.0,0.0);
     966  Vector out = dest;
    977967  Vector out1;
    978968  Vector out2;
    979969
    980  
     970
    981971
    982972  float height = 40;
    983  
    984  
    985   if( box != NULL)
    986   {
     973
     974
     975  if( box != NULL) {
    987976    position = worldEntity->getAbsCoor() +  box->center; // + box->axis[1] * box->halfLength[1];
    988977    dest     = worldEntity->getAbsCoor() +  box->center - box->axis[1] * box->halfLength[1] * 40.0;
    989    
     978
    990979    position1 = worldEntity->getAbsCoor() +  box->center + box->axis[0] * box->halfLength[0] * 2.0f;
    991980    dest1     = worldEntity->getAbsCoor() +  box->center - box->axis[0] * box->halfLength[0] *2.0f;
    992    
    993        
     981
     982
    994983    position2 = worldEntity->getAbsCoor() +  box->center + box->axis[2] * box->halfLength[2] * 2.0f;
    995984    dest2     = worldEntity->getAbsCoor() +  box->center - box->axis[2] * box->halfLength[2] * 2.0f;
    996    
    997   }
    998   else
    999   {
    1000    
    1001   }
    1002 
    1003  
    1004  
    1005   //
     985
     986  } else {
     987    // Init positions and destinations to anything useful!
     988
     989  }
     990
     991
     992
     993  // 1st Ray
    1006994  this->inputStart =  position;
    1007995  this->inputEnd =   dest;
     
    10251013        this->collPlane->z = 0.0f;
    10261014        collision = true;
    1027       } else
     1015        SolidFlag = true;
     1016      } else
    10281017        collision = false;
    1029        
    1030        
    1031         out = dest;
    1032      
     1018
     1019
     1020      out = dest;
     1021
    10331022    } else {
    10341023      collision = true;
     
    10461035  plane* testPlane = this->collPlane;
    10471036
    1048  
    1049   // 2nd Collision Detection
    1050   this->outputStartsOut = true;
    1051   this->outputAllSolid = false;
    1052   this->outputFraction = 1.0f;
    1053   this->inputStart =  position1;
    1054   this->inputEnd =   dest1;
    1055   this->checkCollisionRayN(this->root,0.0f,1.0f, &position1, &dest1 );
    1056   out.x = this->outputFraction;
    1057   //out.z = this->outputFraction;
    1058  
    1059  
    1060     // 3rd Collision Detection
    1061   this->outputStartsOut = true;
    1062   this->outputAllSolid = false;
    1063   this->outputFraction = 1.0f;
    1064   this->inputStart =  position2;
    1065   this->inputEnd =   dest2;
    1066   this->checkCollisionRayN(this->root,0.0f,1.0f, &position2, &dest2 );
    1067   //out.x = this->outputFraction;
    1068   out.z = this->outputFraction;
    1069  
    1070 
     1037
     1038  bool xCollision = false;
     1039  bool zCollision = false;
     1040  if(!SolidFlag) {
     1041
     1042    // 2nd Collision Detection
     1043    this->outputStartsOut = true;
     1044    this->outputAllSolid = false;
     1045    this->outputFraction = 1.0f;
     1046    this->inputStart =  position1;
     1047    this->inputEnd =   dest1;
     1048    this->checkCollisionRayN(this->root,0.0f,1.0f, &position1, &dest1 );
     1049
     1050    if(!this->outputAllSolid != 1.0f) {
     1051      out.x = dest1.x + (dest1.x -position1.x) * this->outputFraction;
     1052      xCollision = true;
     1053      testPlane = this->collPlane;
     1054    }
     1055    if(this->outputAllSolid) {
     1056      SolidFlag = true;
     1057      xCollision = true; 
     1058    }
     1059    //out.z = this->outputFraction;
     1060
     1061    if(!SolidFlag) {
     1062
     1063      // 3rd Collision Detection
     1064      this->outputStartsOut = true;
     1065      this->outputAllSolid = false;
     1066      this->outputFraction = 1.0f;
     1067      this->inputStart =  position2;
     1068      this->inputEnd =   dest2;
     1069      this->checkCollisionRayN(this->root,0.0f,1.0f, &position2, &dest2 );
     1070      //out.x = this->outputFraction;
     1071
     1072      if(this->outputFraction != 1.0f ) {
     1073        out.z = out.z = dest2.z + (dest2.z -position2.z) * this->outputFraction;
     1074        zCollision = true;
     1075        testPlane = this->collPlane;
     1076
     1077      }
     1078      if(this->outputAllSolid) {
     1079          SolidFlag = true;
     1080          zCollision = true;   
     1081      }
     1082    }
     1083  }//end if
    10711084  /*
    10721085  This is how you would calculate the Coordinates where worldEntity Collided with the BSP world.
     
    10771090
    10781091  // Return the normal here: Normal's stored in this->collPlane;
    1079   if( collision)
    1080   {
     1092  if( collision) {
    10811093    PRINTF(5)("We got a collision!! Are you sure: outputFraction = %f\n", this->outputFraction);
    1082     worldEntity->registerCollision(this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), out);
    1083   }
    1084   else  worldEntity->registerCollision(this->parent, worldEntity, Vector(0.0, 2.0, 0.0), dest);
     1094    worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y || (xCollision ? COLLISION_TYPE_AXIS_X :0) | (zCollision ? COLLISION_TYPE_AXIS_Z :0), this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), out, SolidFlag);
     1095  } else {
     1096    if(xCollision || zCollision) {
     1097
     1098      worldEntity->registerCollision((xCollision ? COLLISION_TYPE_AXIS_X :0) | (zCollision ? COLLISION_TYPE_AXIS_Z :0) , this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), out, SolidFlag);
     1099    }
     1100
     1101  }
     1102  //else  worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y, this->parent, worldEntity, Vector(0.0, 2.0, 0.0), dest, false);
    10851103
    10861104}
  • trunk/src/lib/graphics/importer/interactive_model.h

    r8724 r8894  
    3737
    3838    virtual void setAnimation(int animNum, int playbackMode = 0) = 0;
     39    virtual void setAnimation(int firstFrame, int lastFrame, int fps, int bStoppable, int animPlayback) {}
    3940    virtual int getAnimation() = 0;
     41
     42    virtual void setAnimationSpeed(float speed) {}
    4043};
    4144
  • trunk/src/lib/graphics/importer/md2/md2Model.cc

    r8490 r8894  
    103103  this->pModelInfo.pTexCoor = (float*)this->data->pTexCoor;
    104104
     105  this->animationSpeed = 1.0f;
     106
    105107  // triangle conversion
    106108  this->pModelInfo.pTriangles = new sTriangleExt[this->data->numTriangles];
     
    159161
    160162/**
     163 * sets the animation type
     164 * @param firstFrame: index of the first frame
     165 * @param lastFrame: index of the last frame
     166 * @param fps: frames per second
     167 * @param bStoppable: is 1 if so, 0 else
     168 */
     169void MD2Model::setAnimation(int firstFrame, int lastFrame, int fps, int bStoppable, int animPlayback)
     170{
     171  this->animationState.startFrame = firstFrame;
     172  this->animationState.endFrame = lastFrame;
     173  this->animationState.nextFrame = firstFrame + 1;
     174  this->animationState.fps = fps;
     175  this->animationState.type = 0;
     176  this->animationState.numPlays = 0;
     177  this->animationState.animPlaybackMode = animPlayback;
     178
     179  this->animationState.interpolationState = 0.0f;
     180  this->animationState.localTime = 0.0f;
     181  this->animationState.lastTime = 0.0f;
     182  this->animationState.currentFrame = firstFrame;
     183}
     184
     185/**
    161186  \brief sets the animation type
    162187* @param type: animation type
     
    196221void MD2Model::tick(float time)
    197222{
    198   this->animate(time);
     223  this->animate(time * this->animationSpeed);
    199224  this->processLighting();
    200225  this->interpolate(/*this->verticesList*/);
  • trunk/src/lib/graphics/importer/md2/md2Model.h

    r8724 r8894  
    6969
    7070//! animation names enumeration
    71 typedef enum animType
     71typedef enum MD2animType
    7272  {
    7373    STAND,                       //0
     
    156156  void renderFrameTriangles() const;
    157157
    158 
    159158  virtual void setAnimation(int type, int animPlayback = MD2_ANIM_LOOP);
     159  virtual void setAnimation(int firstFrame, int lastFrame, int fps, int bStoppable, int animPlayback);
    160160  /**  returns the current animation @returns animation type */
    161161  inline int MD2Model::getAnimation() { return this->animationState.type; }
     162  virtual void setAnimationSpeed(float speed) { this->animationSpeed = speed; }
    162163  /**  scales the current model @param scaleFactor: the factor [0..1] to use for scaling */
    163164  void scaleModel(float scaleFactor) { this->scaleFactor = scaleFactor;}
     
    186187 private:
    187188  float               scaleFactor;                      //!< the scale factor (individual)
     189  float               animationSpeed;                   //!< the speed of the animation (factor for the time)
    188190  sAnimState          animationState;                   //!< animation state of the model
    189191  sVec3D              verticesList[MD2_MAX_VERTICES];   //!< place to temp sav the vert
Note: See TracChangeset for help on using the changeset viewer.