Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8293 in orxonox.OLD for trunk/src/lib


Ignore:
Timestamp:
Jun 8, 2006, 11:11:37 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the osX-branche back here
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/osx . -r7763:HEAD

conflicts resolved, and everything is working as expected (or at least i hope so :) )

Location:
trunk/src/lib
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/Makefile.am

    r7810 r8293  
    5656
    5757
    58 SUBDIRS = importer \
    59           spatial_separation
    60 
     58SUBDIRS =       importer \
     59                spatial_separation
    6160EXTRA_DIST =
  • trunk/src/lib/graphics/importer/md2Model.cc

    r7732 r8293  
    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#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 )
     88#else
     89#define BULK_CONV( _ptr, _num )
     90#define BULK_CONV16( _ptr, _num )
     91#endif 
    6992
    7093/********************************************************************************
     
    80103  /* this creates the data container via ressource manager */
    81104  if (!modelFileName.empty())
    82     this->data = (MD2Data*)ResourceManager::getInstance()->load(modelFileName, MD2, RP_GAME, skinFileName, scale);
     105    this->data = (MD2Data*)ResourceManager::getInstance()->load(
     106                        modelFileName, MD2, RP_GAME, skinFileName, scale);
     107                       
     108        //When arriving here it is assumed that everything is in the correct byte order.       
    83109  if( unlikely(this->data == NULL))
    84110    PRINTF(0)("The model was not found, MD2Model Loader finished abnormaly. Update the data-repos\n");
     
    92118  this->setAnim(STAND);
    93119
    94   this->debug();
     120  //this->debug();
    95121
    96122    //write the modelinfo information
     
    99125  this->pModelInfo.numNormals = 0;
    100126  this->pModelInfo.numTexCoor = this->data->numTexCoor;
     127       
    101128  this->pModelInfo.pVertices = (float*)this->data->pVertices;
     129               
    102130  this->pModelInfo.pNormals = NULL;
     131
    103132  this->pModelInfo.pTexCoor = (float*)this->data->pTexCoor;
    104 
     133       
    105134  // triangle conversion
    106135  this->pModelInfo.pTriangles = new sTriangleExt[this->data->numTriangles];
     
    357386void MD2Model::debug()
    358387{
    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");
     388  //PRINTF(0)("\n==========================| MD2Model::debug() |===\n");
     389  PRINTF(0)("=  Model FileName:\t%s\n", this->data->fileName.c_str());
     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
     394  PRINTF(0)("=  Number of Vertices:\t%i\n", this->data->header->numVertices);
     395  PRINTF(0)("=  Number of Frames: \t%i\n", this->data->header->numFrames);
     396  PRINTF(0)("=  Height, Width:\t%i, %i\n", this->data->header->skinHeight, this->data->header->skinWidth);
     397  PRINTF(0)("=  Pointer to the data object: %p\n", this->data);
     398  //PRINTF(0)("===================================================\n\n");
    368399}
    369400
     
    442473  this->header = new MD2Header;
    443474  fread(this->header, 1, sizeof(MD2Header), pFile);
     475        BULK_CONV( this->header, sizeof(MD2Header)/4 );
    444476  /* 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))
     477  if( unlikely( this->header->version != MD2_VERSION) && unlikely( this->header->ident != MD2_IDENT))
    446478    {
    447479      PRINTF(1)("Couldn't load file %s: invalid file format: stop loading\n", fileName.c_str());
     
    449481    }
    450482
    451   this->fileName =fileName;
     483  this->fileName = fileName;
    452484  /* got the data: map it to locals */
    453485  this->numFrames = this->header->numFrames;
     
    468500  fseek(pFile, this->header->offsetFrames, SEEK_SET);
    469501  fread(buffer, this->header->frameSize, this->numFrames, pFile);
     502        //BULK_CONV( buffer, this->header->frameSize*this->numFrames*sizeof(char)/4 );
    470503  /* read opengl commands */
    471504  fseek(pFile, this->header->offsetGlCommands, SEEK_SET);
     505
    472506  fread(this->pGLCommands, sizeof(int), this->numGLCommands, pFile);
     507        BULK_CONV( this->pGLCommands, this->numGLCommands );
    473508  /* triangle list */
    474509  fseek(pFile, this->header->offsetTriangles, SEEK_SET);
    475   fread(this->pTriangles, sizeof(sTriangle), this->numTriangles, pFile);
     510  fread(this->pTriangles, sizeof(sTriangle), this->numTriangles, pFile);       
     511        BULK_CONV16( this->pTriangles, this->numTriangles*sizeof(sTriangle)/2 );
     512
    476513  /*  read in texture coordinates */
    477514  fseek(pFile, this->header->offsetTexCoords, SEEK_SET);
    478515  fread(this->pTexCoor, sizeof(sTexCoor), this->numTexCoor, pFile);
    479 
     516        BULK_CONV16( this->pTexCoor, this->numTexCoor*sizeof(sTexCoor)/2 );
    480517
    481518  for(int i = 0; i < this->numFrames; ++i)
    482519    {
    483520      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 );
    484524      pVertex = this->pVertices + this->numVertices  * i;
    485525      pNormals = this->pLightNormals + this->numVertices * i;
  • trunk/src/lib/graphics/importer/texture.cc

    r8145 r8293  
    2121#include "compiler.h"
    2222
    23 // INCLUDING SDL_Image
    24 #ifdef HAVE_SDL_IMAGE_H
     23#ifdef HAVE_SDL_SDL_H
     24#include <SDL/SDL_image.h>
     25#include <SDL/SDL_endian.h>
     26#include <SDL/SDL_byteorder.h>
     27#else
     28#include <SDL_endian.h>
    2529#include <SDL_image.h>
     30#include <SDL_byteorder.h>
     31#endif
     32#if SDL_BYTEORDER == SDL_BIG_ENDIAN
     33/*
     34 * On the BIG_ENDIAN architecture, the 24 and 32bit bitmaps have
     35 * different masks. If you don't do this distinction properly,
     36 * you will get weird-looking textures.
     37 */
     38Uint32 alphaMask[] = {
     39        0xFF000000,
     40        0x00FF0000,
     41        0x0000FF00,
     42        0x000000FF,
     43};
     44
     45Uint32 opaqueMask[] = {
     46        0x00FF0000,
     47        0x0000FF00,
     48        0x000000FF,
     49        0xFF000000
     50};
    2651#else
    27 #include <SDL/SDL_image.h>
     52/*
     53 * On the LIL_ENDIAN architecture everything is fine and easy. The 24
     54 * and 32bit bitmaps have the same masks.
     55 */
     56Uint32 alphaMask[] = {
     57        0x000000FF,
     58        0x0000FF00,
     59        0x00FF0000,
     60        0xFF000000,
     61};
     62
     63Uint32 *opaqueMask = alphaMask;
     64
    2865#endif
    29 
    3066
    3167TextureData::TextureData()
     
    251287  Uint32 saved_flags;
    252288  Uint8  saved_alpha;
    253 
    254289  hasAlpha = false;
    255290  int pixelDepth = 24;
    256291
     292        Uint32* mask = opaqueMask;
     293       
    257294  /* Save the alpha blending attributes */
    258295  saved_flags = surface->flags&(SDL_SRCALPHA | SDL_RLEACCELOK);
    259296  saved_alpha = surface->format->alpha;
    260   if ( (saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA )
     297  if ( saved_flags & SDL_SRCALPHA )
    261298  {
    262299    SDL_SetAlpha(surface, 0, 0);
    263300    hasAlpha = true;
    264301    pixelDepth = 32;
    265   }
    266 
     302                mask = alphaMask;
     303  }
     304               
    267305  retSurface = SDL_CreateRGBSurface(SDL_HWSURFACE,
    268306                                    surface->w, surface->h,
    269307                                    pixelDepth,
    270 #if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */
    271                                     0x000000FF,
    272                                     0x0000FF00,
    273                                     0x00FF0000,
    274                                     0xFF000000
    275 #else
    276                                     0xFF000000,
    277                                     0x00FF0000,
    278                                     0x0000FF00,
    279                                     0x000000FF
    280 #endif
    281                                    );
     308                                                                                                                                                mask[0], mask[1], mask[2], mask[3] );
    282309  if ( retSurface == NULL )
    283310    return NULL;
  • trunk/src/lib/graphics/spatial_separation/quadtree.cc

    r5430 r8293  
    2525
    2626using namespace std;
    27 
    2827#define QUADTREE_MATERIAL_COUNT       4
    2928
  • trunk/src/lib/math/vector.h

    r8145 r8293  
    9393  Vector getNormalized() const;
    9494  Vector abs();
     95
    9596  /** @param toVec nears this Vector to... @param t how much to advance (0.0: not at all; 1.0: fully) */
    9697  inline void slerpTo(const Vector& toVec, float t) { *this + (toVec - *this) * t; };
  • trunk/src/lib/sound/ogg_player.cc

    r7849 r8293  
    3131
    3232#include "debug.h"
     33
     34#ifdef HAVE_SDL_SDL_H
     35
     36#include <SDL/SDL.h>
     37#include <SDL/SDL_endian.h>
     38
     39#else
     40
     41#include <SDL.h>
     42#include <SDL_endian.h>
     43
     44#endif
    3345
    3446namespace OrxSound
     
    151163  bool OggPlayer::play()
    152164  {
    153     if (!(this->state & OggPlayer::FileOpened))
     165    /*if (!(this->state & OggPlayer::FileOpened))
    154166      return false;
    155167
     
    161173    if (this->musicThreadID == NULL)
    162174      return ((this->musicThreadID = SDL_CreateThread(OggPlayer::musicThread, (void*)this)) != NULL);
    163     return true;
     175    return true;*/
    164176  }
    165177
     
    385397    if(size == 0)
    386398      return false;
    387 
     399/*#ifdef SDL_BIG_ENDIAN
     400                        int cnt = wavLength/2;
     401                        Uint16* wavBufferAsShorts = ( Uint16* )wavBuffer;
     402                        for ( int i = 0; i < cnt; ++i, ++wavBufferAsShorts )
     403                                *wavBufferAsShorts = SDL_Swap16( *wavBufferAsShorts );
     404#endif*/
    388405    alBufferData(buffer, format, pcm, size, vorbisInfo->rate);
    389406    if (DEBUG_LEVEL >= 3)
  • trunk/src/lib/sound/sound_buffer.cc

    r7460 r8293  
    2222#include "sdlincl.h"
    2323#include <cassert>
    24 
     24#ifdef HAVE_SDL_SDL_H
     25#include <SDL/SDL.h>
     26#include <SDL/SDL_endian.h>
     27#else
     28#include <SDL.h>
     29#include <SDL_endian.h>
     30#endif
    2531namespace OrxSound
    2632{
     
    6773      return false;
    6874    }
    69 
    70     alBufferData(this->bufferID, SoundBuffer::sdlAudioSpecToAlFormat(&wavSpec), wavBuffer, wavLength, wavSpec.freq);
     75#if SDL_BYTEORDER == SDL_BIG_ENDIAN
     76                if ( !( wavSpec.format == AUDIO_U8 || wavSpec.format == AUDIO_S8 ) ) {
     77                        int cnt = wavLength/2;
     78                        Uint16* wavBufferAsShorts = ( Uint16* )wavBuffer;
     79                        for ( int i = 0; i < cnt; ++i, ++wavBufferAsShorts )
     80                                *wavBufferAsShorts = SDL_Swap16( *wavBufferAsShorts );
     81                }
     82#endif
     83    alBufferData(this->bufferID, SoundBuffer::sdlAudioSpecToAlFormat(&wavSpec),
     84                        wavBuffer, wavLength, wavSpec.freq);
     85                       
    7186    SDL_FreeWAV(wavBuffer);
    7287    if (SoundEngine::checkError("Could not load Wave file", __LINE__))
  • trunk/src/lib/util/file.cc

    r8276 r8293  
    2323#include <fstream>
    2424
    25 #ifdef __unix__
     25#ifdef __unix__ 
    2626#include <unistd.h>
    2727#elif __WIN32__ || _MS_DOS_
    2828#include <dir.h>
    2929#else
    30 #include <direct.h>
     30//#include <direct.h>
    3131#endif
    3232
Note: See TracChangeset for help on using the changeset viewer.