Index: trunk/src/lib/graphics/Makefile.am
===================================================================
--- trunk/src/lib/graphics/Makefile.am	(revision 8255)
+++ trunk/src/lib/graphics/Makefile.am	(revision 8293)
@@ -56,6 +56,5 @@
 
 
-SUBDIRS = importer \
-          spatial_separation
-
+SUBDIRS = 	importer \
+          	spatial_separation
 EXTRA_DIST =
Index: trunk/src/lib/graphics/importer/md2Model.cc
===================================================================
--- trunk/src/lib/graphics/importer/md2Model.cc	(revision 8255)
+++ trunk/src/lib/graphics/importer/md2Model.cc	(revision 8293)
@@ -14,5 +14,12 @@
 
 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_IMPORTER
-
+#include "config.h"
+#ifdef HAVE_SDL_SDL_H
+#include <SDL/SDL.h>
+#include <SDL/SDL_endian.h>
+#else
+#include <SDL.h>
+#include <SDL_endian.h>
+#endif
 #include "md2Model.h"
 #include "material.h"
@@ -20,5 +27,4 @@
 #include "debug.h"
 #include "util/loading/resource_manager.h"
-
 
 using namespace std;
@@ -67,4 +73,21 @@
 
 
+#ifdef SDL_LIL_ENDIAN
+#define BULK_CONV( _ptr, _num ) do { \
+	int  _cnt = _num;\
+	int* _iptr = (int*)_ptr;\
+	for( int _l = 0; _l<_cnt; ++_l )\
+		_iptr[_l] = SDL_SwapLE32( _iptr[_l] );\
+} while( 0 )
+#define BULK_CONV16( _ptr, _num ) do { \
+	short  _cnt = _num;\
+	short* _iptr = (short*)_ptr;\
+	for( int _l = 0; _l<_cnt; ++_l )\
+		_iptr[_l] = SDL_SwapLE16( _iptr[_l] );\
+} while( 0 )
+#else
+#define BULK_CONV( _ptr, _num )
+#define BULK_CONV16( _ptr, _num )
+#endif	
 
 /********************************************************************************
@@ -80,5 +103,8 @@
   /* this creates the data container via ressource manager */
   if (!modelFileName.empty())
-    this->data = (MD2Data*)ResourceManager::getInstance()->load(modelFileName, MD2, RP_GAME, skinFileName, scale);
+    this->data = (MD2Data*)ResourceManager::getInstance()->load( 
+			modelFileName, MD2, RP_GAME, skinFileName, scale);
+			
+	//When arriving here it is assumed that everything is in the correct byte order.	
   if( unlikely(this->data == NULL))
     PRINTF(0)("The model was not found, MD2Model Loader finished abnormaly. Update the data-repos\n");
@@ -92,5 +118,5 @@
   this->setAnim(STAND);
 
-  this->debug();
+  //this->debug();
 
     //write the modelinfo information
@@ -99,8 +125,11 @@
   this->pModelInfo.numNormals = 0;
   this->pModelInfo.numTexCoor = this->data->numTexCoor;
+	
   this->pModelInfo.pVertices = (float*)this->data->pVertices;
+		
   this->pModelInfo.pNormals = NULL;
+
   this->pModelInfo.pTexCoor = (float*)this->data->pTexCoor;
-
+	
   // triangle conversion
   this->pModelInfo.pTriangles = new sTriangleExt[this->data->numTriangles];
@@ -357,13 +386,15 @@
 void MD2Model::debug()
 {
-  PRINT(0)("\n==========================| MD2Model::debug() |===\n");
-  PRINT(0)("=  Model FileName:\t%s\n", this->data->fileName.c_str());
-  PRINT(0)("=  Skin FileName:\t%s\n", this->data->skinFileName.c_str());
-  PRINT(0)("=  Size in Memory:\t%i Bytes\n", this->data->header->frameSize * this->data->header->numFrames + 64); // 64bytes is the header size
-  PRINT(0)("=  Number of Vertices:\t%i\n", this->data->header->numVertices);
-  PRINT(0)("=  Number of Frames: \t%i\n", this->data->header->numFrames);
-  PRINT(0)("=  Height, Width:\t%i, %i\n", this->data->header->skinHeight, this->data->header->skinWidth);
-  PRINT(0)("=  Pointer to the data object: %p\n", this->data);
-  PRINT(0)("===================================================\n\n");
+  //PRINTF(0)("\n==========================| MD2Model::debug() |===\n");
+  PRINTF(0)("=  Model FileName:\t%s\n", this->data->fileName.c_str());
+  PRINTF(0)("=  Skin FileName:\t%s\n", 
+		this->data->skinFileName.c_str());
+  PRINTF(0)("=  Size in Memory:\t%i Bytes\n", 
+		this->data->header->frameSize * this->data->header->numFrames + 64); // 64bytes is the header size
+  PRINTF(0)("=  Number of Vertices:\t%i\n", this->data->header->numVertices);
+  PRINTF(0)("=  Number of Frames: \t%i\n", this->data->header->numFrames);
+  PRINTF(0)("=  Height, Width:\t%i, %i\n", this->data->header->skinHeight, this->data->header->skinWidth);
+  PRINTF(0)("=  Pointer to the data object: %p\n", this->data);
+  //PRINTF(0)("===================================================\n\n");
 }
 
@@ -442,6 +473,7 @@
   this->header = new MD2Header;
   fread(this->header, 1, sizeof(MD2Header), pFile);
+	BULK_CONV( this->header, sizeof(MD2Header)/4 );
   /* check for the header version: make sure its a md2 file :) */
-  if( unlikely(this->header->version != MD2_VERSION) && unlikely(this->header->ident != MD2_IDENT))
+  if( unlikely( this->header->version != MD2_VERSION) && unlikely( this->header->ident != MD2_IDENT))
     {
       PRINTF(1)("Couldn't load file %s: invalid file format: stop loading\n", fileName.c_str());
@@ -449,5 +481,5 @@
     }
 
-  this->fileName =fileName;
+  this->fileName = fileName;
   /* got the data: map it to locals */
   this->numFrames = this->header->numFrames;
@@ -468,18 +500,26 @@
   fseek(pFile, this->header->offsetFrames, SEEK_SET);
   fread(buffer, this->header->frameSize, this->numFrames, pFile);
+	//BULK_CONV( buffer, this->header->frameSize*this->numFrames*sizeof(char)/4 );
   /* read opengl commands */
   fseek(pFile, this->header->offsetGlCommands, SEEK_SET);
+
   fread(this->pGLCommands, sizeof(int), this->numGLCommands, pFile);
+	BULK_CONV( this->pGLCommands, this->numGLCommands );
   /* triangle list */
   fseek(pFile, this->header->offsetTriangles, SEEK_SET);
-  fread(this->pTriangles, sizeof(sTriangle), this->numTriangles, pFile);
+  fread(this->pTriangles, sizeof(sTriangle), this->numTriangles, pFile);	
+	BULK_CONV16( this->pTriangles, this->numTriangles*sizeof(sTriangle)/2 );
+
   /*  read in texture coordinates */
   fseek(pFile, this->header->offsetTexCoords, SEEK_SET);
   fread(this->pTexCoor, sizeof(sTexCoor), this->numTexCoor, pFile);
-
+	BULK_CONV16( this->pTexCoor, this->numTexCoor*sizeof(sTexCoor)/2 );
 
   for(int i = 0; i < this->numFrames; ++i)
     {
       frame = (sFrame*)(buffer + this->header->frameSize * i);
+			//Convert the translate and scale Vec3D if needed.
+			BULK_CONV( frame, 6 );
+			BULK_CONV( frame->pVertices, 3 );
       pVertex = this->pVertices + this->numVertices  * i;
       pNormals = this->pLightNormals + this->numVertices * i;
Index: trunk/src/lib/graphics/importer/texture.cc
===================================================================
--- trunk/src/lib/graphics/importer/texture.cc	(revision 8255)
+++ trunk/src/lib/graphics/importer/texture.cc	(revision 8293)
@@ -21,11 +21,47 @@
 #include "compiler.h"
 
-// INCLUDING SDL_Image
-#ifdef HAVE_SDL_IMAGE_H
+#ifdef HAVE_SDL_SDL_H
+#include <SDL/SDL_image.h>
+#include <SDL/SDL_endian.h>
+#include <SDL/SDL_byteorder.h>
+#else
+#include <SDL_endian.h>
 #include <SDL_image.h>
+#include <SDL_byteorder.h>
+#endif
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
+/*
+ * On the BIG_ENDIAN architecture, the 24 and 32bit bitmaps have
+ * different masks. If you don't do this distinction properly, 
+ * you will get weird-looking textures.
+ */
+Uint32 alphaMask[] = {
+	0xFF000000,
+	0x00FF0000,
+	0x0000FF00,
+	0x000000FF,
+};
+
+Uint32 opaqueMask[] = {
+	0x00FF0000,
+	0x0000FF00,
+	0x000000FF,
+	0xFF000000
+};
 #else
-#include <SDL/SDL_image.h>
+/*
+ * On the LIL_ENDIAN architecture everything is fine and easy. The 24
+ * and 32bit bitmaps have the same masks.
+ */
+Uint32 alphaMask[] = {
+	0x000000FF,
+	0x0000FF00,
+	0x00FF0000,
+	0xFF000000,
+};
+
+Uint32 *opaqueMask = alphaMask;
+
 #endif
-
 
 TextureData::TextureData()
@@ -251,33 +287,24 @@
   Uint32 saved_flags;
   Uint8  saved_alpha;
-
   hasAlpha = false;
   int pixelDepth = 24;
 
+	Uint32* mask = opaqueMask;
+	
   /* Save the alpha blending attributes */
   saved_flags = surface->flags&(SDL_SRCALPHA | SDL_RLEACCELOK);
   saved_alpha = surface->format->alpha;
-  if ( (saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA )
+  if ( saved_flags & SDL_SRCALPHA )
   {
     SDL_SetAlpha(surface, 0, 0);
     hasAlpha = true;
     pixelDepth = 32;
-  }
-
+		mask = alphaMask;
+  }
+		
   retSurface = SDL_CreateRGBSurface(SDL_HWSURFACE,
                                     surface->w, surface->h,
                                     pixelDepth,
-#if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */
-                                    0x000000FF,
-                                    0x0000FF00,
-                                    0x00FF0000,
-                                    0xFF000000
-#else
-                                    0xFF000000,
-                                    0x00FF0000,
-                                    0x0000FF00,
-                                    0x000000FF
-#endif
-                                   );
+																		mask[0], mask[1], mask[2], mask[3] );
   if ( retSurface == NULL )
     return NULL;
Index: trunk/src/lib/graphics/spatial_separation/quadtree.cc
===================================================================
--- trunk/src/lib/graphics/spatial_separation/quadtree.cc	(revision 8255)
+++ trunk/src/lib/graphics/spatial_separation/quadtree.cc	(revision 8293)
@@ -25,5 +25,4 @@
 
 using namespace std;
-
 #define QUADTREE_MATERIAL_COUNT       4
 
