Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8122 in orxonox.OLD for branches/osx/src/lib/graphics


Ignore:
Timestamp:
Jun 2, 2006, 5:46:11 PM (19 years ago)
Author:
ponder
Message:

Md2loader seems to work

Location:
branches/osx/src/lib/graphics
Files:
3 edited

Legend:

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

    r7732 r8122  
    1414
    1515#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_IMPORTER
    16 
     16#include "config.h"
     17#ifdef HAVE_SDL_SDL_H
     18#include <SDL/SDL.h>
     19#include <SDL/SDL_endian.h>
     20#else
     21#include <SDL.h>
     22#include <SDL_endian.h>
     23#endif
    1724#include "md2Model.h"
    1825#include "material.h"
     
    2027#include "debug.h"
    2128#include "util/loading/resource_manager.h"
    22 
    2329
    2430using namespace std;
     
    6773
    6874
     75#ifdef SDL_LIL_ENDIAN
     76#define BULK_CONV( _ptr, _num ) do { \
     77        int  _cnt = _num;\
     78        int* _iptr = (int*)_ptr;\
     79        for( int _l = 0; _l<_cnt; ++_l )\
     80                _iptr[_l] = SDL_SwapLE32( _iptr[_l] );\
     81} while( 0 )
     82#else
     83#define BULK_CONV( _ptr, _num )
     84#endif 
    6985
    7086/********************************************************************************
     
    8096  /* this creates the data container via ressource manager */
    8197  if (!modelFileName.empty())
    82     this->data = (MD2Data*)ResourceManager::getInstance()->load(modelFileName, MD2, RP_GAME, skinFileName, scale);
     98    this->data = (MD2Data*)ResourceManager::getInstance()->load(
     99                        modelFileName, MD2, RP_GAME, skinFileName, scale);
     100                       
     101        //When arriving here it is assumed that everything is in the correct byte order.       
    83102  if( unlikely(this->data == NULL))
    84103    PRINTF(0)("The model was not found, MD2Model Loader finished abnormaly. Update the data-repos\n");
     
    99118  this->pModelInfo.numNormals = 0;
    100119  this->pModelInfo.numTexCoor = this->data->numTexCoor;
     120       
    101121  this->pModelInfo.pVertices = (float*)this->data->pVertices;
     122               
    102123  this->pModelInfo.pNormals = NULL;
     124
    103125  this->pModelInfo.pTexCoor = (float*)this->data->pTexCoor;
    104 
     126       
    105127  // triangle conversion
    106128  this->pModelInfo.pTriangles = new sTriangleExt[this->data->numTriangles];
     
    357379void MD2Model::debug()
    358380{
    359   PRINT(0)("\n==========================| MD2Model::debug() |===\n");
    360   PRINT(0)("=  Model FileName:\t%s\n", this->data->fileName.c_str());
    361   PRINT(0)("=  Skin FileName:\t%s\n", this->data->skinFileName.c_str());
    362   PRINT(0)("=  Size in Memory:\t%i Bytes\n", this->data->header->frameSize * this->data->header->numFrames + 64); // 64bytes is the header size
    363   PRINT(0)("=  Number of Vertices:\t%i\n", this->data->header->numVertices);
    364   PRINT(0)("=  Number of Frames: \t%i\n", this->data->header->numFrames);
    365   PRINT(0)("=  Height, Width:\t%i, %i\n", this->data->header->skinHeight, this->data->header->skinWidth);
    366   PRINT(0)("=  Pointer to the data object: %p\n", this->data);
    367   PRINT(0)("===================================================\n\n");
     381  //PRINTF(0)("\n==========================| MD2Model::debug() |===\n");
     382  PRINTF(0)("=  Model FileName:\t%s\n", this->data->fileName.c_str());
     383  PRINTF(0)("=  Skin FileName:\t%s\n", this->data->skinFileName.c_str());
     384  PRINTF(0)("=  Size in Memory:\t%i Bytes\n", this->data->header->frameSize * this->data->header->numFrames + 64); // 64bytes is the header size
     385  PRINTF(0)("=  Number of Vertices:\t%i\n", this->data->header->numVertices);
     386  PRINTF(0)("=  Number of Frames: \t%i\n", this->data->header->numFrames);
     387  PRINTF(0)("=  Height, Width:\t%i, %i\n", this->data->header->skinHeight, this->data->header->skinWidth);
     388  PRINTF(0)("=  Pointer to the data object: %p\n", this->data);
     389  //PRINTF(0)("===================================================\n\n");
    368390}
    369391
     
    442464  this->header = new MD2Header;
    443465  fread(this->header, 1, sizeof(MD2Header), pFile);
     466        BULK_CONV( this->header, sizeof(MD2Header)/4 );
    444467  /* check for the header version: make sure its a md2 file :) */
    445   if( unlikely(this->header->version != MD2_VERSION) && unlikely(this->header->ident != MD2_IDENT))
     468  if( unlikely( this->header->version != MD2_VERSION) && unlikely( this->header->ident != MD2_IDENT))
    446469    {
    447470      PRINTF(1)("Couldn't load file %s: invalid file format: stop loading\n", fileName.c_str());
     
    449472    }
    450473
    451   this->fileName =fileName;
     474  this->fileName = fileName;
    452475  /* got the data: map it to locals */
    453476  this->numFrames = this->header->numFrames;
     
    468491  fseek(pFile, this->header->offsetFrames, SEEK_SET);
    469492  fread(buffer, this->header->frameSize, this->numFrames, pFile);
     493        BULK_CONV( buffer, this->header->frameSize*this->numFrames*sizeof(char)/4 );
    470494  /* read opengl commands */
    471495  fseek(pFile, this->header->offsetGlCommands, SEEK_SET);
     496
    472497  fread(this->pGLCommands, sizeof(int), this->numGLCommands, pFile);
     498        BULK_CONV( this->pGLCommands, this->numGLCommands );
    473499  /* triangle list */
    474500  fseek(pFile, this->header->offsetTriangles, SEEK_SET);
    475   fread(this->pTriangles, sizeof(sTriangle), this->numTriangles, pFile);
     501  fread(this->pTriangles, sizeof(sTriangle), this->numTriangles, pFile);       
     502        BULK_CONV( this->pTriangles, this->numTriangles*(sizeof(sTriangle)/4) );
     503
    476504  /*  read in texture coordinates */
    477505  fseek(pFile, this->header->offsetTexCoords, SEEK_SET);
    478506  fread(this->pTexCoor, sizeof(sTexCoor), this->numTexCoor, pFile);
    479 
     507        BULK_CONV( this->pTexCoor, this->numTexCoor*(sizeof(sTexCoor)/4) );
    480508
    481509  for(int i = 0; i < this->numFrames; ++i)
  • branches/osx/src/lib/graphics/importer/texture.cc

    r7751 r8122  
    207207                                    surface->w, surface->h,
    208208                                    pixelDepth,
    209 #if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */
     209//#if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */
    210210                                    0x000000FF,
    211211                                    0x0000FF00,
    212212                                    0x00FF0000,
    213213                                    0xFF000000
    214 #else
    215                                     0xFF000000,
     214/*#else*/
     215                                    /*0xFF000000,
    216216                                    0x00FF0000,
    217217                                    0x0000FF00,
    218                                     0x000000FF
    219 #endif
     218                                    0x000000FF*/
     219/*#endif*/
    220220                                   );
    221221  if ( retSurface == NULL )
  • branches/osx/src/lib/graphics/spatial_separation/quadtree.cc

    r5430 r8122  
    2525
    2626using namespace std;
    27 
    2827#define QUADTREE_MATERIAL_COUNT       4
    2928
Note: See TracChangeset for help on using the changeset viewer.