Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9140 in orxonox.OLD


Ignore:
Timestamp:
Jul 4, 2006, 3:06:00 PM (18 years ago)
Author:
bensch
Message:

merged back

Location:
branches/terrain/src
Files:
2 deleted
25 edited
14 copied

Legend:

Unmodified
Added
Removed
  • branches/terrain/src/defs/debug.h

    r8282 r9140  
    111111#define PRINTFORX_VDEBUG  PRINTF5
    112112
     113#ifndef ORX_DATADIR
     114#define ORX_DATADIR "/usr/share"
     115#endif
     116#ifndef DEBUG_LEVEL
     117#define DEBUG_LEVEL 2
     118#endif
    113119#if DEBUG_LEVEL <= 3
    114120#define PRINTF(x)        PRINT(x)
  • branches/terrain/src/defs/glincl.h

    r5279 r9140  
    1717#include <OpenGL/gl.h>
    1818#include <OpenGL/glu.h>
     19#include <OpenGL/glext.h>
    1920#endif
    2021
  • branches/terrain/src/lib/collision_detection/cd_engine.cc

    r9110 r9140  
    2424#include "model.h"
    2525#include "world_entity.h"
    26 #include "terrain.h"
     26#include "terrain_entity.h"
    2727// #include "player.h"
    2828
     
    4545
    4646  this->bAbordOnFirstCollision = false;
    47  
     47
    4848  this->terrain = NULL;
    4949}
     
    106106  std::list<WorldEntity*>::iterator entityIterator;
    107107  const std::list<BaseObject*>* bspList = ClassList::getList(CL_BSP_ENTITY);
    108   if( bspList == NULL)
    109     return;
     108  if( bspList != NULL)
     109  {
    110110
    111   // for all bsp managers check all entities
    112   for( bspIterator = bspList->begin(); bspIterator != bspList->end(); bspIterator++) {
     111    // for all bsp managers check all entities
     112    for( bspIterator = bspList->begin(); bspIterator != bspList->end(); bspIterator++)
     113    {
    113114      for(entityIterator = list1.begin(); entityIterator != list1.end(); entityIterator++)
    114115      {
    115 //         PRINTF(0)("Checking: %s a %s\n", (*entityIterator)->getName(), (*entityIterator)->getClassName());
     116        //               PRINTF(0)("Checking: %s a %s\n", (*entityIterator)->getName(), (*entityIterator)->getClassName());
    116117        (dynamic_cast<BspEntity*>(*bspIterator)->getBspManager())->checkCollision(*entityIterator);
    117118      }
     119    }
    118120  }
     121
     122  /// COLLISION OF THE Modular-TERRAIN
     123/*  const std::list<BaseObject*>* tl = ClassList::getList( CL_TERRAIN );
     124  std::list<BaseObject*>::const_iterator ti;
     125  if ( tl == NULL )
     126    return;
     127  float offset = 8.0f;
     128  for ( ti = tl->begin(); ti != tl->end(); ++ti )
     129  {
     130    TerrainEntity* terrain = dynamic_cast<TerrainEntity*>( *ti );
     131    for( entityIterator = list1.begin(); entityIterator != list1.end(); entityIterator++ )
     132    {
     133      Vector pos( (*entityIterator)->getAbsCoor() );
     134      Vector normal;
     135      float height = pos.y;
     136      terrain->getAltitude( pos, normal );
     137      if ( height-offset < pos.y )
     138      {
     139        ( *entityIterator )->registerCollision(
     140          *entityIterator, terrain, pos, normal );
     141      }
     142    }
     143  }*/
    119144}
    120145
     
    138163void CDEngine::debugSpawnTree(int depth, sVec3D* vertices, int numVertices)
    139164{
    140 //   if ( this->rootTree == NULL)
    141 //     this->rootTree = new OBBTree(depth, vertices, numVertices);
     165  //   if ( this->rootTree == NULL)
     166  //     this->rootTree = new OBBTree(depth, vertices, numVertices);
    142167}
    143168
     
    156181void CDEngine::debugDraw(int depth, int drawMode)
    157182{
    158 //   if(this-> rootTree != NULL)
    159 //     this->rootTree->drawBV(depth, drawMode);
     183  //   if(this-> rootTree != NULL)
     184  //     this->rootTree->drawBV(depth, drawMode);
    160185}
  • branches/terrain/src/lib/collision_detection/cd_engine.h

    r8186 r9140  
    1616class WorldEntity;
    1717class OBBTree;
    18 class Terrain;
     18class TerrainEntity;
    1919class BspManager;
    2020//class Player;
     
    5050  inline void disable(const int options) { int temp = this->state & options; this->state ^= temp; }
    5151
    52   inline void setTerrain(Terrain* terrain) { this->terrain = terrain; }
     52  inline void setTerrain( TerrainEntity* terrain) { this->terrain = terrain; }
    5353  inline void setBSPModel(BspManager* bspManager) { this->bspManager = bspManager; }
    5454
     
    8383  OBBTree*                rootTree;                         //!< for testing purposes a root tree
    8484
    85   Terrain*                terrain;                          //!< this it a ref to the terrain, serving as a ground for all WE
     85  TerrainEntity*                terrain;                          //!< this it a ref to the terrain, serving as a ground for all WE
    8686  BspManager*             bspManager;
    8787};
  • branches/terrain/src/lib/graphics/effects/volfog_effect.cc

    r9006 r9140  
    3030//#include <GL/glext.h> //OpenGL Extensions
    3131//#include <GL/glxext.h> // GLX Extensions
    32 
     32#ifndef __APPLE__
    3333#ifndef GL_EXT_fog_coord
    3434#define GL_EXT_fog_coord 1
     
    4545PFNGLFOGCOORDDVEXTPROC glFogCoorddvEXT = 0;
    4646PFNGLFOGCOORDPOINTEREXTPROC glFogCoordPointerEXT = 0;
    47 
     47#endif
    4848
    4949using namespace std;
  • branches/terrain/src/lib/graphics/graphics_engine.cc

    r8740 r9140  
    236236  // Enable default GL stuff
    237237  glEnable(GL_DEPTH_TEST);
    238 
     238  glEnable(GL_CULL_FACE);
     239  glCullFace(GL_FRONT);
    239240  Render2D::getInstance();
    240241
     
    297298  }
    298299
    299   glEnable(GL_CULL_FACE);
    300   glCullFace(GL_FRONT);
     300
    301301}
    302302
  • branches/terrain/src/lib/graphics/importer/Makefile.am

    r8724 r9140  
    3838                           md3/md3_mesh.cc \
    3939                           md3/md3_data.cc \
    40                            md3/md3_tag.cc
    41 
    42 
     40                           md3/md3_tag.cc \
     41                           \
     42                           terrain/terrain.cc \
     43                           terrain/terrain_quad.cc \
     44                           terrain/terrain_page.cc \
     45                           terrain/frustum.cc \
     46                           terrain/buffer_broker.cc
    4347
    4448
     
    8185                md3/md3_mesh.h \
    8286                md3/md3_data.h \
    83                 md3/md3_tag.h
     87                md3/md3_tag.h \
     88                \
     89                terrain/terrain.h \
     90                terrain/terrain_page.h \
     91                terrain/terrain_quad.h \
     92                terrain/frustum.h \
     93                terrain/types.h \
     94                terrain/buffer_broker.h
    8495
  • branches/terrain/src/lib/graphics/importer/material.h

    r8761 r9140  
    6161  void setSpecularMap(const std::string& sMap, GLenum target = GL_TEXTURE_2D);
    6262  void setBump(const std::string& bump);
    63 
    6463  GLuint diffuseTextureID(unsigned int i = 0) const { return (this->textures.size() > i)? this->textures[i].getTexture() : 0; };
    6564
  • branches/terrain/src/lib/graphics/importer/md2/md2Model.cc

    r9003 r9140  
    1717#include "md2Model.h"
    1818#include "material.h"
    19 
     19#include "config.h"
     20#ifdef HAVE_SDL_SDL_H
     21#include <SDL/SDL.h>
     22#include <SDL/SDL_endian.h>
     23#else
     24#include <SDL.h>
     25#include <SDL_endian.h>
     26#endif
    2027#include "debug.h"
    2128#include "util/loading/resource_manager.h"
     
    6673  };
    6774
    68 
     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/********************************************************************************
     
    467490  this->header = new MD2Header;
    468491  fread(this->header, 1, sizeof(MD2Header), pFile);
     492        BULK_CONV( this->header, sizeof(MD2Header)/4 );
    469493  /* check for the header version: make sure its a md2 file :) */
    470   if( unlikely(this->header->version != MD2_VERSION) && unlikely(this->header->ident != MD2_IDENT))
     494  if( unlikely( this->header->version != MD2_VERSION) && unlikely( this->header->ident != MD2_IDENT))
    471495    {
    472496      PRINTF(1)("Couldn't load file %s: invalid file format: stop loading\n", fileName.c_str());
     
    474498    }
    475499
    476   this->fileName =fileName;
     500  this->fileName = fileName;
    477501  /* got the data: map it to locals */
    478502  this->numFrames = this->header->numFrames;
     
    493517  fseek(pFile, this->header->offsetFrames, SEEK_SET);
    494518  fread(buffer, this->header->frameSize, this->numFrames, pFile);
     519        //BULK_CONV( buffer, this->header->frameSize*this->numFrames*sizeof(char)/4 );
    495520  /* read opengl commands */
    496521  fseek(pFile, this->header->offsetGlCommands, SEEK_SET);
     522
    497523  fread(this->pGLCommands, sizeof(int), this->numGLCommands, pFile);
     524        BULK_CONV( this->pGLCommands, this->numGLCommands );
    498525  /* triangle list */
    499526  fseek(pFile, this->header->offsetTriangles, SEEK_SET);
    500   fread(this->pTriangles, sizeof(sTriangle), this->numTriangles, pFile);
     527  fread(this->pTriangles, sizeof(sTriangle), this->numTriangles, pFile);       
     528        BULK_CONV16( this->pTriangles, this->numTriangles*sizeof(sTriangle)/2 );
     529
    501530  /*  read in texture coordinates */
    502531  fseek(pFile, this->header->offsetTexCoords, SEEK_SET);
    503532  fread(this->pTexCoor, sizeof(sTexCoor), this->numTexCoor, pFile);
    504 
     533        BULK_CONV16( this->pTexCoor, this->numTexCoor*sizeof(sTexCoor)/2 );
    505534
    506535  for(int i = 0; i < this->numFrames; ++i)
    507536    {
    508537      frame = (sFrame*)(buffer + this->header->frameSize * i);
     538                        //Convert the translate and scale Vec3D if needed.
     539                        BULK_CONV( frame, 6 );
     540                        BULK_CONV( frame->pVertices, 3 );
    509541      pVertex = this->pVertices + this->numVertices  * i;
    510542      pNormals = this->pLightNormals + this->numVertices * i;
  • branches/terrain/src/lib/graphics/importer/md3/md3_data.h

    r8724 r9140  
    7070  };
    7171
    72 
    7372  //! class to store the md2 data in
    7473  class MD3Data : public BaseObject
  • branches/terrain/src/lib/graphics/importer/terrain/buffer_broker.h

    r9135 r9140  
    11/*
    2         orxonox - the future of 3D-vertical-scrollers
    3  
    4         Copyright (C) 2006 orx
    5  
    6         This program is free software; you can redistribute it and/or modify
    7         it under the terms of the GNU General Public License as published by
    8         the Free Software Foundation; either version 2, or (at your option)
    9         any later version.
    10  
    11         ### File Specific:
    12         main programmer: Marco Biasini
     2        orxonox - the future of 3D-vertical-scrollers
     3
     4        Copyright (C) 2006 orx
     5
     6        This program is free software; you can redistribute it and/or modify
     7        it under the terms of the GNU General Public License as published by
     8        the Free Software Foundation; either version 2, or (at your option)
     9        any later version.
     10
     11        ### File Specific:
     12        main programmer: Marco Biasini
    1313
    1414 */
     
    2121#include "types.h"
    2222/**
    23  * @brief       Manages the streaming of the vertex buffer objects for the terrain page.
     23 * @brief       Manages the streaming of the vertex buffer objects for the terrain page.
    2424 */
    2525
    2626struct BufferPair {
    27         BufferPair( int _i, int _v ) { indexName = _i; vertexName = _v; next = NULL; }
    28         BufferPair() { indexName = vertexName = 0; next = NULL; }
    29         GLuint                  indexName;     
    30         GLuint                  vertexName;
    31         BufferPair              *next;
     27        BufferPair( int _i, int _v ) { indexName = _i; vertexName = _v; next = NULL; }
     28        BufferPair() { indexName = vertexName = 0; next = NULL; }
     29        GLuint                  indexName;
     30        GLuint                  vertexName;
     31        BufferPair              *next;
    3232};
    3333
     
    3535
    3636class BufferBroker {
    37         public:
    38                
    39                 BufferBroker( int _num, int _vbSize, int _ibSize )
    40                 {
    41                         capacity = _num;
    42                         freeIndexBuffers = new GLuint[capacity];
    43                         freeVertexBuffers =     new GLuint[capacity];
    44                         lastAcquired = 0;
    45                         vbSize = _vbSize; ibSize = _ibSize;
    46                         glGenBuffersARB( capacity, freeIndexBuffers );
    47                         glGenBuffersARB( capacity, freeVertexBuffers );
    48                         for ( int i = 0; i < capacity; ++i ) {
    49                                 glBindBufferARB( GL_ARRAY_BUFFER_ARB, freeVertexBuffers[i] );
    50                                 glBufferDataARB( GL_ARRAY_BUFFER_ARB, vbSize,
    51                                         NULL, GL_DYNAMIC_DRAW_ARB );
    52                                 glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, freeIndexBuffers[i] );
    53                                 glBufferDataARB( GL_ELEMENT_ARRAY_BUFFER_ARB, ibSize,
    54                                         NULL, GL_DYNAMIC_DRAW_ARB );           
    55                         }
    56                         head = tail = NULL;
    57                 }
    58                 ~BufferBroker()
    59                 {
    60                         pBufferPair bp = head;
    61                         while ( bp ) {
    62                                 pBufferPair tmp = bp->next;
    63                                 release( bp->vertexName, bp->indexName );
    64                                 bp = tmp;
    65                         }
    66                         glDeleteBuffersARB( capacity, freeVertexBuffers );
    67                         glDeleteBuffersARB( capacity, freeIndexBuffers );
    68                         SAVE_DELETE_ARRAY( freeIndexBuffers );
    69                         SAVE_DELETE_ARRAY( freeVertexBuffers );                 
    70                 }
    71                 inline int getIBSize() { return ibSize; }
    72                 inline int getVBSize() { return vbSize; }               
    73                 inline void acquire( GLuint &_vbName, GLuint &_ibName );
    74                
    75                 inline void release( const GLuint &_vbName, const GLuint &_ibName );
    76         protected:
     37        public:
    7738
    78                 int                                             capacity;
    79                
    80                 int                                             vbSize,
    81                                                                 ibSize;
    82                 int                                             lastAcquired;
    83                
    84                 GLuint                                  *freeIndexBuffers,
    85                                                                 *freeVertexBuffers;                                             
    86                                                                
    87                 BufferPair                              *head, *tail;
     39                BufferBroker( int _num, int _vbSize, int _ibSize )
     40                {
     41                        capacity = _num;
     42                        freeIndexBuffers = new GLuint[capacity];
     43                        freeVertexBuffers =     new GLuint[capacity];
     44                        lastAcquired = 0;
     45                        vbSize = _vbSize; ibSize = _ibSize;
     46                        glGenBuffersARB( capacity, freeIndexBuffers );
     47                        glGenBuffersARB( capacity, freeVertexBuffers );
     48                        for ( int i = 0; i < capacity; ++i ) {
     49                                glBindBufferARB( GL_ARRAY_BUFFER_ARB, freeVertexBuffers[i] );
     50                                glBufferDataARB( GL_ARRAY_BUFFER_ARB, vbSize,
     51                                        NULL, GL_DYNAMIC_DRAW_ARB );
     52                                glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, freeIndexBuffers[i] );
     53                                glBufferDataARB( GL_ELEMENT_ARRAY_BUFFER_ARB, ibSize,
     54                                        NULL, GL_DYNAMIC_DRAW_ARB );
     55                        }
     56                        head = tail = NULL;
     57                }
     58                ~BufferBroker()
     59                {
     60                        pBufferPair bp = head;
     61                        while ( bp ) {
     62                                pBufferPair tmp = bp->next;
     63                                release( bp->vertexName, bp->indexName );
     64                                bp = tmp;
     65                        }
     66                        glDeleteBuffersARB( capacity, freeVertexBuffers );
     67                        glDeleteBuffersARB( capacity, freeIndexBuffers );
     68                        SAVE_DELETE_ARRAY( freeIndexBuffers );
     69                        SAVE_DELETE_ARRAY( freeVertexBuffers );
     70                }
     71                inline int getIBSize() { return ibSize; }
     72                inline int getVBSize() { return vbSize; }
     73                inline void acquire( GLuint &_vbName, GLuint &_ibName );
     74
     75                inline void release( const GLuint &_vbName, const GLuint &_ibName );
     76        protected:
     77
     78                int                                             capacity;
     79
     80                int                                             vbSize,
     81                                                                ibSize;
     82                int                                             lastAcquired;
     83
     84                GLuint                                  *freeIndexBuffers,
     85                                                                *freeVertexBuffers;
     86
     87                BufferPair                              *head, *tail;
    8888};
    8989
    9090inline void BufferBroker::release( const GLuint &_vbName, const GLuint &_ibName )
    9191{
    92         pBufferPair bp = head, prev = NULL;
    93         bool removed = false;
    94         while ( bp ) {
     92        pBufferPair bp = head, prev = NULL;
     93        bool removed = false;
     94        while ( bp ) {
    9595
    96                 if ( bp->indexName == _ibName && bp->vertexName == _vbName ) {
    97                         if ( prev ) {
    98                                 prev->next = bp->next;                                 
    99                         }
    100                         else {
    101                                 head = bp->next;
    102                         }
    103                         if ( bp->next == NULL )
    104                                 tail = prev;
    105                         int index = capacity-lastAcquired;
    106                         lastAcquired--;
    107                         freeIndexBuffers[index] = bp->indexName;
    108                         freeVertexBuffers[index] = bp->vertexName;
    109                         delete bp;
    110                         removed = true;
    111                         break; 
    112                 }
    113                 prev = bp;
    114                 bp = bp->next;
    115         }
    116         assert( removed );
     96                if ( bp->indexName == _ibName && bp->vertexName == _vbName ) {
     97                        if ( prev ) {
     98                                prev->next = bp->next;
     99                        }
     100                        else {
     101                                head = bp->next;
     102                        }
     103                        if ( bp->next == NULL )
     104                                tail = prev;
     105                        int index = capacity-lastAcquired;
     106                        lastAcquired--;
     107                        freeIndexBuffers[index] = bp->indexName;
     108                        freeVertexBuffers[index] = bp->vertexName;
     109                        delete bp;
     110                        removed = true;
     111                        break;
     112                }
     113                prev = bp;
     114                bp = bp->next;
     115        }
     116        assert( removed );
    117117}
    118118
    119119inline void BufferBroker::acquire( GLuint &_vbName, GLuint &_ibName )
    120120{
    121         assert( capacity > lastAcquired );
    122         int index = capacity-lastAcquired-1;
    123         _vbName = freeVertexBuffers[index]; _ibName = freeIndexBuffers[index];
    124         lastAcquired++;
    125         if ( tail ) {
    126                 tail->next = new BufferPair( _ibName, _vbName );
    127                 tail = tail->next;
    128         }
    129         else {
    130                 tail = head = new BufferPair( _ibName, _vbName );       
    131         }
     121        assert( capacity > lastAcquired );
     122        int index = capacity-lastAcquired-1;
     123        _vbName = freeVertexBuffers[index]; _ibName = freeIndexBuffers[index];
     124        lastAcquired++;
     125        if ( tail ) {
     126                tail->next = new BufferPair( _ibName, _vbName );
     127                tail = tail->next;
     128        }
     129        else {
     130                tail = head = new BufferPair( _ibName, _vbName );
     131        }
    132132}
    133133
  • branches/terrain/src/lib/graphics/importer/terrain/types.h

    r9135 r9140  
    11/*
    2         orxonox - the future of 3D-vertical-scrollers
    3  
    4         Copyright (C) 2006 orx
    5  
    6         This program is free software; you can redistribute it and/or modify
    7         it under the terms of the GNU General Public License as published by
    8         the Free Software Foundation; either version 2, or (at your option)
    9         any later version.
    10  
    11         ### File Specific:
    12         main programmer: Marco Biasini
    13         This files needs to be removed after code-revision...
     2        orxonox - the future of 3D-vertical-scrollers
     3
     4        Copyright (C) 2006 orx
     5
     6        This program is free software; you can redistribute it and/or modify
     7        it under the terms of the GNU General Public License as published by
     8        the Free Software Foundation; either version 2, or (at your option)
     9        any later version.
     10
     11        ### File Specific:
     12        main programmer: Marco Biasini
     13        This files needs to be removed after code-revision...
    1414 */
    15 #ifndef TYPES_H
    16 #define TYPES_H
     15#ifndef _TYPES_H
     16#define _TYPES_H
    1717
    1818#ifndef NULL
     
    2121#include <math.h>
    2222#include "texture.h"
     23#include "plane.h"
    2324
    2425#define SAVE_DELETE_ARRAY( _a ) if ( _a ) { delete[] _a; _a = NULL; }
    2526#define SAVE_DELETE( _a ) if ( _a ) { delete _a; _a = NULL; }
    2627
    27 struct Triple {
    28         Triple( float _x, float _y, float _z )
    29         {
    30                 x = _x; y = _y; z = _z;
    31         }
    32         Triple() { x = y = z = 0.0f; }
    33         inline float length() const
    34         { return sqrt( x*x+y*y+z*z ); }
    35         float x, y, z;
     28struct Triple
     29{
     30  Triple( float _x, float _y, float _z )
     31  {
     32    x = _x; y = _y; z = _z;
     33  }
     34  Triple() { x = y = z = 0.0f; }
     35  inline float length() const
     36    { return sqrt( x*x+y*y+z*z ); }
     37  float x, y, z;
    3638};
    3739
    38 struct TexCoord {
    39         TexCoord( float _u, float _v )
    40         {
    41                 u = _u; v = _v;
    42         }
    43         TexCoord() { u = v = 0.0f; }
    44         float u, v;
     40struct TexCoord
     41{
     42  TexCoord( float _u, float _v )
     43  {
     44    u = _u; v = _v;
     45  }
     46  TexCoord() { u = v = 0.0f; }
     47  float u, v;
    4548};
    4649
     
    4851 * Defines an axis aligned box.
    4952 */
    50 struct ABox {
    51        
    52         ABox( Triple _min, Triple _max)
    53         {
    54                 corner = _min;
    55                 x = _max.x-_min.x;
    56                 y = _max.y-_min.y;
    57                 z = _max.z-_min.z;
    58         }
    59        
    60         ABox()
    61         {
    62                 corner = Triple( 0.0f, 0.0f, 0.0f );
    63                 x = y = z = 0.0f;
    64         }
    65         inline void set( const Triple& _min, const Triple& _max )
    66         {
    67                 setMin( _min ); setMax( _max );
    68         }
    69         inline void setMax( const Triple& _max )
    70         {
    71                 x = _max.x-corner.x;
    72                 y = _max.y-corner.y;
    73                 z = _max.z-corner.z;
    74         }
    75         inline void setMin( const Triple& _min )
    76         {
    77                 corner = _min;
    78         }
    79         inline Triple vertexP( const Triple& _normal ) const
    80         {
    81                 Triple res = corner;
    82                 if ( _normal.x > 0 )
    83                         res.x+= x;
    84                 if ( _normal.y > 0 )
    85                         res.y+= y;
    86                 if ( _normal.z > 0 )
    87                         res.z+= z;                     
    88                        
    89                 return res;
    90         }
    91         inline Triple vertexN( const Triple& _normal ) const
    92         {               
    93                 Triple res = corner;
    94                 if ( _normal.x < 0 )
    95                         res.x+= x;
    96                 if ( _normal.y < 0 )
    97                         res.y+= y;
    98                 if ( _normal.z < 0 )
    99                         res.z+= z;                     
    100                        
    101                 return res;
    102        
    103         }
    104         inline Triple min() const { return Triple(corner); }
    105         inline Triple max() const { return Triple( corner.x+x, corner.y+y, corner.z+z ); }
    106         Triple corner;
    107         float x, y, z;
    108        
     53struct ABox
     54{
     55
     56  ABox( Triple _min, Triple _max)
     57  {
     58    corner = _min;
     59    x = _max.x-_min.x;
     60    y = _max.y-_min.y;
     61    z = _max.z-_min.z;
     62  }
     63
     64  ABox()
     65  {
     66    corner = Triple( 0.0f, 0.0f, 0.0f );
     67    x = y = z = 0.0f;
     68  }
     69  inline void set( const Triple& _min, const Triple& _max )
     70  {
     71    setMin( _min ); setMax( _max );
     72  }
     73  inline void setMax( const Triple& _max )
     74  {
     75    x = _max.x-corner.x;
     76    y = _max.y-corner.y;
     77    z = _max.z-corner.z;
     78  }
     79  inline void setMin( const Triple& _min )
     80  {
     81    corner = _min;
     82  }
     83  inline Triple vertexP( const Triple& _normal ) const
     84  {
     85    Triple res = corner;
     86    if ( _normal.x > 0 )
     87      res.x+= x;
     88    if ( _normal.y > 0 )
     89      res.y+= y;
     90    if ( _normal.z > 0 )
     91      res.z+= z;
     92
     93    return res;
     94  }
     95  inline Triple vertexN( const Triple& _normal ) const
     96  {
     97    Triple res = corner;
     98    if ( _normal.x < 0 )
     99      res.x+= x;
     100    if ( _normal.y < 0 )
     101      res.y+= y;
     102    if ( _normal.z < 0 )
     103      res.z+= z;
     104
     105    return res;
     106
     107  }
     108inline Triple min() const { return Triple(corner); }
     109  inline Triple max() const { return Triple( corner.x+x, corner.y+y, corner.z+z ); }
     110  Triple corner;
     111  float x, y, z;
     112
    109113};
    110114
    111 struct Plane {
    112         Plane() { n = Triple( 0.0f, 1.0f, 0.0f ); d = 0.0f; }
    113         inline void setCoefficients( float _nx, float _ny, float _nz, float _d )
    114         {
    115                 n = Triple( _nx, _ny, _nz );
    116                 float l = n.length();
    117                 n.x /= l; n.y/=l; n.z/=l;
    118                 d = _d/l;
    119         }
    120         inline float distance( const Triple& _point ) const
    121         {
    122                 return _point.x*n.x+_point.y*n.y+_point.z*n.z+d;
    123         }
    124         Triple n;
    125         float d;
    126 };
     115// struct Plane
     116// {
     117//   Plane() { n = Triple( 0.0f, 1.0f, 0.0f ); d = 0.0f; }
     118//   inline void setCoefficients( float _nx, float _ny, float _nz, float _d )
     119//   {
     120//     n = Triple( _nx, _ny, _nz );
     121//     float l = n.length();
     122//     n.x /= l; n.y/=l; n.z/=l;
     123//     d = _d/l;
     124//   }
     125//   inline float distance( const Triple& _point ) const
     126//   {
     127//     return _point.x*n.x+_point.y*n.y+_point.z*n.z+d;
     128//   }
     129//   Triple n;
     130//   float d;
     131// };
    127132
    128133/**
    129134 * TODO: Replace this method with the actual matrix multiplication code!
    130135 */
    131 inline void multMat(float *res,float *a, float *b) {
     136inline void multMat(float *res,float *a, float *b)
     137{
    132138
    133139
    134         for (int i=0;i<4;i++) {
    135                 for (int j = 0;j < 4;j++) {
    136                         res[i*4+j] = 0.0;
    137                         for (int k = 0; k < 4; k++) {
    138                                 res[i*4+j] += a[i*4+k] * b[k*4+j];
    139                         }
    140                 }
    141         }
     140  for (int i=0;i<4;i++)
     141  {
     142    for (int j = 0;j < 4;j++)
     143    {
     144      res[i*4+j] = 0.0;
     145      for (int k = 0; k < 4; k++)
     146      {
     147        res[i*4+j] += a[i*4+k] * b[k*4+j];
     148      }
     149    }
     150  }
    142151}
    143152typedef unsigned char UByte;
    144 struct Heightfield {
    145         int                     width;
    146         int                     height;
    147         int                             pitch;
    148         UByte                   *data;
    149         Heightfield() { data = NULL; width=0;height=0;pitch=0;}
     153struct Heightfield
     154{
     155  int                     width;
     156  int                     height;
     157  int                             pitch;
     158  UByte                   *data;
     159  Heightfield() { data = NULL; width=0;height=0;pitch=0;}
    150160};
    151161
    152 struct LayerInfo {
     162struct LayerInfo
     163{
    153164
    154         int                             envmode;
    155         float                   repeatX,
    156                                         repeatZ;
    157         Texture                 *alpha;
    158         Texture                 *detail;
    159        
     165  int                             envmode;
     166  float                   repeatX,
     167  repeatZ;
     168  Texture                 *alpha;
     169  Texture                 *detail;
     170
    160171};
    161172typedef enum { LV_FULL, LV_PARTIAL, LV_NO } LayerVisibility;
    162173
    163 struct BufferInfo {
    164        
    165         BufferInfo( unsigned int _vb, unsigned int _ib,
    166                 unsigned int _numV, unsigned int _numI )
    167         {
    168                 vbIdentifier = _vb; ibIdentifier = _ib;
    169                 numIndices = _numI; numVertices =_numV;
    170                
    171         }
    172        
    173         BufferInfo()
    174         {
    175                 vbIdentifier = ibIdentifier = numIndices = numVertices = 0;
    176         }
    177         unsigned int    vbIdentifier,
    178                                         ibIdentifier,
    179                                         numIndices,
    180                                         numVertices;   
     174struct BufferInfo
     175{
     176
     177  BufferInfo( unsigned int _vb, unsigned int _ib,
     178              unsigned int _numV, unsigned int _numI )
     179  {
     180    vbIdentifier = _vb; ibIdentifier = _ib;
     181    numIndices = _numI; numVertices =_numV;
     182
     183  }
     184
     185  BufferInfo()
     186  {
     187    vbIdentifier = ibIdentifier = numIndices = numVertices = 0;
     188  }
     189  unsigned int    vbIdentifier,
     190  ibIdentifier,
     191  numIndices,
     192  numVertices;
    181193};
    182194#endif
  • branches/terrain/src/lib/graphics/importer/texture.cc

    r8761 r9140  
    332332  else
    333333  {
    334     assert(surface->format->BitsPerPixel == 24);
     334    //assert(surface->format->BitsPerPixel == 24);
    335335  }
    336336
  • branches/terrain/src/lib/sound/ogg_player.cc

    r9019 r9140  
    402402    if(size == 0)
    403403      return false;
    404 /*#ifdef SDL_BIG_ENDIAN
    405                         int cnt = wavLength/2;
    406                         Uint16* wavBufferAsShorts = ( Uint16* )wavBuffer;
    407                         for ( int i = 0; i < cnt; ++i, ++wavBufferAsShorts )
    408                                 *wavBufferAsShorts = SDL_Swap16( *wavBufferAsShorts );
    409 #endif*/
     404#ifdef SDL_BIG_ENDIAN
     405        int cnt = OGG_PLAYER_BUFFER_SIZE/2;
     406        Uint16* wavBufferAsShorts = ( Uint16* )pcm;
     407        for ( int i = 0; i < cnt; ++i, ++wavBufferAsShorts )
     408                *wavBufferAsShorts = SDL_Swap16( *wavBufferAsShorts );
     409#endif
    410410    alBufferData(buffer, format, pcm, size, vorbisInfo->rate);
    411411    if (DEBUG_LEVEL >= 3)
  • branches/terrain/src/lib/util/threading.h

    r7847 r9140  
    1414 #include <SDL/SDL_thread.h>
    1515#endif
    16 
     16#include <string>
    1717namespace OrxThread
    1818{
     
    3131    void start();
    3232    void terminate();
    33 
    34 
    3533  private:
    3634    SDL_Thread* thread;
  • branches/terrain/src/orxonox.cc

    r8750 r9140  
    2727#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_ORXONOX
    2828#include "orxonox.h"
    29 
    3029#include "globals.h"
    3130
     
    519518  // checking for existence of the configuration-files, or if the lock file is still used
    520519  if (showGui || (!File("./orxonox.conf").isFile() &&
    521                   !File(DEFAULT_CONFIG_FILE).isFile())
    522 #if DEBUG_LEVEL <= 3 // developers do not need to see the GUI, when orxonox fails
    523       || ResourceManager::isFile(DEFAULT_LOCK_FILE)
    524 #endif
    525      )
     520                  !File(DEFAULT_CONFIG_FILE).isFile() ) )
    526521  {
    527522    File lockFile(DEFAULT_LOCK_FILE);
  • branches/terrain/src/story_entities/game_world.cc

    r9110 r9140  
    3030#include "camera.h"
    3131#include "environment.h"
    32 #include "terrain.h"
    3332#include "test_entity.h"
    34 #include "terrain.h"
     33#include "terrain_entity.h"
    3534#include "playable.h"
    3635#include "environments/mapped_water.h"
  • branches/terrain/src/story_entities/game_world_data.cc

    r9019 r9140  
    3131#include "player.h"
    3232#include "camera.h"
    33 #include "terrain.h"
     33#include "terrain_entity.h"
    3434#include "skybox.h"
    3535#include "md2/md2Model.h"
     
    209209      BaseObject* created = Factory::fabricate(element);
    210210      if( created != NULL )
    211         PRINTF(4)("Created a %s: %s\n", created->getClassName(), created->getName());
     211        PRINTF(2)("Created a %s: %s\n", created->getClassName(), created->getName());
    212212
    213213      //todo do this more elegant
     
    217217        State::setSkyBox(dynamic_cast<SkyBox*>(this->sky));
    218218      }
    219       if( element->Value() == "Terrain" && created->isA(CL_TERRAIN))
     219               
     220      if( element->Value() == "TerrainEntity" && created->isA(CL_TERRAIN))
    220221      {
    221         this->terrain = dynamic_cast<Terrain*>(created);
     222        this->terrain = dynamic_cast<TerrainEntity*>(created);
    222223        CDEngine::getInstance()->setTerrain(terrain);
    223224      }
  • branches/terrain/src/story_entities/game_world_data.h

    r7460 r9140  
    1414class Camera;
    1515class Player;
    16 class Terrain;
     16class TerrainEntity;
    1717class WorldEntity;
    1818
     
    5757    Player*                       localPlayer;    //!< The player, you fly through the level.
    5858    WorldEntity*                  sky;            //!< The environmental sky of orxonox
    59     Terrain*                      terrain;        //!< The terrain - ground
     59    TerrainEntity*                terrain;        //!< The terrain - ground
    6060
    6161    OrxSound::OggPlayer*          music;          //!< Reference to the SoundEngine's music player (OggPlayer)
  • branches/terrain/src/story_entities/multi_player_world_data.cc

    r9008 r9140  
    3131#include "camera.h"
    3232#include "environment.h"
    33 #include "terrain.h"
     33#include "terrain_entity.h"
    3434#include "test_entity.h"
    35 #include "terrain.h"
    3635#include "md2/md2Model.h"
    3736#include "world_entities/projectiles/projectile.h"
     
    157156        if( element->Value() != NULL && !strcmp( element->Value(), "Terrain"))
    158157        {
    159           this->terrain = dynamic_cast<Terrain*>(created);
     158          this->terrain = dynamic_cast<TerrainEntity*>(created);
    160159          CDEngine::getInstance()->setTerrain(terrain);
    161160        }
     
    188187          if( element->Value() != NULL && !strcmp( element->Value(), "Terrain"))
    189188          {
    190             this->terrain = dynamic_cast<Terrain*>(created);
     189            this->terrain = dynamic_cast<TerrainEntity*>(created);
    191190            CDEngine::getInstance()->setTerrain(terrain);
    192191          }
  • branches/terrain/src/story_entities/simple_game_menu.cc

    r8717 r9140  
    3131#include "world_entity.h"
    3232#include "elements/image_entity.h"
    33 #include "terrain.h"
     33#include "terrain_entity.h"
    3434#include "camera.h"
    3535
  • branches/terrain/src/util/multiplayer_team_deathmatch.cc

    r9110 r9140  
    3232
    3333#include "shared_network_data.h"
    34 #include "terrain.h"
     34#include "terrain_entity.h"
    3535#include "class_list.h"
    3636#include "space_ships/space_ship.h"
  • branches/terrain/src/world_entities/WorldEntities.am

    r9061 r9140  
    1212                world_entities/skybox.cc \
    1313                world_entities/skydome.cc \
    14                 world_entities/terrain.cc \
     14                world_entities/terrain_entity.cc \
    1515                world_entities/satellite.cc \
    1616                world_entities/movie_entity.cc \
     
    7777                skybox.h \
    7878                skydome.h \
    79                 terrain.h \
     79                terrain_entity.h \
    8080                satellite.h \
    8181                movie_entity.h \
  • branches/terrain/src/world_entities/camera.cc

    r7868 r9140  
    3434  this->subscribeEvent(ES_GAME, KeyMapper::PEV_VIEW5);
    3535
    36   this->setFovy(90);
     36  this->setFovy(90.0);
    3737  this->setAspectRatio(1.2f);
    38   this->setClipRegion(.1, 2000);
     38  this->setClipRegion( .1, 40.0f );
    3939
    4040  this->setViewMode(Camera::ViewNormal);
  • branches/terrain/src/world_entities/playable.cc

    r9110 r9140  
    6969  //subscribe to collision reaction
    7070  this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, CL_BSP_ENTITY);
    71 
     71        this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, CL_TERRAIN );
    7272  registerVar( new SynchronizeableInt( &score, &score, "score" ) );
    7373  registerVar( new SynchronizeableBool( &bFire, &bFire, "bFire", PERMISSION_OWNER));
  • branches/terrain/src/world_entities/skybox.cc

    r8037 r9140  
    230230//   glPushAttrib(GL_LIGHTING_BIT);
    231231  glDisable(GL_LIGHTING);
    232 
     232  glDisable( GL_DEPTH_TEST );   
    233233  glDisable(GL_FOG);
    234234
  • branches/terrain/src/world_entities/world_entity.cc

    r9110 r9140  
    442442    return false;
    443443
     444
    444445  // get a collision event
    445446  CollisionEvent* c = CREngine::getInstance()->popCollisionEventObject();
Note: See TracChangeset for help on using the changeset viewer.