Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8162 in orxonox.OLD for branches/osx


Ignore:
Timestamp:
Jun 5, 2006, 5:27:38 PM (19 years ago)
Author:
ponder
Message:

The md2Model loader now works as expected

Location:
branches/osx/src/lib
Files:
4 edited

Legend:

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

    r8122 r8162  
    8080                _iptr[_l] = SDL_SwapLE32( _iptr[_l] );\
    8181} while( 0 )
     82#define BULK_CONV16( _ptr, _num ) do { \
     83        short  _cnt = _num;\
     84        short* _iptr = (short*)_ptr;\
     85        for( int _l = 0; _l<_cnt; ++_l )\
     86                _iptr[_l] = SDL_SwapLE16( _iptr[_l] );\
     87} while( 0 )
    8288#else
    8389#define BULK_CONV( _ptr, _num )
     90#define BULK_CONV16( _ptr, _num )
    8491#endif 
    8592
     
    111118  this->setAnim(STAND);
    112119
    113   this->debug();
     120  //this->debug();
    114121
    115122    //write the modelinfo information
     
    381388  //PRINTF(0)("\n==========================| MD2Model::debug() |===\n");
    382389  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
     390  PRINTF(0)("=  Skin FileName:\t%s\n",
     391                this->data->skinFileName.c_str());
     392  PRINTF(0)("=  Size in Memory:\t%i Bytes\n",
     393                this->data->header->frameSize * this->data->header->numFrames + 64); // 64bytes is the header size
    385394  PRINTF(0)("=  Number of Vertices:\t%i\n", this->data->header->numVertices);
    386395  PRINTF(0)("=  Number of Frames: \t%i\n", this->data->header->numFrames);
     
    491500  fseek(pFile, this->header->offsetFrames, SEEK_SET);
    492501  fread(buffer, this->header->frameSize, this->numFrames, pFile);
    493         BULK_CONV( buffer, this->header->frameSize*this->numFrames*sizeof(char)/4 );
     502        //BULK_CONV( buffer, this->header->frameSize*this->numFrames*sizeof(char)/4 );
    494503  /* read opengl commands */
    495504  fseek(pFile, this->header->offsetGlCommands, SEEK_SET);
     
    500509  fseek(pFile, this->header->offsetTriangles, SEEK_SET);
    501510  fread(this->pTriangles, sizeof(sTriangle), this->numTriangles, pFile);       
    502         BULK_CONV( this->pTriangles, this->numTriangles*(sizeof(sTriangle)/4) );
     511        BULK_CONV16( this->pTriangles, this->numTriangles*sizeof(sTriangle)/2 );
    503512
    504513  /*  read in texture coordinates */
    505514  fseek(pFile, this->header->offsetTexCoords, SEEK_SET);
    506515  fread(this->pTexCoor, sizeof(sTexCoor), this->numTexCoor, pFile);
    507         BULK_CONV( this->pTexCoor, this->numTexCoor*(sizeof(sTexCoor)/4) );
     516        BULK_CONV16( this->pTexCoor, this->numTexCoor*sizeof(sTexCoor)/2 );
    508517
    509518  for(int i = 0; i < this->numFrames; ++i)
    510519    {
    511520      frame = (sFrame*)(buffer + this->header->frameSize * i);
     521                        //Convert the translate and scale Vec3D if needed.
     522                        BULK_CONV( frame, 6 );
     523                        BULK_CONV( frame->pVertices, 3 );
    512524      pVertex = this->pVertices + this->numVertices  * i;
    513525      pNormals = this->pLightNormals + this->numVertices * i;
  • branches/osx/src/lib/graphics/importer/texture.cc

    r8122 r8162  
    2222#include <math.h>
    2323
    24 // INCLUDING SDL_Image
    25 #ifdef HAVE_SDL_IMAGE_H
     24#ifdef HAVE_SDL_SDL_H
     25#include <SDL/SDL_image.h>
     26#include <SDL/SDL_endian.h>
     27#include <SDL/SDL_byteorder.h>
     28#else
     29#include <SDL_endian.h>
    2630#include <SDL_image.h>
     31#include <SDL_byteorder.h>
     32#endif
     33#if SDL_BYTEORDER == SDL_BIG_ENDIAN
     34/*
     35 * On the BIG_ENDIAN architecture, the 24 and 32bit bitmaps have
     36 * different masks. If you don't do this distinction properly,
     37 * you will get weird-looking textures.
     38 */
     39Uint32 alphaMask[] = {
     40        0xFF000000,
     41        0x00FF0000,
     42        0x0000FF00,
     43        0x000000FF,
     44};
     45
     46Uint32 opaqueMask[] = {
     47        0x00FF0000,
     48        0x0000FF00,
     49        0x000000FF,
     50        0xFF000000
     51};
    2752#else
    28 #include <SDL/SDL_image.h>
     53/*
     54 * On the LIL_ENDIAN architecture everything is fine and easy. The 24
     55 * and 32bit bitmaps have the same masks.
     56 */
     57Uint32 alphaMask[] = {
     58        0x000000FF,
     59        0x0000FF00,
     60        0x00FF0000,
     61        0xFF000000,
     62};
     63
     64Uint32 opaqueMask[] = alphaMask
     65
    2966#endif
    30 
    3167/**
    3268 * @brief Constructor for a Texture
     
    190226  Uint32 saved_flags;
    191227  Uint8  saved_alpha;
    192 
    193228  hasAlpha = false;
    194229  int pixelDepth = 24;
    195230
     231        Uint32* mask = opaqueMask;
     232       
    196233  /* Save the alpha blending attributes */
    197234  saved_flags = surface->flags&(SDL_SRCALPHA | SDL_RLEACCELOK);
    198235  saved_alpha = surface->format->alpha;
    199   if ( (saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA )
     236  if ( saved_flags & SDL_SRCALPHA )
    200237  {
    201238    SDL_SetAlpha(surface, 0, 0);
    202239    hasAlpha = true;
    203240    pixelDepth = 32;
    204   }
    205 
     241                mask = alphaMask;
     242  }
     243               
    206244  retSurface = SDL_CreateRGBSurface(SDL_HWSURFACE,
    207245                                    surface->w, surface->h,
    208246                                    pixelDepth,
    209 //#if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */
    210                                     0x000000FF,
    211                                     0x0000FF00,
    212                                     0x00FF0000,
    213                                     0xFF000000
    214 /*#else*/
    215                                     /*0xFF000000,
    216                                     0x00FF0000,
    217                                     0x0000FF00,
    218                                     0x000000FF*/
    219 /*#endif*/
    220                                    );
     247                                                                                                                                                mask[0], mask[1], mask[2], mask[3] );
    221248  if ( retSurface == NULL )
    222249    return NULL;
  • branches/osx/src/lib/math/vector.h

    r7711 r8162  
    9898  Vector getNormalized() const;
    9999  Vector abs();
     100
    100101  /** @param toVec nears this Vector to... @param t how much to advance (0.0: not at all; 1.0: fully) */
    101102  inline void slerpTo(const Vector& toVec, float t) { *this + (toVec - *this) * t; };
  • branches/osx/src/lib/sound/sound_buffer.cc

    r8122 r8162  
    7373      return false;
    7474    }
    75 #ifdef SDL_BIG_ENDIAN
     75#if SDL_BYTEORDER == SDL_BIG_ENDIAN
    7676                if ( !( wavSpec.format == AUDIO_U8 || wavSpec.format == AUDIO_S8 ) ) {
    7777                        int cnt = wavLength/2;
Note: See TracChangeset for help on using the changeset viewer.