Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7410 in orxonox.OLD


Ignore:
Timestamp:
Apr 27, 2006, 10:18:03 PM (18 years ago)
Author:
bottac
Message:

Inserted some SDL_SwapLE32()

Location:
branches/bsp_model/src/lib/graphics/importer
Files:
2 edited

Legend:

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

    r7395 r7410  
    127127    size    = SDL_SwapLE32(((int *)(header))[19]);
    128128    PRINTF(4)("BSP FILE: BrushesSize: %i Bytes. \n", size);
    129     PRINTF(4)("BSP FILE: NumBrushes: %i. \n", size / 12);
    130     PRINTF(4)("BSP FILE: Remainder: %i. \n", size % 12);
     129    PRINTF(4)("BSP FILE: NumBrushes: %i. \n", size / sizeof(brush));
     130    PRINTF(4)("BSP FILE: Remainder: %i. \n", size % sizeof(brush));
    131131    PRINTF(4)("BSP FILE: BrushesOffset: %i. \n", offset);
    132     this->brushes = new char [size];
    133     bspFile.seekg(offset);
    134     bspFile.read(this->brushes, size);
     132    this->brushes = new brush [size/sizeof(brush)];
     133    bspFile.seekg(offset);
     134    bspFile.read((char*)this->brushes, size);
    135135
    136136    // Get the brushSides
     
    162162    size    = SDL_SwapLE32(((int *)(header))[25]);
    163163    PRINTF(4)("BSP FILE: MeshVertsSize: %i Bytes. \n", size);
    164     PRINTF(4)("BSP FILE: NumMeshVerts: %i. \n", size / 4);
    165     PRINTF(4)("BSP FILE: Remainder: %i. \n", size % 4);
     164    PRINTF(4)("BSP FILE: NumMeshVerts: %i. \n", size / sizeof(meshvert));
     165    PRINTF(4)("BSP FILE: Remainder: %i. \n", size % sizeof(meshvert));
    166166    PRINTF(4)("BSP FILE: MeshVertsOffset: %i. \n", offset);
    167     this->meshverts = new char [size];
    168     bspFile.seekg(offset);
    169     bspFile.read(this->meshverts, size);
     167    this->meshverts = new meshvert [size / sizeof(meshvert)];
     168    bspFile.seekg(offset);
     169    bspFile.read((char*)this->meshverts, size);
    170170
    171171    // Get the Faces
     
    220220    for( int i = 0; i < this->numFaces; i++) {
    221221      face& cFace = ((face *)(this->faces))[i];
    222       if (      cFace.type == 2)
    223         this->numPatches += (cFace.size[0] -1 ) / 2  * (cFace.size[1] -1) / 2;
     222      if (SDL_SwapLE32(cFace.type) == 2)
     223        this->numPatches += (SDL_SwapLE32(cFace.size[0]) -1 ) / 2  * (SDL_SwapLE32(cFace.size[1]) -1) / 2;
    224224    }
    225225
     
    234234    // Do tesselation for all Faces of type 2
    235235    for( int i = 0; i < this->numFaces; i++) {
    236       if (      ((face *)(this->faces))[i].type == 2)
     236      if (SDL_SwapLE32((this->faces)[i].type) == 2)
    237237        this->tesselate(i);
    238238    }
     
    473473void BspFile::tesselate(int iface)
    474474{
    475   face*  Face =  & (((face *)(this->faces))[iface]);
     475  face*  Face =  &((this->faces)[iface]);
    476476  BspVertex *  BspVrtx = (BspVertex*)this->vertice;
    477477  int level = 7;
    478478  int level1 = 8;
    479 
     479  int size0 = SDL_SwapLE32(Face->size[0]);
     480  int size1 = SDL_SwapLE32(Face->size[1]);
    480481  // For each patch...
    481   for(int i = 0; i <(Face->size[0] - 1)    ; i+=2) {
    482     for(int j = 0; j <(Face->size[1] -1)    ; j+=2) {
     482  for(int i = 0; i <  ( size0 - 1)    ; i+=2) {
     483    for(int j = 0; j < ( size1 -1)    ; j+=2) {
    483484
    484485
     
    490491      for(int k = 0; k < 3; k++) {
    491492        for(int l = 0; l < 3; l++) {
    492           controls[k +3*l]. position[0] =   BspVrtx[Face->vertex +( j * Face->size[0])+ i + l+ Face->size[0]*k].position[0];
    493           controls[k +3*l]. position[1] =   BspVrtx[Face->vertex + (j * Face->size[0])+ i +l+ Face->size[0]*k].position[1];
    494           controls[k +3*l]. position[2] =   BspVrtx[Face->vertex + (j * Face->size[0])+ i + l+ Face->size[0]*k].position[2]; /*Face->n_vertexes*/
    495 
    496           controlsTmp[2-k +6-3*l]. position[0] =   BspVrtx[Face->vertex +( j * Face->size[0])+ i + l+ Face->size[0]*k].position[0];
    497           controlsTmp[2-k +6-3*l]. position[1] =   BspVrtx[Face->vertex + (j * Face->size[0])+ i +l+ Face->size[0]*k].position[1];
    498           controlsTmp[2-k +6-3*l]. position[2] =   BspVrtx[Face->vertex + (j * Face->size[0])+ i + l+ Face->size[0]*k].position[2]; /*Face->n_vertexes*/
    499 
    500           VControls[k +3*l]. position[0] =   BspVrtx[Face->vertex +( j * Face->size[0])+ i + l+ Face->size[0]*k].position[0];
    501           VControls[k +3*l]. position[1] =   BspVrtx[Face->vertex + (j * Face->size[0])+ i +l+ Face->size[0]*k].position[1];
    502           VControls[k +3*l]. position[2] =   BspVrtx[Face->vertex + (j * Face->size[0])+ i + l+ Face->size[0]*k].position[2];
    503 
    504           VControls[k +3*l]. normal[0] =   BspVrtx[Face->vertex +( j * Face->size[0])+ i + l+ Face->size[0]*k].normal[0];
    505           VControls[k +3*l]. normal[1] =   BspVrtx[Face->vertex + (j * Face->size[0])+ i +l+ Face->size[0]*k].normal[1];
    506           VControls[k +3*l]. normal[2] =   BspVrtx[Face->vertex + (j * Face->size[0])+ i + l+ Face->size[0]*k].normal[2];
    507 
    508           VControls[k +3*l]. texcoord[0][0]=   BspVrtx[Face->vertex +( j * Face->size[0])+ i + l+ Face->size[0]*k].texcoord[0][0];
    509           VControls[k +3*l]. texcoord[0][1] =   BspVrtx[Face->vertex + (j * Face->size[0])+ i +l+ Face->size[0]*k].texcoord[0][1];
    510           VControls[k +3*l]. texcoord[1][0] =   BspVrtx[Face->vertex +( j * Face->size[0])+ i + l+ Face->size[0]*k].texcoord[1][0];
    511           VControls[k +3*l]. texcoord[1][1] =   BspVrtx[Face->vertex + (j * Face->size[0])+ i +l+ Face->size[0]*k].texcoord[1][1];
     493          controls[k +3*l]. position[0] =   SDL_SwapLE32(    BspVrtx[Face->vertex + (j * size0)+ i + l+ size0*k].position[0]);
     494          controls[k +3*l]. position[1] =   SDL_SwapLE32(    BspVrtx[Face->vertex + (j * size0)+ i +l+ size0*k].position[1]);
     495          controls[k +3*l]. position[2] =   SDL_SwapLE32(    BspVrtx[Face->vertex + (j * size0)+ i + l+ size0*k].position[2]); /*Face->n_vertexes*/
     496
     497          controlsTmp[2-k +6-3*l]. position[0] =   SDL_SwapLE32(    BspVrtx[Face->vertex +( j * size0)+ i + l+ size0*k].position[0]);
     498          controlsTmp[2-k +6-3*l]. position[1] =   SDL_SwapLE32(    BspVrtx[Face->vertex + (j * size0)+ i +l+ size0*k].position[1]);
     499          controlsTmp[2-k +6-3*l]. position[2] =   SDL_SwapLE32(    BspVrtx[Face->vertex + (j * size0)+ i + l+ size0*k].position[2]); /*Face->n_vertexes*/
     500
     501          VControls[k +3*l]. position[0] =   SDL_SwapLE32(    BspVrtx[Face->vertex +( j * size0)+ i + l+ size0*k].position[0]);
     502          VControls[k +3*l]. position[1] =   SDL_SwapLE32(    BspVrtx[Face->vertex + (j * size0)+ i +l+ size0*k].position[1]);
     503          VControls[k +3*l]. position[2] =   SDL_SwapLE32(    BspVrtx[Face->vertex + (j * size0)+ i + l+ size0*k].position[2]);
     504
     505          VControls[k +3*l]. normal[0] =   SDL_SwapLE32(    BspVrtx[Face->vertex +( j * size0)+ i + l+ size0*k].normal[0]);
     506          VControls[k +3*l]. normal[1] =   SDL_SwapLE32(    BspVrtx[Face->vertex + (j * size0)+ i +l+ size0*k].normal[1]);
     507          VControls[k +3*l]. normal[2] =   SDL_SwapLE32(    BspVrtx[Face->vertex + (j * size0)+ i + l+ size0*k].normal[2]);
     508
     509          VControls[k +3*l]. texcoord[0][0]=    SDL_SwapLE32(    BspVrtx[Face->vertex +( j * size0)+ i + l+ size0*k].texcoord[0][0]);
     510          VControls[k +3*l]. texcoord[0][1] =   SDL_SwapLE32(    BspVrtx[Face->vertex + (j * size0)+ i +l+ size0*k].texcoord[0][1]);
     511          VControls[k +3*l]. texcoord[1][0] =   SDL_SwapLE32(    BspVrtx[Face->vertex +( j * size0)+ i + l+ size0*k].texcoord[1][0]);
     512          VControls[k +3*l]. texcoord[1][1] =   SDL_SwapLE32(    BspVrtx[Face->vertex + (j * size0)+ i +l+ size0*k].texcoord[1][1]);
    512513
    513514
     
    593594        for(int v=0; v<=level; ++v) {
    594595          px=(float)v/level;
     596
     597
     598
     599
    595600
    596601          //Vertice[u*(tesselation+1)+v]=       temp[0]*((1.0f-px)*(1.0f-px))+ temp[1]*((1.0f-px)*px*2)+ temp[2]*(px*px);
  • branches/bsp_model/src/lib/graphics/importer/bsp_file.h

    r7395 r7410  
    147147  face* faces;               //!<
    148148  char* leafBrushes;         //!< Buffer to store brush indice
    149   char* brushes;             //!< Buffer to store  brushes
     149  brush* brushes;            //!< Buffer to store  brushes
    150150  char* brushSides;          //!<
    151151  char* vertice;             //!<
    152   char* meshverts;           //!<
     152  meshvert* meshverts;       //!<
    153153  char* visData;             //!<
    154154  char* textures;            //!<
Note: See TracChangeset for help on using the changeset viewer.