Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9869 in orxonox.OLD


Ignore:
Timestamp:
Oct 3, 2006, 12:19:30 AM (15 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

Location:
trunk
Files:
23 deleted
504 edited
93 copied

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r9406 r9869  
    1 2006-07-21      Benjamin Grauerb <bensch@orxonox.net>
     12006-09-22      Benjamin Grauer <bensch@orxonox.net>
     2        Complete reimplementation of the ResourceManager.
     3        Now all resourceable Classes have a SubClass, that handles via Resources.
     4        The Approach is Scaleable/Modular, and conforms with Shared Libraries.
     5
     62006-09-16      Benjamin Grauer <bensch@orxonox.net>
     7        Total templated and typesafe approach to the Executor paradigm.
     8        Now there is only one implementation of the Executor-construct,
     9        and all special types of executors (e.g SubString, lua_State*)
     10        are created via Explicit Specialization and an Evaluater.
     11
     122006-09-01      Benjamin Grauer <bensch@orxonox.net>
     13        Reimplementation of the ObjectList Class
     14        Removed old constructs
     15        Waiting for adaptions in Network and CollisionReaction
     16
     172006-07-21      Benjamin Grauer <bensch@orxonox.net>
    218        New implementation of the signal/slot paradigm
    319        For this the nice implementation sigslot from Sarah Thompson was adapted.
     
    1733
    1834
    19 2006-06-10      Benjamin Grauerb <bensch@orxonox.net>
     352006-06-10      Benjamin Grauer <bensch@orxonox.net>
    2036        Introduced new GL-style Gui
    2137
    22 2006-05-19      Benjamin Grauerb <bensch@orxonox.net>
     382006-05-19      Benjamin Grauer <bensch@orxonox.net>
    2339        New Design of the Executor (constant instead of linear time)
    2440
     
    2252412004-04-25      Amir Guindehi <amir@guindehi.ch>
    226242        Created Project orxonox.
    227         Thanks a lot.
     243        Thanks a lot. (from all the Orxonox-dev-team)
  • trunk/IDEAS

    r9406 r9869  
     1        ====================
     2        ====== IDEAS =======
     3        ====================
    14
    25
    3 all: fill in your ideas here!
    4 
    5 - Spacecraft transformations
    6 - weather influences: fog, rain, sun, wind
    7 - team play: fight with team-mates
    8 - RPG style: intelligence, constitution, force/power
    9 
    10 
    11 Please see at the Wiki for more information about this:
     6Please have a look at the Wiki for more information about this:
    127-------------------------------------------------------
    13       https://www.orxonox.net/cgi-bin/trac.cgi
     8---------      https://dev.orxonox.net      -----------
    149-------------------------------------------------------
  • trunk/configure.ac

    r9668 r9869  
    624624                 src/lib/event/Makefile
    625625                 src/lib/physics/Makefile
    626                  src/lib/particles/Makefile
    627626                 src/lib/collision_detection/Makefile
    628627                 src/lib/collision_reaction/Makefile
  • trunk/src/Makefile.am

    r9006 r9869  
    3737                orxonox.cc \
    3838                \
    39                 lib/particles/model_particles.cc \
    40                 lib/particles/spark_particles.cc \
    41                 lib/particles/sprite_particles.cc \
    42                 lib/particles/plane_emitter.cc \
    43                 lib/graphics/effects/fog_effect.cc \
    44                 lib/graphics/effects/volfog_effect.cc \
    45                 lib/graphics/effects/rain_effect.cc \
    46                 lib/graphics/effects/snow_effect.cc \
    47                 lib/graphics/effects/cloud_effect.cc \
    48                 lib/graphics/effects/lightning_effect.cc \
    49                 lib/graphics/effects/lense_flare.cc \
    50                 \
    5139                util/multiplayer_team_deathmatch.cc \
    5240                util/singleplayer_shootemup.cc \
     
    6957                defs/confincl.h \
    7058                defs/error.h \
    71                 defs/debug.h \
    7259                defs/globals.h \
    7360                defs/compiler.h \
    74                 defs/class_id.h \
     61                defs/class_id_DEPRECATED.h \
    7562                subprojects/benchmark.h
    7663
  • trunk/src/defs/include_paths.am

    r8490 r9869  
    1313AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/graphics/spatial_separation
    1414AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/graphics/render2D
    15 AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/particles
    1615AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/gui/gl
    1716AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/gui/gl/glmenu
     
    2120AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/math
    2221AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/network
    23 AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/tinyxml
    2422AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/physics
    25 AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/physics/fields
    2623AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/collision_detection
    2724AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/collision_reaction
    28 AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/newmat
    2925AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/sound
    3026AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/script_engine
    3127AM_CXXFLAGS+=-I$(MAINSRCDIR)/defs
    32 AM_CXXFLAGS+=-I$(MAINSRCDIR)/font
    33 AM_CXXFLAGS+=-I$(MAINSRCDIR)/network
    34 AM_CXXFLAGS+=-I$(MAINSRCDIR)/ai
    3528AM_CXXFLAGS+=-I$(MAINSRCDIR)/util
    3629AM_CXXFLAGS+=-I$(MAINSRCDIR)/util/animation
    37 AM_CXXFLAGS+=-I$(MAINSRCDIR)/util/common
    38 AM_CXXFLAGS+=-I$(MAINSRCDIR)/util/track
    39 AM_CXXFLAGS+=-I$(MAINSRCDIR)/subprojects
     30
    4031AM_CXXFLAGS+=-I$(MAINSRCDIR)/../extern_libs
  • trunk/src/lib/BuildLibs.am

    r9668 r9869  
    11
    22libORXlibs_a_LIBRARIES_ = \
    3                 $(LIB_PREFIX)/util/libORXlibutil.a \
    4                 $(LIB_PREFIX)/shell/libORXshell.a \
    53                $(LIB_PREFIX)/event/libORXevent.a \
    64                $(LIB_PREFIX)/gui/qt/libORXqtgui.a \
    75                $(LIB_PREFIX)/gui/gl/libORXglgui.a \
    86                $(LIB_PREFIX)/gui/libORXbasegui.a \
    9                 $(LIB_PREFIX)/script_engine/libORXscript.a \
    10                 $(LIB_PREFIX)/graphics/importer/libORXimporter.a \
    117                $(LIB_PREFIX)/graphics/libORXgraphics.a \
    12                 $(LIB_PREFIX)/graphics/importer/libtc.a \
    13                 $(LIB_PREFIX)/sound/libORXsound.a \
    14                 $(LIB_PREFIX)/particles/libORXparticles.a \
    158                $(LIB_PREFIX)/collision_detection/libORXcd.a \
    169                $(LIB_PREFIX)/collision_reaction/libORXcr.a \
     
    2316                $(LIB_PREFIX)/physics/libORXphysics.a \
    2417                $(LIB_PREFIX)/gui/gl/libORXglgui.a \
     18                \
     19                $(LIB_PREFIX)/graphics/importer/libORXimporter.a \
     20                $(LIB_PREFIX)/graphics/importer/libtc.a \
     21                $(LIB_PREFIX)/sound/libORXsound.a \
    2522                $(LIB_PREFIX)/shell/libORXshell.a \
    26                 $(LIB_PREFIX)/math/libORXmath.a \
     23                $(LIB_PREFIX)/script_engine/libORXscript.a \
     24                $(LIB_PREFIX)/util/libORXexecutor.a \
    2725                $(LIB_PREFIX)/util/libORXlibutil.a \
    2826                $(LIB_PREFIX)/lang/libORXlang.a \
    29                 $(LIB_PREFIX)/libORXlibs.a
     27                $(LIB_PREFIX)/libORXlibs.a \
     28                $(LIB_PREFIX)/math/libORXmath.a
  • trunk/src/lib/Makefile.am

    r9668 r9869  
    2525        event \
    2626        physics \
    27         particles \
    2827        collision_detection \
    2928        collision_reaction \
    3029        gui \
    3130        network \
     31        shell \
    3232        parser \
    33         shell \
    3433        script_engine
  • trunk/src/lib/collision_detection/aabb.cc

    r9406 r9869  
    2121
    2222
    23 
     23ObjectListDefinition(AABB);
    2424/**
    2525 *  standard constructor
     
    2727AABB::AABB ()
    2828{
    29    this->setClassID(CL_OBB, "AABB");
     29  this->registerObject(this, AABB::_objectList);
    3030   this->halfLength[0] = this->halfLength[1] = this->halfLength[2] = 0.0f;
    3131   this->bCollided = false;
  • trunk/src/lib/collision_detection/aabb.h

    r8724 r9869  
    1111#include "bounding_volume.h"
    1212
    13 template<class T> class tList;
    14 
    1513//! A class representing an extended bounding volume tree: an obb tree
    1614class AABB : public BoundingVolume {
     15  ObjectListDeclaration(AABB);
    1716
    1817 public:
  • trunk/src/lib/collision_detection/aabb_tree_node.cc

    r9494 r9869  
    3232#include "debug.h"
    3333
    34 
    35 
    36 
    37 
    38 
    3934GLUquadricObj* AABBTreeNode_sphereObj = NULL;
    4035
    41 
     36ObjectListDefinition(AABBTreeNode);
    4237/**
    4338 *  standard constructor
     
    4843    : BVTreeNode()
    4944{
    50   this->setClassID(CL_OBB_TREE_NODE, "AABBTreeNode");
     45  this->registerObject(this, AABBTreeNode::_objectList);
    5146
    5247  this->obbTree = &tree;
  • trunk/src/lib/collision_detection/aabb_tree_node.h

    r8724 r9869  
    2121class AABBTreeNode : public BVTreeNode
    2222{
     23  ObjectListDeclaration(AABBTreeNode);
    2324
    2425
  • trunk/src/lib/collision_detection/bounding_sphere.cc

    r9406 r9869  
    2020
    2121
    22 
     22ObjectListDefinition(BoundingSphere);
    2323/**
    2424 *  standard constructor
     
    2626BoundingSphere::BoundingSphere ()
    2727{
    28    this->setClassID(CL_BOUNDING_SPHERE, "BoundingSphere");
     28  this->registerObject(this, BoundingSphere::_objectList);
    2929}
    3030
  • trunk/src/lib/collision_detection/bounding_sphere.h

    r5039 r9869  
    1 /*! 
     1/*!
    22 * @file bounding_sphere.h
    33  *  Definition of a bounding sphere
     
    1414//! A class representing an extended bounding volume tree: an sphere
    1515class BoundingSphere : public BoundingVolume {
     16  ObjectListDeclaration(BoundingSphere);
    1617
    1718 public:
  • trunk/src/lib/collision_detection/bounding_volume.cc

    r9406 r9869  
    2020
    2121
    22 
     22ObjectListDefinition(BoundingVolume);
    2323/**
    2424 *  standard constructor
     
    2626BoundingVolume::BoundingVolume ()
    2727{
    28   this->setClassID(CL_BOUNDING_VOLUME, "BoundingVolume");
     28  this->registerObject(this, BoundingVolume::_objectList);
    2929  this->modelInf = NULL;
    3030  this->triangleIndexes = NULL;
  • trunk/src/lib/collision_detection/bounding_volume.h

    r9008 r9869  
    1717//! An abstract class representing a bounding volume
    1818class BoundingVolume : public BaseObject {
     19  ObjectListDeclaration(BoundingVolume);
    1920
    2021  public:
  • trunk/src/lib/collision_detection/bv_tree.cc

    r9406 r9869  
    2121
    2222
    23 
     23ObjectListDefinition(BVTree);
    2424/**
    2525 *  standard constructor
     
    2727BVTree::BVTree ()
    2828{
    29    this->setClassID(CL_BV_TREE, "BVTree");
     29  this->registerObject(this, BVTree::_objectList);
    3030
    3131}
  • trunk/src/lib/collision_detection/bv_tree.h

    r7711 r9869  
    3636class BVTree : public BaseObject
    3737{
     38  ObjectListDeclaration(BVTree);
    3839
    3940  public:
  • trunk/src/lib/collision_detection/bv_tree_node.cc

    r9406 r9869  
    2020
    2121
    22 
     22ObjectListDefinition(BVTreeNode);
    2323/**
    2424 *  standard constructor
     
    2626BVTreeNode::BVTreeNode ()
    2727{
    28    this->setClassID(CL_BV_TREE_NODE, "BVTreeNode");
     28  this->registerObject(this, BVTreeNode::_objectList);
    2929
    3030}
  • trunk/src/lib/collision_detection/bv_tree_node.h

    r7732 r9869  
    2424//! A class that represents a bounding volume tree
    2525class BVTreeNode : public BaseObject {
     26  ObjectListDeclaration(BVTreeNode);
    2627
    2728
  • trunk/src/lib/collision_detection/cd_engine.cc

    r9406 r9869  
    2020#include "debug.h"
    2121
    22 #include "class_list.h"
    23 
    2422#include "model.h"
    2523#include "world_entity.h"
     
    3634
    3735
    38 
     36ObjectListDefinition(CDEngine);
    3937/**
    40  * standard constructor
     38 * @brief standard constructor
    4139 */
    4240CDEngine::CDEngine ()
    4341{
    44   this->setClassID(CL_CD_ENGINE, "CDEngine");
     42  this->registerObject(this, CDEngine::_objectList);
    4543
    4644  this->bAbordOnFirstCollision = false;
     
    103101void CDEngine::checkCollisionGround(std::list<WorldEntity*>& list1)
    104102{
    105 
    106   std::list<BaseObject*>::const_iterator bspIterator;
    107103  std::list<WorldEntity*>::iterator entityIterator;
    108   const std::list<BaseObject*>* bspList = ClassList::getList(CL_BSP_ENTITY);
    109   if( bspList == NULL)
    110     return;
    111 
    112104  // for all bsp managers check all entities
    113   for( bspIterator = bspList->begin(); bspIterator != bspList->end(); bspIterator++) {
     105  for( ObjectList<BspEntity>::const_iterator bspIterator = BspEntity::objectList().begin();
     106       bspIterator != BspEntity::objectList().end();
     107       bspIterator++) {
    114108      for(entityIterator = list1.begin(); entityIterator != list1.end(); entityIterator++)
    115109      {
  • trunk/src/lib/collision_detection/cd_engine.h

    r8186 r9869  
    3636//! The class representing the collision detection system of orxonox
    3737class CDEngine : public BaseObject {
     38  ObjectListDeclaration(CDEngine);
    3839
    3940  friend class WorldEntity;
  • trunk/src/lib/collision_detection/obb.cc

    r9406 r9869  
    2121
    2222
    23 
     23ObjectListDefinition(OBB);
    2424/**
    2525 *  standard constructor
     
    2727OBB::OBB ()
    2828{
    29    this->setClassID(CL_OBB, "OBB");
     29  this->registerObject(this, OBB::_objectList);
    3030   this->halfLength[0] = this->halfLength[1] = this->halfLength[2] = 0.0f;
    3131   this->bCollided = false;
  • trunk/src/lib/collision_detection/obb.h

    r7711 r9869  
    1515//! A class representing an extended bounding volume tree: an obb tree
    1616class OBB : public BoundingVolume {
     17  ObjectListDeclaration(OBB);
    1718
    1819 public:
  • trunk/src/lib/collision_detection/obb_tree.cc

    r9406 r9869  
    2727
    2828
    29 
     29ObjectListDefinition(OBBTree);
    3030/**
    3131 *  standard constructor
     
    5151void OBBTree::init()
    5252{
    53   this->setClassID(CL_OBB_TREE, "OBBTree");
     53  this->registerObject(this, OBBTree::_objectList);
    5454  this->rootNode = NULL;
    5555  this->id = 0;
  • trunk/src/lib/collision_detection/obb_tree.h

    r9235 r9869  
    2020class OBBTree : public BVTree
    2121{
     22  ObjectListDeclaration(OBBTree);
    2223
    2324  public:
  • trunk/src/lib/collision_detection/obb_tree_node.cc

    r9406 r9869  
    3838GLUquadricObj* OBBTreeNode_sphereObj = NULL;
    3939
    40 
     40ObjectListDefinition(OBBTreeNode);
    4141/**
    4242 *  standard constructor
     
    4747    : BVTreeNode()
    4848{
    49   this->setClassID(CL_OBB_TREE_NODE, "OBBTreeNode");
     49  this->registerObject(this, OBBTreeNode::_objectList);
    5050
    5151  this->obbTree = &tree;
     
    284284
    285285/**
    286  * calculate the eigenvectors for the object oriented box
     286 * @brief calculate the eigenvectors for the object oriented box
    287287 * @param box: reference to the box
    288288 * @param modelInf: the model info structure of the model
     
    361361
    362362/**
    363  * this separates an ob-box in the middle
     363 * @brief this separates an ob-box in the middle
    364364 * @param box: the box to separate
    365365 *
  • trunk/src/lib/collision_detection/obb_tree_node.h

    r9235 r9869  
    1717class PNode;
    1818
    19 
    2019//! A class that represents a bounding volume tree
    2120class OBBTreeNode : public BVTreeNode
    2221{
    23 
    24 
     22  ObjectListDeclaration(OBBTreeNode);
    2523  public:
    2624    OBBTreeNode(const OBBTree& tree, OBBTreeNode* prev, int depth);
  • trunk/src/lib/collision_reaction/collision.cc

    r9406 r9869  
    1818#include "collision.h"
    1919#include "debug.h"
    20 
    21 
    22 
    2320
    2421/**
  • trunk/src/lib/collision_reaction/collision.h

    r8490 r9869  
    2121class Collision
    2222{
    23 
    2423  public:
    2524    Collision();
  • trunk/src/lib/collision_reaction/collision_event.cc

    r9406 r9869  
    1818#include "collision_event.h"
    1919#include "debug.h"
    20 
    21 
    22 
    2320
    2421/**
  • trunk/src/lib/collision_reaction/collision_event.h

    r8894 r9869  
    2020//! A class representing a simple collision
    2121class CollisionEvent {
    22 
    2322 public:
    2423   CollisionEvent();
  • trunk/src/lib/collision_reaction/collision_handle.cc

    r9406 r9869  
    3030
    3131
    32 
     32ObjectListDefinition(CollisionHandle);
    3333
    3434/**
     
    3838CollisionHandle::CollisionHandle (WorldEntity* owner, CREngine::CRType type)
    3939{
    40   this->setClassID(CL_COLLISION_HANDLE, "CollisionHandle");
     40  this->registerObject(this, CollisionHandle::_objectList);
    4141
    4242  this->owner = owner;
     
    9494 *  @param classID the classid to look for
    9595 */
    96 void CollisionHandle::addTarget(long target)
     96void CollisionHandle::addTarget(const ClassID& target)
    9797{
    9898  // make sure there is no dublicate
    99   std::vector<long>::iterator it = this->targetList.begin();
     99  std::vector<ClassID>::iterator it = this->targetList.begin();
    100100  for( ; it < this->targetList.end(); it++)
    101101    if( (*it) == target)
    102102      return;
    103103
     104
    104105  // add element
    105    PRINTF(5)("addTarget: %i \n", target);
    106 
    107    this->targetList.push_back(target);
     106  this->targetList.push_back(target);
     107   PRINTF(5)("addTarget: %i \n", target.id());
    108108}
    109109
     
    227227bool CollisionHandle::filterCollisionEvent(CollisionEvent* collisionEvent)
    228228{
    229   std::vector<long>::iterator it = this->targetList.begin();
     229  std::vector<ClassID>::iterator it = this->targetList.begin();
    230230  for(; it < this->targetList.end(); it++)
    231231  {
     
    253253
    254254    if( collisionEvent->getEntityA() == this->owner) {
    255       if( collisionEvent->getEntityB()->isA((ClassID)(*it))) {
     255      if( collisionEvent->getEntityB()->isA((*it))) {
    256256        PRINTF(5)("I am: %s colliding with: %s is a %i filter ok\n", owner->getClassCName(),
    257                   collisionEvent->getEntityB()->getClassCName(), *it);
     257        collisionEvent->getEntityB()->getClassCName(), (*it).id());
    258258        return true; }
    259259    }
    260260    else {
    261       if( collisionEvent->getEntityA()->isA((ClassID)(*it))) {
     261      if( collisionEvent->getEntityA()->isA((*it))) {
    262262        PRINTF(5)("I am: %s colliding with: %s is a %i filter ok\n", owner->getClassCName(),
    263                   collisionEvent->getEntityA()->getClassCName(), *it);
     263        collisionEvent->getEntityA()->getClassCName(), (*it).id());
    264264      return true; }
    265265    }
     
    276276bool CollisionHandle::filterCollision(Collision* collision)
    277277{
    278   std::vector<long>::iterator it = this->targetList.begin();
     278  std::vector<ClassID>::iterator it = this->targetList.begin();
    279279  for(; it < this->targetList.end(); it++)
    280280  {
     
    302302
    303303    if( collision->getEntityA() == this->owner) {
    304       if( collision->getEntityA()->isA((ClassID)(*it)))
     304      if( collision->getEntityA()->isA(*it))
    305305        return true; }
    306306      else {
    307         if( collision->getEntityB()->isA((ClassID)(*it)))
     307        if( collision->getEntityB()->isA(*it))
    308308          return true; }
    309309  }
  • trunk/src/lib/collision_reaction/collision_handle.h

    r8490 r9869  
    2323class CollisionHandle : public BaseObject
    2424{
    25 
     25  ObjectListDeclaration(CollisionHandle);
    2626  public:
    2727    CollisionHandle(WorldEntity* owner, CREngine::CRType type);
     
    3030    void reset();
    3131
    32     void addTarget(long target);
     32    void addTarget(const ClassID& target);
    3333    Collision* registerCollision(WorldEntity* entityA, WorldEntity* entityB);
    3434    void registerSharedCollision(Collision* collision);
     
    6464
    6565    std::vector<Collision*>       collisionList;           //!< a list full of collisions
    66     std::vector<long>             targetList;              //!< a list of target classes for filtering
     66    /// TODO Take a std::set here!
     67    std::vector<ClassID>          targetList;              //!< a list of target classes for filtering @TODO TAKE SET INSTEAD OF VECTOR HERE
    6768
    6869    CollisionReaction*            collisionReaction;       //!< reference to the collision reaction object
  • trunk/src/lib/collision_reaction/collision_reaction.cc

    r9406 r9869  
    2020
    2121
    22 
     22ObjectListDefinition(CollisionReaction);
    2323
    2424/**
     
    2828  : BaseObject()
    2929{
    30   this->setClassID(CL_COLLISION_REACTION, "CollisionReaction");
     30  this->registerObject(this, CollisionReaction::_objectList);
    3131}
    3232
  • trunk/src/lib/collision_reaction/collision_reaction.h

    r8490 r9869  
    1818class CollisionReaction : public BaseObject
    1919{
    20 
     20  ObjectListDeclaration(CollisionReaction);
    2121  public:
    2222    CollisionReaction();
  • trunk/src/lib/collision_reaction/cr_engine.cc

    r9406 r9869  
    2929
    3030
    31 
     31ObjectListDefinition(CREngine);
    3232/**
    3333 * standard constructor
     
    3636  : BaseObject()
    3737{
    38    this->setClassID(CL_CR_ENGINE, "CREngine");
     38  this->registerObject(this, CREngine::_objectList);
    3939   this->setName("CREngine");
    4040
  • trunk/src/lib/collision_reaction/cr_engine.h

    r9235 r9869  
    2525class CREngine : public BaseObject
    2626{
     27  ObjectListDeclaration(CREngine);
    2728
    2829  public:
  • trunk/src/lib/collision_reaction/cr_object_damage.cc

    r9406 r9869  
    2828
    2929
    30 
     30ObjectListDefinition(CRObjectDamage);
    3131/**
    3232 *  standard constructor
     
    3535  : CollisionReaction()
    3636{
    37   this->setClassID(CL_CR_OBJECT_DAMAGE, "CRObjectDamage");
    38 
     37  this->registerObject(this, CRObjectDamage::_objectList);
    3938}
    4039
  • trunk/src/lib/collision_reaction/cr_object_damage.h

    r8190 r9869  
    1515class CRObjectDamage : public CollisionReaction
    1616{
     17  ObjectListDeclaration(CRObjectDamage);
    1718  public:
    1819    CRObjectDamage();
  • trunk/src/lib/collision_reaction/cr_physics_full_walk.cc

    r9406 r9869  
    3535
    3636
    37 
     37ObjectListDefinition(CRPhysicsFullWalk);
    3838/**
    3939 *  standard constructor
     
    4242    : CollisionReaction()
    4343{
    44   this->setClassID(CL_CR_PHYSICS_FULL_WALK, "CRPhysicsFullWalk");
     44  this->registerObject(this, CRPhysicsFullWalk::_objectList);
    4545}
    4646
  • trunk/src/lib/collision_reaction/cr_physics_full_walk.h

    r9235 r9869  
    1515class CRPhysicsFullWalk : public CollisionReaction
    1616{
     17  ObjectListDeclaration(CRPhysicsFullWalk);
    1718  public:
    1819    CRPhysicsFullWalk();
  • trunk/src/lib/collision_reaction/cr_physics_ground_walk.cc

    r9406 r9869  
    3535
    3636
    37 
     37ObjectListDefinition(CRPhysicsGroundWalk);
    3838/**
    3939 *  standard constructor
     
    4242    : CollisionReaction()
    4343{
    44   this->setClassID(CL_CR_PHYSICS_GROUND_WALK, "CRPhysicsGroundWalk");
     44  this->registerObject(this, CRPhysicsGroundWalk::_objectList);
    4545}
    4646
  • trunk/src/lib/collision_reaction/cr_physics_ground_walk.h

    r8894 r9869  
    1515class CRPhysicsGroundWalk : public CollisionReaction
    1616{
     17  ObjectListDeclaration(CRPhysicsGroundWalk);
    1718  public:
    1819    CRPhysicsGroundWalk();
  • trunk/src/lib/coord/p_node.cc

    r9656 r9869  
    1919
    2020#include "util/loading/load_param.h"
    21 #include "class_list.h"
    2221
    2322#include "netdefs.h"
     
    3029#include "color.h"
    3130
     31
     32ObjectListDefinition(PNode);
    3233/**
    3334 * @brief standard constructor
     
    3839  : BaseObject(), Synchronizeable()
    3940{
    40   this->setClassID(CL_PARENT_NODE, "PNode");
     41  this->registerObject(this, PNode::_objectList);
    4142
    4243  this->bRelCoorChanged = true;
     
    7980  PRINTF(4)("delete %s::%s\n", this->getClassCName(), this->getCName());
    8081  // remove the Node, delete it's children (if required).
    81   std::list<PNode*>::iterator deleteNode;
    82   unsigned int size;
     82  PNode* last = NULL;
     83  //this->debugNode(0);
     84
    8385  while(!this->children.empty())
    8486  {
    85     deleteNode = this->children.begin();
    86     size = this->children.size();
     87    PNode* deleteNode = this->children.front();
     88    if (deleteNode == last)
     89    {
     90      PRINTF(1)("Node same as last that was tried to be deleted. FORCE reparent to NULL of %p\n", deleteNode);
     91      (deleteNode->setParent( NULL));
     92      continue;
     93    }
    8794    if ((this->parentMode & PNODE_PROHIBIT_CHILD_DELETE) ||
    88         ((*deleteNode)->parentMode & PNODE_PROHIBIT_DELETE_WITH_PARENT))
     95        (deleteNode->parentMode & PNODE_PROHIBIT_DELETE_WITH_PARENT))
    8996    {
    90       if (this == PNode::nullParent && (*deleteNode)->parentMode & PNODE_REPARENT_TO_NULL)
     97      if (this == PNode::nullParent && deleteNode->parentMode & PNODE_REPARENT_TO_NULL)
    9198      {
    9299        PRINTF(4)("%s::%s deletes %s::%s\n",
    93100                  this->getClassCName(), this->getCName(),
    94                   (*deleteNode)->getClassCName(), (*deleteNode)->getCName());
    95         delete (*deleteNode);
     101                  deleteNode->getClassCName(), deleteNode->getCName());
     102        delete deleteNode;
    96103      }
    97104      else
     
    99106        PRINTF(4)("%s::%s reparents %s::%s\n",
    100107                  this->getClassCName(), this->getCName(),
    101                   (*deleteNode)->getClassCName(), (*deleteNode)->getCName());
    102         (*deleteNode)->reparent();
     108                  deleteNode->getClassCName(), deleteNode->getCName());
     109        deleteNode->reparent();
    103110      }
    104111    }
     
    107114      PRINTF(4)("%s::%s deletes PNode: %s::%s\n",
    108115                this->getClassCName(), this->getCName(),
    109                 (*deleteNode)->getClassCName(), (*deleteNode)->getCName());
    110       delete (*deleteNode);
     116                deleteNode->getClassCName(), deleteNode->getCName());
     117      delete deleteNode;
    111118    }
     119    last = deleteNode;
    112120  }
    113121
     
    541549void PNode::addChild (const std::string& childName)
    542550{
    543   PNode* childNode = dynamic_cast<PNode*>(ClassList::getObject(childName, CL_PARENT_NODE));
     551  PNode* childNode = PNode::objectList().getObject(childName);
    544552  //  PRINTF(0)("Adding the Child: %s to: %s\n", childName, this->getName());
    545553  //  assert( childNode != NULL );
     
    625633void PNode::setParent (const std::string& parentName)
    626634{
    627   PNode* parentNode = dynamic_cast<PNode*>(ClassList::getObject(parentName, CL_PARENT_NODE));
     635  PNode* parentNode = PNode::objectList().getObject(parentName);
    628636  if (parentNode != NULL)
    629637    parentNode->addChild(this);
     
    681689void PNode::setParentSoft(const std::string& parentName, float bias)
    682690{
    683   PNode* parentNode = dynamic_cast<PNode*>(ClassList::getObject(parentName, CL_PARENT_NODE));
     691  PNode* parentNode = PNode::objectList().getObject(parentName);
    684692  if (parentNode != NULL)
    685693    this->setParentSoft(parentNode, bias);
     
    730738  if (likely(PNode::nullParent == NULL))
    731739  {
    732     PNode::nullParent = new PNode(NULL, PNODE_PARENT_MODE_DEFAULT | PNODE_REPARENT_TO_NULL);
    733     PNode::nullParent->setClassID(CL_NULL_PARENT, "NullParent");
     740    PNode::nullParent = new NullParent();
     741    //PNode::nullParent->registerObject(, CL_NULL_PARENT);
    734742    PNode::nullParent->setName("NullParent");
    735743    PNode::nullParent->setSynchronized(true);
     
    915923  int childNodeCount = 0;
    916924  this->countChildNodes(childNodeCount);
    917 
     925  printf("%p:", this);
    918926  PRINT(0)("PNode(%s::%s) - absCoord: (%0.2f, %0.2f, %0.2f), relCoord(%0.2f, %0.2f, %0.2f), direction(%0.2f, %0.2f, %0.2f) - %s - %d childs\n",
    919927           this->getClassCName(),
     
    11061114}
    11071115
    1108 
     1116ObjectListDefinition(NullParent);
     1117
     1118NullParent::NullParent()
     1119  : PNode(NULL, PNODE_PARENT_MODE_DEFAULT | PNODE_REPARENT_TO_NULL)
     1120{
     1121  this->registerObject(this, NullParent::_objectList);
     1122}
  • trunk/src/lib/coord/p_node.h

    r9406 r9869  
    5050  PNODE_REPARENT_DELETE_CHILDREN       = 0x0040,    //!< Deletes the Children of the node when This Node is Removed. (Use with care).
    5151  /// FIXME
    52    PNODE_REPARENT_KEEP_POSITION         = 0x0080,    //!< Tries to keep the Position if the Node is reparented.
     52  PNODE_REPARENT_KEEP_POSITION         = 0x0080,    //!< Tries to keep the Position if the Node is reparented.
    5353
    5454
     
    7373
    7474//! Patent Node is a Engine to calculate the position of an Object in respect to the position of its parent.
    75 class PNode : virtual public BaseObject, virtual public Synchronizeable {
    76  public:
     75class PNode : virtual public BaseObject, virtual public Synchronizeable
     76{
     77  ObjectListDeclaration(PNode);
     78
     79public:
    7780  PNode (PNode* parent = PNode::getNullParent(), long nodeFlags = PNODE_PARENT_MODE_DEFAULT);
    7881  virtual ~PNode ();
     
    9598  inline const Vector& getRelCoor () const { return this->prevRelCoordinate; };
    9699  /** @returns the Relative Coordinate Destination */
    97   inline const Vector& getRelCoorSoft2D() const { return (this->toCoordinate)? *this->toCoordinate : this->relCoordinate; };
     100inline const Vector& getRelCoorSoft2D() const { return (this->toCoordinate)? *this->toCoordinate : this->relCoordinate; };
    98101  void setAbsCoor (const Vector& absCoord);
    99102  void setAbsCoor (float x, float y, float z);
     
    130133  inline const Quaternion& getRelDir () const { return this->prevRelDirection; };
    131134  /** @returns the Relative Directional Destination */
    132   inline const Quaternion& getRelDirSoft2D() const { return (this->toDirection)? *this->toDirection : this->relDirection; };
     135inline const Quaternion& getRelDirSoft2D() const { return (this->toDirection)? *this->toDirection : this->relDirection; };
    133136  /** @returns a Vector pointing into the relative Direction */
    134137  inline Vector getRelDirV() const { return this->prevRelDirection.apply(Vector(0,1,0)); };
     
    178181  void removeNodeFlags(unsigned short nodeFlags);
    179182
    180   // NULL_PARENT //
    181183  /** @returns the NullParent, the (main) ROOT of the PNode Tree. If it does not yet exist, it will be created. */
    182   static PNode* getNullParent()  { return (PNode::nullParent != NULL)? PNode::nullParent : PNode::createNullParent(); };
     184static PNode* getNullParent()  { return (PNode::nullParent != NULL) ? PNode::nullParent : PNode::createNullParent(); };
    183185
    184186  // UPDATING //
     
    195197  float distance(const PNode* node) const { return (this->getAbsCoor() - node->getAbsCoor()).len(); };
    196198
    197  private:
     199private:
    198200  /** tells the child that the parent's Coordinate has changed */
    199201  inline void parentCoorChanged () { this->bRelCoorChanged = true; }
    200202  /** tells the child that the parent's Direction has changed */
    201203  inline void parentDirChanged () { this->bRelDirChanged = true; }
    202  public:
     204public:
    203205  /** @returns the last calculated coordinate */
    204206  inline Vector getLastAbsCoor() { return this->lastAbsCoordinate; }
    205  private:
     207private:
    206208  static PNode* createNullParent();
    207209  void reparent();
     
    209211  void eraseChild(PNode* child);
    210212
    211  private:
     213private:
    212214  bool               bRelCoorChanged;    //!< If Relative Coordinate has changed since last time we checked
    213215  bool               bRelDirChanged;     //!< If Relative Direction has changed since last time we checked
     
    221223  Vector             lastAbsCoordinate;  //!< this is used for speedcalculation, it stores the last coordinate
    222224  Quaternion         prevRelDirection;   //!< The last Relative Direciton from the last update-Cycle.
    223 //  Quaternion         lastAbsDirection;
     225  //  Quaternion         lastAbsDirection;
    224226
    225227  Vector             velocity;           //!< Saves the velocity.
     
    238240  static PNode*      nullParent;         //!< The ROOT of the main PNode Tree.
    239241
    240   private:
    241     float coorx;
    242     float coory;
    243     float coorz;
    244 
    245     float rotw;
    246     float rotx;
    247     float roty;
    248     float rotz;
    249 
    250   private:
    251     int relCoordinate_handle;
    252     int relDirection_handle;
    253     Vector relCoordinate_write;
    254     Quaternion relDirection_write;
    255 
    256   public:
    257     virtual void varChangeHandler( std::list<int> & id );
     242private:
     243  float coorx;
     244  float coory;
     245  float coorz;
     246
     247  float rotw;
     248  float rotx;
     249  float roty;
     250  float rotz;
     251
     252private:
     253  int relCoordinate_handle;
     254  int relDirection_handle;
     255  Vector relCoordinate_write;
     256  Quaternion relDirection_write;
     257
     258public:
     259  virtual void varChangeHandler( std::list<int> & id );
    258260};
    259261
     262// NULL_PARENT //
     263class NullParent : public PNode
     264{
     265  ObjectListDeclaration(NullParent);
     266  friend class PNode;
     267  NullParent();
     268};
     269
     270
    260271#endif /* _P_NODE_H */
  • trunk/src/lib/event/event_handler.cc

    r9656 r9869  
    2828#include <algorithm>
    2929
     30
     31ObjectListDefinition(EventHandler);
    3032/**
    3133 * @brief standard constructor
     
    3335EventHandler::EventHandler ()
    3436{
    35   this->setClassID(CL_EVENT_HANDLER, "EventHandler");
     37  this->registerObject(this, EventHandler::_objectList);
    3638  this->setName("EventHandler");
    3739
  • trunk/src/lib/event/event_handler.h

    r8743 r9869  
    2121class EventHandler : public BaseObject
    2222{
    23 
     23  ObjectListDeclaration(EventHandler);
    2424public:
    2525  virtual ~EventHandler();
  • trunk/src/lib/event/event_listener.cc

    r7868 r9869  
    1919#include "event_handler.h"
    2020
     21ObjectListDefinition(EventListener);
    2122/**
    2223 * @brief standard constructor
     
    2425EventListener::EventListener ()
    2526{
    26   this->setClassID(CL_EVENT_LISTENER, "EventListener");
     27  this->registerObject(this, EventListener::_objectList);
    2728}
    2829
  • trunk/src/lib/event/event_listener.h

    r7868 r9869  
    1212
    1313//! A class for event listener
    14 class EventListener : virtual public BaseObject {
    15 
    16  public:
     14class EventListener : virtual public BaseObject
     15{
     16  ObjectListDeclaration(EventListener);
     17public:
    1718  EventListener();
    1819  virtual ~EventListener();
  • trunk/src/lib/event/key_mapper.cc

    r9406 r9869  
    2525#include "globals.h"
    2626#include "parser/ini_parser/ini_parser.h"
    27 #include "util/preferences.h"
     27#include "parser/preferences/preferences.h"
    2828#include "key_names.h"
    2929#include "event_def.h"
     
    3232
    3333
    34 
     34ObjectListDefinition(KeyMapper);
    3535
    3636/* initialize all variables to a reasonable value*/
     
    116116KeyMapper::KeyMapper ()
    117117{
    118    this->setClassID(CL_KEY_MAPPER, "KeyMapper");
     118  this->registerObject(this, KeyMapper::_objectList);
    119119}
    120120
  • trunk/src/lib/event/key_mapper.h

    r8724 r9869  
    1616class KeyMapper : public BaseObject
    1717{
     18  ObjectListDeclaration(KeyMapper);
    1819public:
    1920  //! A mapping from key-name to key-id
  • trunk/src/lib/graphics/Makefile.am

    r9006 r9869  
    66libORXgraphics_a_SOURCES = \
    77                graphics_engine.cc \
     8                graphics_effect.cc \
    89                light.cc \
    910                shader.cc \
     11                shader_data.cc \
     12                resource_shader.cc \
    1013                \
    1114                render2D/render_2d.cc \
     
    1922                text_engine/font.cc \
    2023                text_engine/font_data.cc \
    21                 \
    22                 effects/graphics_effect.cc \
    23                 effects/atmospheric_engine.cc \
    24                 effects/weather_effect.cc \
    25                 effects/sun_effect.cc \
    26                 effects/fog_effect.cc \
    27                 effects/volfog_effect.cc \
    28                 effects/rain_effect.cc \
    29                 effects/snow_effect.cc \
    30                 effects/cloud_effect.cc \
    31                 effects/lightning_effect.cc \
    32                 effects/lense_flare.cc
     24                text_engine/resource_font.cc
    3325
    3426noinst_HEADERS =\
    3527                graphics_engine.h \
     28                graphics_effect.h \
    3629                light.h \
    3730                shader.h \
     31                shader_data.h \
     32                resource_shader.h \
    3833                \
    3934                render2D/render_2d.h \
     
    4742                text_engine/font.h \
    4843                text_engine/font_data.h \
    49                 text_engine/default_font.xpm \
    50                 \
    51                 effects/graphics_effect.h \
    52                 effects/atmospheric_engine.h \
    53                 effects/weather_effect.h \
    54                 effects/sun_effect.h \
    55                 effects/fog_effect.h \
    56                 effects/volfog_effect.h \
    57                 effects/rain_effect.h \
    58                 effects/snow_effect.h \
    59                 effects/cloud_effect.h \
    60                 effects/lightning_effect.h \
    61                 effects/lense_flare.h
     44                text_engine/resource_font.h \
     45                text_engine/default_font.xpm
    6246
    6347
  • trunk/src/lib/graphics/graphics_engine.cc

    r9406 r9869  
    1717
    1818#include "graphics_engine.h"
    19 #include "util/loading/resource_manager.h"
    2019#include "state.h"
    2120
     
    2827#include "debug.h"
    2928
    30 #include "util/preferences.h"
     29#include "parser/preferences/preferences.h"
    3130#include "substring.h"
    3231#include "text.h"
     
    3534#include "texture.h"
    3635
    37 #include "effects/graphics_effect.h"
    38 #include "effects/fog_effect.h"
    39 #include "effects/lense_flare.h"
     36#include "graphics_effect.h"
    4037
    4138#include "shell_command.h"
    42 
     39#include "loading/load_param_xml.h"
    4340
    4441#include "parser/tinyxml/tinyxml.h"
    4542#include "util/loading/load_param.h"
    4643#include "util/loading/factory.h"
    47 #include "class_list.h"
    4844
    4945#ifdef __WIN32__
     
    5450SHELL_COMMAND(fps, GraphicsEngine, toggleFPSdisplay);
    5551
     52ObjectListDefinition(GraphicsEngine);
     53
    5654/**
    5755 * @brief standard constructor
     
    5957GraphicsEngine::GraphicsEngine ()
    6058{
    61   this->setClassID(CL_GRAPHICS_ENGINE, "GraphicsEngine");
     59  this->registerObject(this, GraphicsEngine::_objectList);
    6260  this->setName("GraphicsEngine");
    6361
     
    117115{
    118116  LoadParamXML(root, "GraphicsEffect", this, GraphicsEngine, loadGraphicsEffects)
    119   .describe("loads a graphics effect");
     117   .describe("loads a graphics effect");
    120118}
    121119
     
    590588
    591589  // tick the graphics effects
    592   if (this->graphicsEffects != NULL || (this->graphicsEffects = ClassList::getList(CL_GRAPHICS_EFFECT)) != NULL)
    593   {
    594     std::list<BaseObject*>::const_iterator it;
    595     for (it = this->graphicsEffects->begin(); it != this->graphicsEffects->end(); it++)
    596       dynamic_cast<GraphicsEffect*>(*it)->tick(dt);
    597   }
     590  for (ObjectList<GraphicsEffect>::const_iterator it = GraphicsEffect::objectList().begin();
     591       it != GraphicsEffect::objectList().end();
     592       ++it)
     593    (*it)->tick(dt);
    598594}
    599595
     
    688684  {
    689685    case EV_VIDEO_RESIZE:
    690       this->resolutionChanged(event.resize);
    691       break;
    692   }
    693 }
     686    this->resolutionChanged(event.resize);
     687    break;
     688  }
     689}
  • trunk/src/lib/graphics/graphics_engine.h

    r9406 r9869  
    3030class GraphicsEngine : public EventListener
    3131{
     32  ObjectListDeclaration(GraphicsEngine);
    3233  public:
    3334    virtual ~GraphicsEngine();
  • trunk/src/lib/graphics/importer/Makefile.am

    r8724 r9869  
    44noinst_LIBRARIES = libORXimporter.a libtc.a
    55
    6 libORXimporter_a_SOURCES = model.cc \
    7                            interactive_model.cc \
    8                            md_model_structure.cc \
    9                            vertex_array_model.cc \
    10                            grid.cc \
    11                            static_model.cc \
    12                            objModel.cc \
    13                            primitive_model.cc \
    14                            height_map.cc \
    15                            bsp_manager.cc \
    16                            bsp_file.cc \
    17                            bsp_tree_node.cc \
    18                            bsp_tree_leaf.cc \
    19                            \
    20                            material.cc \
    21                            texture.cc \
    22                            texture_data.cc \
    23                            texture_sequence.cc \
    24                            media_container.cc \
    25                            movie_player.cc \
    26                            \
    27                            bsp_manager.cc \
    28                            bsp_file.cc \
    29                            bsp_tree_node.cc \
    30                            bsp_tree_leaf.cc \
    31                            \
    32                            md2/md2Model.cc \
    33                            \
    34                            md3/md3_model.cc \
    35                            md3/md3_animation.cc \
    36                            md3/md3_animation_cfg.cc \
    37                            md3/md3_bone_frame.cc \
    38                            md3/md3_mesh.cc \
    39                            md3/md3_data.cc \
    40                            md3/md3_tag.cc
     6libORXimporter_a_SOURCES = \
     7                model.cc \
     8                interactive_model.cc \
     9                md_model_structure.cc \
     10                vertex_array_model.cc \
     11                grid.cc \
     12                static_model.cc \
     13                static_model_data.cc \
     14                objModel.cc \
     15                resource_obj.cc \
     16                primitive_model.cc \
     17                height_map.cc \
     18                bsp_manager.cc \
     19                bsp_file.cc \
     20                bsp_tree_node.cc \
     21                bsp_tree_leaf.cc \
     22                \
     23                material.cc \
     24                texture.cc \
     25                texture_data.cc \
     26                resource_texture.cc \
     27                texture_sequence.cc \
     28                media_container.cc \
     29                movie_player.cc \
     30                \
     31                bsp_manager.cc \
     32                bsp_file.cc \
     33                bsp_tree_node.cc \
     34                bsp_tree_leaf.cc \
     35                \
     36                md2/md2Model.cc \
     37                md2/resource_md2.cc
     38#               \
     39                md3/md3_model.cc \
     40                md3/md3_animation.cc \
     41                md3/md3_animation_cfg.cc \
     42                md3/md3_bone_frame.cc \
     43                md3/md3_mesh.cc \
     44                md3/md3_data.cc \
     45                md3/md3_tag.cc
    4146
    4247
     
    5459                grid.h \
    5560                static_model.h \
     61                static_model_data.h \
    5662                objModel.h \
     63                resource_obj.h \
    5764                primitive_model.h \
    5865                anorms.h \
     
    6370                texture.h \
    6471                texture_data.h \
     72                resource_texture.h \
    6573                texture_sequence.h \
    6674                \
     
    7482                \
    7583                md2/md2Model.h \
     84                md2/resource_md2.h \
    7685                \
    7786                md3/md3_model.h \
  • trunk/src/lib/graphics/importer/bsp_file.cc

    r9406 r9869  
    466466    PRINTF(4)("BSP FILE: Name %s . \n", fileName);
    467467
    468     absFileName = ResourceManager::getFullName(fileName);
     468    absFileName = Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(fileName);
    469469
    470470    if(File(absFileName).exists()) {
     
    481481    strncat (fileName, ext, strlen(fileName));
    482482
    483     absFileName = ResourceManager::getFullName(fileName);
     483    absFileName = Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(fileName);
    484484
    485485    if(File(absFileName).exists()) {
     
    496496    strncat (fileName, ext, strlen(fileName));
    497497
    498     absFileName = ResourceManager::getFullName(fileName);
     498    absFileName = Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(fileName);
    499499
    500500    if(File(absFileName).exists()) {
     
    511511    strncat (fileName, ext, strlen(fileName));
    512512
    513     absFileName = ResourceManager::getFullName(fileName);
     513    absFileName = Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(fileName);
    514514
    515515    if(File(absFileName).exists()) {
     
    524524    strcpy(ext, ".TGA");
    525525    strncat (fileName, ext, strlen(fileName));
    526     absFileName = ResourceManager::getFullName(fileName);
     526    absFileName = Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(fileName);
    527527
    528528    if(File(absFileName).exists()/*stat( absFileName.c_str() , &results) == 0*/) {
     
    537537    strcpy(ext, ".jpg");
    538538    strncat (fileName, ext, strlen(fileName));
    539     absFileName = ResourceManager::getFullName(fileName);
     539    absFileName = Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(fileName);
    540540    if(File(absFileName).exists()) {
    541541      PRINTF(4)("BSP FILE: gefunden . \n");
     
    551551    strcpy(ext, ".JPG");
    552552    strncat (fileName, ext, strlen(fileName));
    553     absFileName = ResourceManager::getFullName(fileName);
     553    absFileName = Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(fileName);
    554554    if(File(absFileName).exists()) {
    555555      PRINTF(4)("BSP FILE: gefunden . \n");
     
    566566    strcpy(ext, ".bmp");
    567567    strncat (fileName, ext, strlen(fileName));
    568     absFileName = ResourceManager::getFullName(fileName);
     568    absFileName = Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(fileName);
    569569
    570570    if(File(absFileName).exists()) {
     
    580580    strcpy(ext, ".BMP");
    581581    strncat (fileName, ext, strlen(fileName));
    582     absFileName = ResourceManager::getFullName(fileName);
     582    absFileName = Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(fileName);
    583583
    584584    if(File(absFileName).exists()) {
     
    611611  this->testSurf = NULL;
    612612
    613   this->testSurf = IMG_Load(ResourceManager::getFullName(mat).c_str());
     613  this->testSurf = IMG_Load(Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(mat).c_str());
    614614  if(this->testSurf != NULL) {
    615615    if(this->testSurf->format->Amask != 0 ) tmpAMat.alpha = true;
  • trunk/src/lib/graphics/importer/bsp_manager.cc

    r9235 r9869  
    3333#include "world_entities/player.h"
    3434#include "world_entities/playable.h"
    35 #include "util/loading/resource_manager.h"
     35
    3636// STL Containers
    3737#include <vector>
     
    4141#include "world_entity.h"
    4242
     43#include "util/loading/resource_manager.h"
    4344#include "util/loading/load_param.h"
    4445#include "util/loading/factory.h"
     
    9192  this->bspFile = new BspFile();
    9293  this->bspFile->scale =  scale;
    93   if(this->bspFile->read(ResourceManager::getFullName(fileName).c_str()) == -1)
     94  if(this->bspFile->read(Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(fileName).c_str()) == -1)
    9495    return -1;
    9596
     
    13761377    if( this->outputFraction == 1.0f) // No collision Detected
    13771378    {
    1378       if( this->outputAllSolid ) 
     1379      if( this->outputAllSolid )
    13791380      {
    13801381        this->collPlane = new plane;
  • trunk/src/lib/graphics/importer/height_map.cc

    r8316 r9869  
    2222#include "p_node.h"
    2323#include "state.h"
    24 #include "util/loading/resource_manager.h"
    2524#include "debug.h"
    2625
     
    327326
    328327
     328ObjectListDefinition(HeightMap);
    329329
    330330
     
    413413void HeightMap::init(const std::string& heightMapName)
    414414{
    415   this->setClassID(CL_HEIGHT_MAP, "HeightMap");
     415  this->registerObject(this, HeightMap::_objectList);
    416416
    417417  this->shiftX = 0;
  • trunk/src/lib/graphics/importer/height_map.h

    r7526 r9869  
    2929
    3030class SDL_Surface;
    31 class Vector;
    3231class Material;
    33 class PNode;
    3432class Texture;
    3533class HeightMap;
     
    7068
    7169
     70
    7271//!< the height map representation itself
    7372class HeightMap : public VertexArrayModel
    7473{
     74  ObjectListDeclaration(HeightMap);
    7575  friend class Tile;
    7676
  • trunk/src/lib/graphics/importer/interactive_model.cc

    r9406 r9869  
    2222
    2323
     24ObjectListDefinition(InteractiveModel);
     25
    2426/**
    2527 * standard constructor
     
    2830InteractiveModel::InteractiveModel()
    2931{
    30   this->setClassID(CL_INTERACTIVE_MODEL, "InteractiveModel");
     32  this->registerObject(this, InteractiveModel::_objectList);
    3133}
    3234
  • trunk/src/lib/graphics/importer/interactive_model.h

    r9003 r9869  
    3030class InteractiveModel : public Model
    3131{
     32  ObjectListDeclaration(InteractiveModel);
    3233  public:
    3334    InteractiveModel();
     
    3839    virtual void setAnimation(int animNum, int playbackMode = 0) = 0;
    3940    virtual void setAnimation(int firstFrame, int lastFrame, int fps, int bStoppable, int animPlayback) {}
    40     virtual int getAnimation() = 0;
     41    virtual int getAnimation() const = 0;
    4142
    4243    virtual bool isAnimationFinished() { return false; }
  • trunk/src/lib/graphics/importer/material.cc

    r9406 r9869  
    2525#include "loading/load_param.h"
    2626
    27 #include "util/loading/resource_manager.h"
     27#include "resource_texture.h"
     28
     29ObjectListDefinition(Material);
    2830
    2931/**
     
    3335Material::Material (const std::string& mtlName)
    3436{
    35   this->setClassID(CL_MATERIAL, "Material");
     37  this->registerObject(this, Material::_objectList);
    3638
    3739  this->setIllum(3);
     
    9092  PRINTF(5)("delete Material %s.\n", this->getCName());
    9193
    92   if (this->ambientTexture != NULL)
    93     ResourceManager::getInstance()->unload(this->ambientTexture);
    94   if (this->specularTexture != NULL)
    95     ResourceManager::getInstance()->unload(this->specularTexture);
    96 
    9794  if (this == Material::selectedMaterial)
    9895    Material::selectedMaterial = NULL;
     
    10198
    10299const Material* Material::selectedMaterial = NULL;
    103 
    104 
    105 /// TODO FIX THIS
    106 // Material& Material::operator=(const Material& m)
    107 // {
    108 //   this->setIllum(m.illumModel);
    109 //   this->setDiffuse(m.diffuse[0],m.diffuse[1],m.diffuse[2]);
    110 //   this->setAmbient(m.ambient[0],m.ambient[1],m.ambient[2]);
    111 //   this->setSpecular(m.specular[0],m.specular[1],m.specular[2]);
    112 //   this->setShininess(m.shininess);
    113 //   this->setTransparency(m.transparency);
    114 //
    115 //   if (this->diffuseTexture != NULL)
    116 //     ResourceManager::getInstance()->unload(this->diffuseTexture);
    117 //   if (m.diffuseTexture != NULL)
    118 //     this->diffuseTexture = (Texture*)ResourceManager::getInstance()->copy(m.diffuseTexture);
    119 //   this->ambientTexture = NULL; /// FIXME
    120 //   this->specularTexture = NULL; /// FIXME
    121 //
    122 //   this->setName(m.getName());
    123 // }
    124 
    125 
    126100
    127101/**
     
    288262
    289263
    290 
    291 /**
    292  * @brief Adds a Texture Path to the List of already existing Paths
    293  * @param pathName The Path to add.
    294 */
    295 void Material::addTexturePath(const std::string& pathName)
    296 {
    297   ResourceManager::getInstance()->addImageDir(pathName);
    298 }
    299 
    300 // MAPPING //
    301 
    302 
    303264/**
    304265 * @brief Sets the Diffuse map of this Texture.
     
    322283 * @param textureNumber The Texture-Number from 0 to GL_MAX_TEXTURE_UNITS
    323284 */
    324 void Material::setDiffuseMap(const TextureDataPointer& textureDataPointer, unsigned int textureNumber)
     285void Material::setDiffuseMap(const TextureData::Pointer& textureDataPointer, unsigned int textureNumber)
    325286{
    326287  assert(textureNumber < Material::getMaxTextureUnits());
     
    349310  if (!dMap.empty())
    350311  {
    351     Texture* tex = dynamic_cast<Texture*>(ResourceManager::getInstance()->load(dMap, IMAGE, RP_GAME, (int)target));
    352     if (tex != NULL)
    353       this->textures[textureNumber] = *tex;
     312    this->textures[textureNumber] = ResourceTexture(dMap);
     313        //dynamic_cast<Texture*>(ResourceManager::getInstance()->load(dMap, IMAGE, RP_GAME, (int)target));
     314/*    if (tex != NULL)
     315      this->textures[textureNumber] = tex;
    354316    else
    355       this->textures[textureNumber] = Texture();
     317      this->textures[textureNumber] = Texture();*/
    356318  }
    357319  else
  • trunk/src/lib/graphics/importer/material.h

    r8761 r9869  
    2424class Material : public BaseObject
    2525{
     26  ObjectListDeclaration(Material);
    2627public:
    2728  Material (const std::string& mtlName = "");
    2829  virtual ~Material ();
    2930
     31  Material& operator=(const Material& material);
     32
    3033  void loadParams(const TiXmlElement* root);
    31 
    32   Material& operator=(const Material& material);
    3334
    3435  bool select () const;
     
    5354  // MAPPING //
    5455  void setDiffuseMap(const Texture& texture, unsigned int textureNumber = 0);
    55   void setDiffuseMap(const TextureDataPointer& texturePointer, unsigned int textureNumber = 0);
     56  void setDiffuseMap(const TextureData::Pointer& texturePointer, unsigned int textureNumber = 0);
    5657  void setDiffuseMap(const std::string& dMap, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
    5758  void setSDLDiffuseMap(SDL_Surface *surface, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
     
    6566
    6667  const Texture& diffuseTexture(unsigned int i = 0) const { return this->textures[i]; };
    67 
    68   static void addTexturePath(const std::string& pathName);
    6968
    7069  static const std::string& blendFuncToString(GLenum blendFunc);
  • trunk/src/lib/graphics/importer/md2/md2Model.cc

    r9406 r9869  
    1919
    2020#include "debug.h"
    21 #include "util/loading/resource_manager.h"
    22 
    23 
    24 
     21#include "resource_md2.h"
     22
     23
     24ObjectListDefinition(MD2Model);
    2525
    2626//! the model anorms
    2727sVec3D MD2Model::anorms[NUM_VERTEX_NORMALS] = {
    28  #include "anorms.h"
    29 };
     28#include "anorms.h"
     29    };
    3030
    3131//! anormal dots, no idea of how this shall work, but it does
    3232float MD2Model::anormsDots[SHADEDOT_QUANT][256] = {
    33   #include "anormtab.h"
    34 };
     33#include "anormtab.h"
     34    };
    3535
    3636
     
    4242sAnim MD2Model::animationList[22] =
    4343  {
    44  // begin, end, fps, interruptable
     44    // begin, end, fps, interruptable
    4545    {   0,  39,  9, 1 },   //!< STAND
    4646    {  40,  45, 10, 1 },   //!< RUN
     
    7373 ********************************************************************************/
    7474
     75MD2Model::MD2Model()
     76  : data(new MD2Data())
     77{
     78  this->init();
     79}
     80
     81#include "resource_md2.h"
    7582/**
    7683  \brief simple constructor initializing all variables
    7784*/
    7885MD2Model::MD2Model(const std::string& modelFileName, const std::string& skinFileName, float scale)
    79 {
    80   this->setClassID(CL_MD2_MODEL, "MD2Model");
    81   /* this creates the data container via ressource manager */
    82   if (!modelFileName.empty())
    83     this->data = (MD2Data*)ResourceManager::getInstance()->load(modelFileName, MD2, RP_GAME, skinFileName, scale);
    84   if( unlikely(this->data == NULL))
    85     PRINTF(0)("The model was not found, MD2Model Loader finished abnormaly. Update the data-repos\n");
    86 
     86    : data(new MD2Data())
     87{
     88  this->init();
    8789  this->scaleFactor = scale;
    88   this->animationSpeed = 1.0f;
    89 
    90   shadeDots = MD2Model::anormsDots[0];
    91   /* set the animation stat mannualy */
    92   this->animationState.type = STAND;
    93   this->animationState.numPlays = 1;
    94   this->setAnimation(STAND);
    95 
    96   this->debug();
    97 
    98     //write the modelinfo information
     90
     91  this->data = ResourceMD2(modelFileName, skinFileName, scale).data;
     92  rebuildInfo();
     93
     94  //this->debug();
     95}
     96
     97MD2Model::MD2Model(const MD2Model& model)
     98  : data(model.data)
     99{
     100  this->init();
     101  this->rebuildInfo();
     102}
     103
     104MD2Model& MD2Model::operator=(const MD2Model& md2model)
     105{
     106  this->data = md2model.data;
     107  this->rebuildInfo();
     108  return *this;
     109}
     110
     111void MD2Model::rebuildInfo()
     112{
     113  //write the modelinfo information
    99114  this->pModelInfo.numVertices = this->data->numVertices;
    100115  this->pModelInfo.numTriangles = this->data->numTriangles;
     
    107122
    108123  // triangle conversion
     124  if (this->pModelInfo.pTriangles != NULL)
     125    delete[] this->pModelInfo.pTriangles;
    109126  this->pModelInfo.pTriangles = new sTriangleExt[this->data->numTriangles];
    110127  for( int i = 0; i < this->data->numTriangles; i++)
     
    118135    this->pModelInfo.pTriangles[i].indexToTexCoor[2] = this->data->pTriangles[i].indexToTexCoor[2];
    119136  }
     137}
     138
     139bool MD2Model::load(const std::string& modelFileName, const std::string& skinFileName, float scale)
     140{
     141  this->data = MD2Data::Pointer(new MD2Data(modelFileName, skinFileName, scale));
     142  this->rebuildInfo();
    120143}
    121144
     
    132155  this->pModelInfo.pTexCoor = NULL;
    133156  this->pModelInfo.pTriangles = NULL;
    134 
    135   ResourceManager::getInstance()->unload(this->data);
    136 }
    137 
     157}
     158
     159
     160void MD2Model::init()
     161{
     162  this->registerObject(this, MD2Model::_objectList);
     163  /* this creates the data container via ressource manager */
     164  if( unlikely(this->data.isNull()))
     165    PRINTF(0)("The model was not found, MD2Model Loader finished abnormaly. Update the data-repos\n");
     166
     167  this->scaleFactor = 1.0f;
     168  this->animationSpeed = 1.0f;
     169
     170  shadeDots = MD2Model::anormsDots[0];
     171  /* set the animation stat mannualy */
     172  this->animationState.type = STAND;
     173  this->animationState.numPlays = 1;
     174  this->setAnimation(STAND);
     175}
    138176
    139177/**
     
    153191
    154192  for( int i = 0; i < this->data->numVertices; ++i)
    155     {
    156       this->verticesList[i][0] = currVec[i][0] + this->animationState.interpolationState * (nextVec[i][0] - currVec[i][0]);
    157       this->verticesList[i][1] = currVec[i][1] + this->animationState.interpolationState * (nextVec[i][1] - currVec[i][1]);
    158       this->verticesList[i][2] = currVec[i][2] + this->animationState.interpolationState * (nextVec[i][2] - currVec[i][2]);
    159     }
     193  {
     194    this->verticesList[i][0] = currVec[i][0] + this->animationState.interpolationState * (nextVec[i][0] - currVec[i][0]);
     195    this->verticesList[i][1] = currVec[i][1] + this->animationState.interpolationState * (nextVec[i][1] - currVec[i][1]);
     196    this->verticesList[i][2] = currVec[i][2] + this->animationState.interpolationState * (nextVec[i][2] - currVec[i][2]);
     197  }
    160198}
    161199
     
    259297  /* draw the triangles */
    260298  while( int i = *(pCommands++)) /* strange looking while loop for maximum performance */
     299  {
     300    if( i < 0)
    261301    {
    262       if( i < 0)
    263         {
    264           glBegin(GL_TRIANGLE_FAN);
    265           i = -i;
    266         }
    267       else
    268         {
    269           glBegin(GL_TRIANGLE_STRIP);
    270         }
    271 
    272       for(; i > 0; i--, pCommands += 3) /* down counting for loop, next 3 gl commands */
    273         {
    274           glTexCoord2f( ((float *)pCommands)[0], ((float *)pCommands)[1] );
    275           glNormal3fv(anorms[this->data->pLightNormals[pCommands[2]]]);
    276           glVertex3fv(this->verticesList[pCommands[2]]);
    277         }
    278       glEnd();
    279 
     302      glBegin(GL_TRIANGLE_FAN);
     303      i = -i;
    280304    }
     305    else
     306    {
     307      glBegin(GL_TRIANGLE_STRIP);
     308    }
     309
     310    for(; i > 0; i--, pCommands += 3) /* down counting for loop, next 3 gl commands */
     311    {
     312      glTexCoord2f( ((float *)pCommands)[0], ((float *)pCommands)[1] );
     313      glNormal3fv(anorms[this->data->pLightNormals[pCommands[2]]]);
     314      glVertex3fv(this->verticesList[pCommands[2]]);
     315    }
     316    glEnd();
     317
     318  }
    281319  glDisable(GL_CULL_FACE);
    282320  glPopAttrib();
     
    289327  int* pCommands = this->data->pGLCommands;
    290328  /* some face culling stuff */
    291 //   glPushAttrib(GL_POLYGON_BIT);
    292 //   glFrontFace(GL_CW);
    293 //   glEnable(GL_CULL_FACE);
    294 //   glCullFace(GL_BACK);
    295 //
    296 //   this->processLighting();
    297 //   this->interpolate(/*this->verticesList*/);
     329  //   glPushAttrib(GL_POLYGON_BIT);
     330  //   glFrontFace(GL_CW);
     331  //   glEnable(GL_CULL_FACE);
     332  //   glCullFace(GL_BACK);
     333  //
     334  //   this->processLighting();
     335  //   this->interpolate(/*this->verticesList*/);
    298336  this->data->material.select();
    299337
     
    337375
    338376  if( this->animationState.localTime - this->animationState.lastTime > (1.0f / this->animationState.fps))
     377  {
     378    this->animationState.currentFrame = this->animationState.nextFrame;
     379    this->animationState.nextFrame++;
     380
     381    if( this->animationState.nextFrame > this->animationState.endFrame )
    339382    {
    340       this->animationState.currentFrame = this->animationState.nextFrame;
    341       this->animationState.nextFrame++;
    342 
    343       if( this->animationState.nextFrame > this->animationState.endFrame )
     383      if( this->animationState.animPlaybackMode == MD2_ANIM_LOOP)
    344384      {
    345         if( this->animationState.animPlaybackMode == MD2_ANIM_LOOP)
    346         {
    347           this->animationState.nextFrame = this->animationState.startFrame;
    348           this->animationState.numPlays++;
    349         }
    350         else
    351         {
    352           this->animationState.nextFrame = this->animationState.endFrame;
    353         }
     385        this->animationState.nextFrame = this->animationState.startFrame;
     386        this->animationState.numPlays++;
    354387      }
    355       this->animationState.lastTime = this->animationState.localTime;
     388      else
     389      {
     390        this->animationState.nextFrame = this->animationState.endFrame;
     391      }
    356392    }
    357 
    358 //     if( this->animationState.currentFrame > (this->data->numFrames - 1) )
    359 //       this->animationState.currentFrame = 0;
    360 
    361 //     if( (this->animationState.nextFrame > (this->data->numFrames - 1)) && this->animationState.animPlaybackMode == MD2_ANIM_LOOP)
    362 //     this->animationState.nextFrame = 0;
     393    this->animationState.lastTime = this->animationState.localTime;
     394  }
     395
     396  //     if( this->animationState.currentFrame > (this->data->numFrames - 1) )
     397  //       this->animationState.currentFrame = 0;
     398
     399  //     if( (this->animationState.nextFrame > (this->data->numFrames - 1)) && this->animationState.animPlaybackMode == MD2_ANIM_LOOP)
     400  //     this->animationState.nextFrame = 0;
    363401
    364402  this->animationState.interpolationState = this->animationState.fps *
    365     (this->animationState.localTime - this->animationState.lastTime);
     403      (this->animationState.localTime - this->animationState.lastTime);
    366404}
    367405
     
    390428  PRINT(0)("=  Number of Frames: \t%i\n", this->data->header->numFrames);
    391429  PRINT(0)("=  Height, Width:\t%i, %i\n", this->data->header->skinHeight, this->data->header->skinWidth);
    392   PRINT(0)("=  Pointer to the data object: %p\n", this->data);
     430  //PRINT(0)("=  Pointer to the data object: %p\n", this->data);
    393431  PRINT(0)("===================================================\n\n");
    394432}
     
    399437 ********************************************************************************/
    400438
     439MD2Data::MD2Data()
     440{
     441  this->init();
     442}
     443
    401444/**
    402445  \brief simple constructor
     
    404447MD2Data::MD2Data(const std::string& modelFileName, const std::string& skinFileName, float scale)
    405448{
    406   scale *= 0.1f;
    407 
     449  this->init();
     450  this->scaleFactor = scale * .1;
     451
     452  this->loadModel(modelFileName);
     453  this->loadSkin(skinFileName);
     454}
     455
     456void MD2Data::init()
     457{
     458  this->scaleFactor = 1.0;
    408459  this->pVertices = NULL;
    409460  this->pGLCommands = NULL;
    410461  this->pLightNormals = NULL;
    411462  this->pTexCoor = NULL;
     463  this->header = NULL;
    412464
    413465  this->numFrames = 0;
     
    415467  this->numGLCommands = 0;
    416468  this->numTexCoor = 0;
    417 
    418 //   this->scaleFactor = 1.0f;
    419   this->scaleFactor = scale;
    420 
    421   this->fileName = "";
    422   this->skinFileName = "";
    423   this->loadModel(modelFileName);
    424   this->loadSkin(skinFileName);
    425 }
    426 
     469}
    427470
    428471/**
     
    462505  pFile = fopen(fileName.c_str(), "rb");
    463506  if( unlikely(!pFile))
    464     {
    465       PRINTF(1)("Couldn't open the MD2 File for loading. Exiting.\n");
    466       return false;
    467     }
     507  {
     508    PRINTF(1)("Couldn't open the MD2 File for loading. Exiting.\n");
     509    return false;
     510  }
    468511  this->header = new MD2Header;
    469512  fread(this->header, 1, sizeof(MD2Header), pFile);
    470513  /* check for the header version: make sure its a md2 file :) */
    471514  if( unlikely(this->header->version != MD2_VERSION) && unlikely(this->header->ident != MD2_IDENT))
    472     {
    473       PRINTF(1)("Couldn't load file %s: invalid file format: stop loading\n", fileName.c_str());
    474       return false;
    475     }
     515  {
     516    PRINTF(1)("Couldn't load file %s: invalid file format: stop loading\n", fileName.c_str());
     517    return false;
     518  }
    476519
    477520  this->fileName =fileName;
     
    506549
    507550  for(int i = 0; i < this->numFrames; ++i)
     551  {
     552    frame = (sFrame*)(buffer + this->header->frameSize * i);
     553    pVertex = this->pVertices + this->numVertices  * i;
     554    pNormals = this->pLightNormals + this->numVertices * i;
     555
     556    for(int j = 0; j < this->numVertices; ++j)
    508557    {
    509       frame = (sFrame*)(buffer + this->header->frameSize * i);
    510       pVertex = this->pVertices + this->numVertices  * i;
    511       pNormals = this->pLightNormals + this->numVertices * i;
    512 
    513       for(int j = 0; j < this->numVertices; ++j)
    514         {
    515           /* SPEEDUP: *(pVerts + i + 0) = (*(frame->pVertices + i + 0)...  */
    516            pVertex[j][0] = ((frame->pVertices[j].v[0] * frame->scale[0] ) + frame->translate[0] )* this->scaleFactor;
    517            pVertex[j][1] = ((frame->pVertices[j].v[2] * frame->scale[2]) + frame->translate[2]) * this->scaleFactor;
    518            pVertex[j][2] = (-1.0 * (frame->pVertices[j].v[1] * frame->scale[1] + frame->translate[1])) * this->scaleFactor;
    519 
    520           //printf("vertex %i/%i: (%f, %f, %f)\n", j, this->numVertices, pVertex[j][0], pVertex[j][1], pVertex[j][2]);
    521 
    522           pNormals[j] = frame->pVertices[j].lightNormalIndex;
    523         }
     558      /* SPEEDUP: *(pVerts + i + 0) = (*(frame->pVertices + i + 0)...  */
     559      pVertex[j][0] = ((frame->pVertices[j].v[0] * frame->scale[0] ) + frame->translate[0] )* this->scaleFactor;
     560      pVertex[j][1] = ((frame->pVertices[j].v[2] * frame->scale[2]) + frame->translate[2]) * this->scaleFactor;
     561      pVertex[j][2] = (-1.0 * (frame->pVertices[j].v[1] * frame->scale[1] + frame->translate[1])) * this->scaleFactor;
     562
     563      //printf("vertex %i/%i: (%f, %f, %f)\n", j, this->numVertices, pVertex[j][0], pVertex[j][1], pVertex[j][2]);
     564
     565      pNormals[j] = frame->pVertices[j].lightNormalIndex;
    524566    }
    525     PRINTF(4)("Finished loading the md2 file\n");
     567  }
     568  PRINTF(4)("Finished loading the md2 file\n");
    526569
    527570  delete [] buffer;
     
    538581{
    539582  if( fileName.empty())
    540     {
    541       this->skinFileName = "";
    542       return false;
    543     }
     583  {
     584    this->skinFileName = "";
     585    return false;
     586  }
    544587
    545588  this->skinFileName = fileName;
  • trunk/src/lib/graphics/importer/md2/md2Model.h

    r9235 r9869  
    2020
    2121#include "base_object.h"
     22#include "count_pointer.h"
    2223
    2324#include "interactive_model.h"
     
    4546struct MD2Header
    4647{
    47    int ident;                           //!< This is used to identify the file
    48    int version;                         //!< The version number of the file (Must be 8)
    49 
    50    int skinWidth;                       //!< The skin width in pixels
    51    int skinHeight;                      //!< The skin height in pixels
    52    int frameSize;                       //!< The size in bytes the frames are
    53 
    54    int numSkins;                        //!< The number of skins associated with the model
    55    int numVertices;                     //!< The number of vertices (constant for each frame)
    56    int numTexCoords;                    //!< The number of texture coordinates
    57    int numTriangles;                    //!< The number of faces (polygons)
    58    int numGlCommands;                   //!< The number of gl commands
    59    int numFrames;                       //!< The number of animation frames
    60 
    61    int offsetSkins;                     //!< The offset in the file for the skin data
    62    int offsetTexCoords;                 //!< The offset in the file for the texture data
    63    int offsetTriangles;                 //!< The offset in the file for the face data
    64    int offsetFrames;                    //!< The offset in the file for the frames data
    65    int offsetGlCommands;                //!< The offset in the file for the gl commands data
    66    int offsetEnd;                       //!< The end of the file offset
     48  int ident;                           //!< This is used to identify the file
     49  int version;                         //!< The version number of the file (Must be 8)
     50
     51  int skinWidth;                       //!< The skin width in pixels
     52  int skinHeight;                      //!< The skin height in pixels
     53  int frameSize;                       //!< The size in bytes the frames are
     54
     55  int numSkins;                        //!< The number of skins associated with the model
     56  int numVertices;                     //!< The number of vertices (constant for each frame)
     57  int numTexCoords;                    //!< The number of texture coordinates
     58  int numTriangles;                    //!< The number of faces (polygons)
     59  int numGlCommands;                   //!< The number of gl commands
     60  int numFrames;                       //!< The number of animation frames
     61
     62  int offsetSkins;                     //!< The offset in the file for the skin data
     63  int offsetTexCoords;                 //!< The offset in the file for the texture data
     64  int offsetTriangles;                 //!< The offset in the file for the face data
     65  int offsetFrames;                    //!< The offset in the file for the frames data
     66  int offsetGlCommands;                //!< The offset in the file for the gl commands data
     67  int offsetEnd;                       //!< The end of the file offset
    6768};
    6869
     
    7071//! animation names enumeration
    7172typedef enum MD2animType
    72   {
    73     STAND,                       //0
    74     RUN,                         //1
    75     ATTACK,                      //2
    76     PAIN_A,                      //3
    77     PAIN_B,                      //4
    78     PAIN_C,          //5
    79     JUMP,            //6
    80     FLIP,            //7
    81     SALUTE,          //8
    82     FALLBACK,        //9
    83     WAVE,            //10
    84     POINT,           //11
    85     CROUCH_STAND,
    86     CROUCH_WALK,
    87     CROUCH_ATTACK,
    88     CROUCH_PAIN,
    89     CROUCH_DEATH,
    90     DEATH_FALLBACK,
    91     DEATH_FALLFORWARD,
    92     DEATH_FALLBACKSLOW,
    93     BOOM,
    94     WALK,
    95 
    96     MAX_ANIMATIONS
    97   };
     73{
     74  STAND,                       //0
     75  RUN,                         //1
     76  ATTACK,                      //2
     77  PAIN_A,                      //3
     78  PAIN_B,                      //4
     79  PAIN_C,          //5
     80  JUMP,            //6
     81  FLIP,            //7
     82  SALUTE,          //8
     83  FALLBACK,        //9
     84  WAVE,            //10
     85  POINT,           //11
     86  CROUCH_STAND,
     87  CROUCH_WALK,
     88  CROUCH_ATTACK,
     89  CROUCH_PAIN,
     90  CROUCH_DEATH,
     91  DEATH_FALLBACK,
     92  DEATH_FALLFORWARD,
     93  DEATH_FALLBACKSLOW,
     94  BOOM,
     95  WALK,
     96
     97  MAX_ANIMATIONS
     98};
    9899
    99100
     
    116117class MD2Data : public BaseObject
    117118{
    118  public:
    119    MD2Data(const std::string& modelFileName, const std::string& skinFileName, float scale = 1.0f);
     119public:
     120  typedef CountPointer<MD2Data>    Pointer;
     121public:
     122  MD2Data();
     123  MD2Data(const std::string& modelFileName, const std::string& skinFileName, float scale = 1.0f);
    120124  virtual ~MD2Data();
    121125
    122  private:
    123    bool loadModel(const std::string& fileName);
    124    bool loadSkin(const std::string& fileName = "");
    125 
    126  public:
     126private:
     127  void init();
     128  bool loadModel(const std::string& fileName);
     129  bool loadSkin(const std::string& fileName = "");
     130
     131public:
    127132  int                numFrames;             //!< number of frames
    128133  int                numVertices;           //!< number of vertices
     
    148153
    149154//! This is a MD2 Model class
    150 class MD2Model : public InteractiveModel {
    151 
    152 public:
     155class MD2Model : public InteractiveModel
     156{
     157  ObjectListDeclaration(MD2Model);
     158public:
     159  MD2Model();
    153160  MD2Model(const std::string& modelFileName, const std::string& skinFileName = "", float scale = 1.0f);
     161  MD2Model(const MD2Model& model);
    154162  virtual ~MD2Model();
     163
     164  MD2Model& operator=(const MD2Model& md2model);
     165
     166  bool load(const std::string& modelFileName, const std::string& skinFileName = "", float scale = 1.0f);
    155167
    156168  virtual void draw() const;
     
    160172  virtual void setAnimation(int firstFrame, int lastFrame, int fps, int bStoppable, int animPlayback);
    161173  /**  returns the current animation @returns animation type */
    162   inline int MD2Model::getAnimation() { return this->animationState.type; }
     174  inline int getAnimation() const { return this->animationState.type; }
    163175  virtual void setAnimationSpeed(float speed) { this->animationSpeed = speed; }
    164   virtual bool isAnimationFinished() { return (this->animationState.currentFrame == this->animationState.endFrame )?true:false; }
     176virtual bool isAnimationFinished() const { return (this->animationState.currentFrame == this->animationState.endFrame )?true:false; }
    165177  /**  scales the current model @param scaleFactor: the factor [0..1] to use for scaling */
    166178  void scaleModel(float scaleFactor) { this->scaleFactor = scaleFactor;}
    167179
     180
     181  void acquireData(const MD2Data::Pointer& data) { this->data = data; rebuildInfo(); };
     182  const MD2Data::Pointer& dataPointer() const { return this->data; };
    168183  virtual void tick(float dtS);
    169184  void debug();
     
    171186
    172187private:
     188  void init();
     189  void rebuildInfo();
     190
    173191  void animate(float time);
    174192  void processLighting();
     
    177195
    178196
    179  public:
     197public:
    180198  /* these variables are static, because they are all the same for every model */
    181   static sVec3D       anorms[NUM_VERTEX_NORMALS];       //!< the anormals
    182   static float        anormsDots[SHADEDOT_QUANT][256];  //!< the anormals dot products
    183   static sAnim        animationList[22];                //!< the anomation list
    184    //! again one of these strange id software parts
    185   float*              shadeDots;
    186 
    187   MD2Data*            data;                             //!< the md2 data pointer
    188 
    189  private:
    190   float               scaleFactor;                      //!< the scale factor (individual)
    191   float               animationSpeed;                   //!< the speed of the animation (factor for the time)
    192   sAnimState          animationState;                   //!< animation state of the model
    193   sVec3D              verticesList[MD2_MAX_VERTICES];   //!< place to temp sav the vert
     199  static sVec3D         anorms[NUM_VERTEX_NORMALS];       //!< the anormals
     200  static float          anormsDots[SHADEDOT_QUANT][256];  //!< the anormals dot products
     201  static sAnim          animationList[22];                //!< the anomation list
     202  //! again one of these strange id software parts
     203  float*                shadeDots;
     204
     205  CountPointer<MD2Data> data;                           //!< the md2 data pointer
     206
     207private:
     208  float                 scaleFactor;                      //!< the scale factor (individual)
     209  float                 animationSpeed;                   //!< the speed of the animation (factor for the time)
     210  sAnimState            animationState;                   //!< animation state of the model
     211  sVec3D                verticesList[MD2_MAX_VERTICES];   //!< place to temp sav the vert
    194212};
    195213
  • trunk/src/lib/graphics/importer/md3/md3_model.h

    r8724 r9869  
    4545
    4646    virtual void setAnimation(int animNum, int playbackMode = 0) {}
    47     virtual int getAnimation() { return 0;}
     47    virtual int getAnimation() const { return 0;}
    4848
    4949    virtual void tick(float dt);
  • trunk/src/lib/graphics/importer/media_container.cc

    r8316 r9869  
    2626
    2727#include "util/loading/resource_manager.h"
    28 
    2928/* header for debug output */
    3029#include "debug.h"
    3130
     31ObjectListDefinition(MediaContainer);
    3232
    3333/**
     
    3737{
    3838  // set the class id for the base object
    39   this->setClassID(CL_MEDIA_CONTAINER, "MediaContainer");
     39  this->registerObject(this, MediaContainer::_objectList);
    4040
    4141  fps = 0;
     
    9191    return false;
    9292  // check whether file exists
    93   if(!ResourceManager::isInDataDir(filename))
     93  if(!Resources::ResourceManager::getInstance()->checkFileInMainPath(filename))
    9494  {
    9595    PRINTF(1)("Could not find %s\n", filename.c_str());
     
    101101
    102102  // Open video file
    103   if (av_open_input_file(&format_context, ResourceManager::getFullName(filename).c_str(), NULL, 0, NULL) !=0 )
    104   {
    105     PRINTF(1)("Could not open %s\n", ResourceManager::getFullName(filename).c_str());
     103  if (av_open_input_file(&format_context, Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(filename).c_str(), NULL, 0, NULL) !=0 )
     104  {
     105    PRINTF(1)("Could not open %s\n", Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(filename).c_str());
    106106    return false;
    107107  }
     
    110110  if (av_find_stream_info(format_context) < 0)
    111111  {
    112     PRINTF(1)("Could not find stream information in %s\n", ResourceManager::getFullName(filename).c_str());
     112    PRINTF(1)("Could not find stream information in %s\n", Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(filename).c_str());
    113113    return false;
    114114  }
     
    119119  if(video_stream == -1)
    120120  {
    121     PRINTF(1)("Could not find a video stream in %s\n", ResourceManager::getFullName(filename).c_str());
     121    PRINTF(1)("Could not find a video stream in %s\n", Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(filename).c_str());
    122122    return false;
    123123  }
  • trunk/src/lib/graphics/importer/media_container.h

    r7221 r9869  
    2424class MediaContainer : public TextureSequence
    2525{
    26 
     26  ObjectListDeclaration(MediaContainer);
    2727private:
    2828
  • trunk/src/lib/graphics/importer/model.cc

    r9406 r9869  
    2020#include "glincl.h"
    2121
    22 
     22ObjectListDefinition(Model);
    2323
    2424/**
     
    2828Model::Model()
    2929{
    30   this->setClassID(CL_MODEL, "Model");
     30  this->registerObject(this, Model::_objectList);
    3131  this->pModelInfo.numVertices = 0;
    3232  this->pModelInfo.numTriangles = 0;
  • trunk/src/lib/graphics/importer/model.h

    r8035 r9869  
    5454//! This class defines the basic components of a model
    5555class Model : virtual public BaseObject {
     56  ObjectListDeclaration(Model);
    5657
    5758  public:
  • trunk/src/lib/graphics/importer/movie_player.cc

    r7221 r9869  
    2424// include your own header
    2525#include "movie_player.h"
    26 
    2726#include "util/loading/resource_manager.h"
    2827
     
    3029#include "debug.h"
    3130
     31ObjectListDefinition(MoviePlayer);
    3232
    3333MoviePlayer::MoviePlayer(const std::string& filename)
    3434{
    3535  // set the class id for the base object
    36   this->setClassID(CL_MOVIE_PLAYER, "MoviePlayer");
    37 
     36  this->registerObject(this, MoviePlayer::_objectList);
    3837  status = STOP;
    3938  timer = 0;
     
    9089    return false;
    9190  // check whether file exists
    92   if(!ResourceManager::isInDataDir(filename))
     91  if(!Resources::ResourceManager::getInstance()->checkFileInMainPath(filename))
    9392  {
    9493    PRINTF(1)("Could not find %s\n", filename.c_str());
     
    10099
    101100  // Open video file
    102   if (av_open_input_file(&format_context, ResourceManager::getFullName(filename).c_str(), NULL, 0, NULL) !=0 )
    103   {
    104     PRINTF(1)("Could not open %s\n", ResourceManager::getFullName(filename).c_str());
     101  if (av_open_input_file(&format_context, Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(filename).c_str(), NULL, 0, NULL) !=0 )
     102  {
     103    PRINTF(1)("Could not open %s\n", Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(filename).c_str());
    105104    return false;
    106105  }
     
    109108  if (av_find_stream_info(format_context) < 0)
    110109  {
    111     PRINTF(1)("Could not find stream information in %s\n", ResourceManager::getFullName(filename).c_str());
     110    PRINTF(1)("Could not find stream information in %s\n", Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(filename).c_str());
    112111    return false;
    113112  }
     
    118117  if(video_stream == -1)
    119118  {
    120     PRINTF(1)("Could not find a video stream in %s\n", ResourceManager::getFullName(filename).c_str());
     119    PRINTF(1)("Could not find a video stream in %s\n", Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(filename).c_str());
    121120    return false;
    122121  }
  • trunk/src/lib/graphics/importer/movie_player.h

    r7221 r9869  
    3131class MoviePlayer : public BaseObject
    3232{
     33  ObjectListDeclaration(MoviePlayer);
    3334
    3435private:
  • trunk/src/lib/graphics/importer/objModel.cc

    r8369 r9869  
    1818#include "objModel.h"
    1919
    20 #include <stdio.h>
    2120#include <string.h>
    22 #include <stdlib.h>
     21#include "loading/resource_manager.h"
    2322
    2423#define PARSELINELENGTH 8192
     
    2726#include "compiler.h"
    2827
     28ObjectListDefinition(OBJModel);
    2929/**
    3030 * @brief Crates a 3D-Model, loads in a File and scales it.
     
    3535  : StaticModel(fileName)
    3636{
    37   this->setClassID(CL_OBJ_MODEL, "OBJModel");
     37  this->registerObject(this, OBJModel::_objectList);
    3838
    3939  this->objPath = "./";
    4040
    41   this->scaleFactor = scaling;
     41  this->setScaleFactor(scaling);
    4242
    4343  this->importFile (fileName);
     
    7777  else
    7878    this->objPath = "./";
    79   Material::addTexturePath(this->objPath);
     79  Resources::ResourceManager::getInstance()->addResourcePath("Texture", this->objPath);
    8080
    8181  this->readFromObjFile (fileName);
  • trunk/src/lib/graphics/importer/objModel.h

    r8369 r9869  
    1212class OBJModel : public StaticModel
    1313{
    14  public:
    15    OBJModel(const std::string& fileName, float scaling = 1.0);
     14  ObjectListDeclaration(OBJModel);
     15public:
     16  OBJModel(const std::string& fileName, float scaling = 1.0);
    1617  virtual ~OBJModel();
    1718
    18  private:
     19private:
    1920  ///// readin /////
    20    bool importFile (const std::string& fileName);
    21    bool readFromObjFile (const std::string& fileName);
    22    bool readMtlLib (const std::string& matFile);
     21  bool importFile (const std::string& fileName);
     22  bool readFromObjFile (const std::string& fileName);
     23  bool readMtlLib (const std::string& matFile);
    2324
    24   private:
    25    void setIllum (Material* material, const char* illum);
    26    void setDiffuse (Material* material, const char* rgb);
    27    void setAmbient (Material* material, const char* rgb);
    28    void setSpecular (Material* material, const char* rgb);
    29    void setShininess (Material* material, const char* shini);
    30    void setTransparency (Material* material, const char* trans);
     25private:
     26  void setIllum (Material* material, const char* illum);
     27  void setDiffuse (Material* material, const char* rgb);
     28  void setAmbient (Material* material, const char* rgb);
     29  void setSpecular (Material* material, const char* rgb);
     30  void setShininess (Material* material, const char* shini);
     31  void setTransparency (Material* material, const char* trans);
    3132
    32  private:
    33    std::string       objPath;     //!< The Path where the obj and mtl-file are located.
     33private:
     34  std::string       objPath;     //!< The Path where the obj and mtl-file are located.
    3435};
    3536
  • trunk/src/lib/graphics/importer/static_model.cc

    r9406 r9869  
    2626
    2727
    28 ////////////////////
    29 /// SUB-Elements ///
    30 ////////////////////
    31 /**
    32  * @brief creates a new ModelFaceElement
    33  */
    34 ModelFaceElement::ModelFaceElement()
    35 {
    36   this->vertexNumber = -1;
    37   this->normalNumber = -1;
    38   this->texCoordNumber = -1;
    39 
    40   this->next = NULL;
    41 }
    42 
    43 /**
    44  * @brief destroys a ModelFaceElement
    45  */
    46 ModelFaceElement::~ModelFaceElement()
    47 {
    48   if (this->next)
    49     delete this->next;
    50 }
    51 
    52 /**
    53  * @brief creates a new ModelFace
    54  */
    55 ModelFace::ModelFace()
    56 {
    57   this->vertexCount = 0;
    58 
    59   this->firstElem = NULL;
    60 
    61   this->material = NULL;
    62 
    63   this->next = NULL;
    64 }
    65 
    66 /**
    67  *  deletes a ModelFace
    68 */
    69 ModelFace::~ModelFace()
    70 {
    71   PRINTF(5)("Cleaning up Face\n");
    72 
    73   if (this->firstElem != NULL)
    74     delete this->firstElem;
    75 
    76   if (this->next != NULL)
    77     delete this->next;
    78 }
    79 
    80 /**
    81  * @brief Creates a new ModelGroup
    82  */
    83 ModelGroup::ModelGroup()
    84 {
    85   PRINTF(4)("Adding new Group\n");
    86   this->name = "";
    87   this->faceMode = -1;
    88   this->faceCount = 0;
    89   this->next = NULL;
    90   this->listNumber = 0;
    91   this->indices = NULL;
    92 
    93   this->firstFace = new ModelFace;
    94   this->currentFace = this->firstFace;
    95 }
    96 
    97 /**
    98  * @brief deletes a ModelGroup
    99  */
    100 ModelGroup::~ModelGroup()
    101 {
    102   PRINTF(5)("Cleaning up group\n");
    103   if (this->firstFace != NULL)
    104     delete this->firstFace;
    105 
    106   // deleting the glList
    107   if (this->listNumber != 0)
    108     glDeleteLists(this->listNumber, 1);
    109 
    110   if (this->next !=NULL)
    111     delete this->next;
    112 
    113 }
    114 
    115 /**
    116  * @brief cleans up a ModelGroup
    117  *
    118  * actually does the same as the delete Operator, but does not delete the predecessing group
    119  */
    120 void ModelGroup::cleanup()
    121 {
    122   PRINTF(5)("Cleaning up group\n");
    123   if (this->firstFace)
    124     delete this->firstFace;
    125   this->firstFace = NULL;
    126   if (this->next)
    127     this->next->cleanup();
    128 }
    129 
    130 
    13128/////////////
    13229/// MODEL ///
    13330/////////////
     31ObjectListDefinition(StaticModel);
     32
    13433/**
    13534 * @brief Creates a 3D-Model.
     
    13837 */
    13938StaticModel::StaticModel(const std::string& modelName)
     39    : data(new StaticModelData(modelName))
    14040{
    141   this->setClassID(CL_STATIC_MODEL, "StaticModel");
     41  this->registerObject(this, StaticModel::_objectList);
    14242  PRINTF(4)("new 3D-Model is being created\n");
    14343  this->setName(modelName);
     44}
    14445
    145   this->finalized = false;
     46StaticModel::StaticModel(const StaticModel& staticModel)
     47  : data(staticModel.data)
     48{
     49  this->registerObject(this, StaticModel::_objectList);
     50  this->setName(staticModel.getName());
     51  this->updateBase();
     52}
    14653
    147   // setting the start group;
    148   this->currentGroup = this->firstGroup = new ModelGroup;
    149   this->groupCount = 0;
    150   this->faceCount = 0;
    151 
    152   this->scaleFactor = 1.0f;
    153 }
    15454
    15555/**
     
    16161{
    16262  PRINTF(4)("Deleting Model ");
    163   if (!this->getName().empty())
    164   {
    165     PRINT(4)("%s\n", this->getCName());
    166   }
    167   else
    168   {
    169     PRINT(4)("\n");
    170   }
    171   this->cleanup();
    172 
    173   PRINTF(5)("Deleting display Lists.\n");
    174   delete this->firstGroup;
    175 
    176   // deleting the MaterialList
    177   PRINTF(5)("Deleting Materials.\n");
    178 
    179   //! @todo do we really have to delete this material??
    180   std::list<ModelMaterial*>::iterator modMat;
    181   for(modMat = this->materialList.begin(); modMat != this->materialList.end(); modMat++)
    182   {
    183     if (!(*modMat)->external)
    184       delete (*modMat)->material;
    185     delete (*modMat);
    186   }
    18763
    18864  // mark this stuff as beeing deleted
     
    19066  this->pModelInfo.pNormals = NULL;
    19167  this->pModelInfo.pTexCoor = NULL;
     68  this->pModelInfo.pTriangles = NULL;
    19269}
     70
     71StaticModel& StaticModel::operator=(const StaticModel& model)
     72{
     73  this->data = model.data;
     74  this->updateBase();
     75  return *this;
     76};
     77
    19378
    19479/**
     
    19782void StaticModel::finalize()
    19883{
    199   // this creates the display List.
    200   this->importToDisplayList();
    201   this->buildTriangleList();
    202 
    203   // write out the modelInfo data used for the collision detection!
    204   this->pModelInfo.pVertices = &this->vertices[0];
    205   this->pModelInfo.pNormals = &this->normals[0];
    206   this->pModelInfo.pTexCoor = &this->vTexture[0];
    207 
    208   this->finalized = true;
     84  data->finalize();
     85  this->updateBase();
    20986}
    21087
    211 /**
    212  * @brief rebuild the Model from the Information we got.
    213  */
    214 void StaticModel::rebuild()
     88void StaticModel::acquireData(const StaticModelData::Pointer& data)
    21589{
    216   PRINTF(3)("Rebuilding Model '%s'\n", this->getCName());
    217   this->finalize();
    218 }
    219 
    220 //////////
    221 // DRAW //
    222 //////////
    223 /**
    224  * @brief Draws the Models of all Groups.
    225  *
    226  * It does this by just calling the Lists that must have been created earlier.
    227  */
    228 void StaticModel::draw () const
    229 {
    230   PRINTF(4)("drawing the 3D-Models\n");
    231   ModelGroup* tmpGroup = this->firstGroup;
    232   while (tmpGroup != NULL)
    233   {
    234     PRINTF(5)("Drawing model %s\n", tmpGroup->name.c_str());
    235     glCallList (tmpGroup->listNumber);
    236     tmpGroup = tmpGroup->next;
    237   }
    238 }
    239 
    240 
    241 /**
    242  * @brief Draws the Model number groupNumber
    243  * @param groupNumber The number of the group that will be displayed.
    244  *
    245  * It does this by just calling the List that must have been created earlier.
    246  */
    247 void StaticModel::draw (int groupNumber) const
    248 {
    249   if (unlikely(groupNumber >= this->groupCount))
    250   {
    251     PRINTF(2)("You requested model number %i, but this File only contains of %i Models.\n", groupNumber-1, this->groupCount);
    252     return;
    253   }
    254   PRINTF(4)("drawing the requested 3D-Models if found.\n");
    255   ModelGroup* tmpGroup = this->firstGroup;
    256   int counter = 0;
    257   while (tmpGroup != NULL)
    258   {
    259     if (counter == groupNumber)
    260     {
    261       PRINTF(4)("Drawing model number %i named %s\n", counter, tmpGroup->name.c_str());
    262       glCallList (tmpGroup->listNumber);
    263       return;
    264     }
    265     ++counter;
    266     tmpGroup = tmpGroup->next;
    267   }
    268   PRINTF(2)("Model number %i in %s not Found.\n", groupNumber, this->getCName());
    269   return;
    270 }
    271 
    272 
    273 /**
    274  * @brief Draws the Model with a specific groupName
    275  * @param groupName The name of the group that will be displayed.
    276  *
    277  * It does this by just calling the List that must have been created earlier.
    278  */
    279 void StaticModel::draw (const std::string& groupName) const
    280 {
    281   PRINTF(4)("drawing the requested 3D-Models if found.\n");
    282   ModelGroup* tmpGroup = this->firstGroup;
    283   while (tmpGroup != NULL)
    284   {
    285     if (tmpGroup->name == groupName)
    286     {
    287       PRINTF(4)("Drawing model %s\n", tmpGroup->name.c_str());
    288       glCallList (tmpGroup->listNumber);
    289       return;
    290     }
    291     tmpGroup = tmpGroup->next;
    292   }
    293   PRINTF(2)("Model Named %s in %s not Found.\n", groupName.c_str(), this->getCName());
    294   return;
    295 }
    296 
    297 //////////
    298 // INIT //
    299 //////////
    300 
    301 /**
    302  * @brief finalizes an Model.
    303  *
    304  * This funcion is needed, to delete all the Lists, and arrays that are no more
    305  * needed because they are already imported into openGL.
    306  * This will be applied at the end of the importing Process.
    307 */
    308 bool StaticModel::cleanup()
    309 {
    310   PRINTF(4)("cleaning up the 3D-Model to save Memory.\n");
    311   this->firstGroup->cleanup();
    312   return true;
    313 }
    314 
    315 //////////
    316 // MESH //
    317 //////////
    318 /**
    319  * @brief adds a new Material to the Material List
    320  * @param material the Material to add
    321  * @returns the added material
    322  *
    323  * this also tells this Model, that all the Materials are handled externally
    324  * with this option set the Materials will not be deleted with the Model.
    325  */
    326 Material* StaticModel::addMaterial(Material* material)
    327 {
    328   if (material == NULL)
    329     return NULL;
    330   ModelMaterial* modMat = new ModelMaterial;
    331   modMat->external = true;
    332   modMat->material = material;
    333   this->materialList.push_back(modMat);
    334   return modMat->material;
    335 }
    336 
    337 /**
    338  * @brief adds a new Material to the Material List
    339  * @param materialName the name of the Material to add
    340  * @returns the added material
    341  */
    342 Material* StaticModel::addMaterial(const std::string& materialName)
    343 {
    344   ModelMaterial* modMat = new ModelMaterial;
    345   modMat->external = false;
    346   modMat->material = new Material(materialName);
    347 
    348   // adding material to the List of materials
    349   this->materialList.push_back(modMat);
    350   return modMat->material;
    351 }
    352 
    353 /**
    354  * @brief finds a Material by its name and returns it
    355  * @param materialName the Name of the material to search for.
    356  * @returns the Material if found, NULL otherwise
    357  */
    358 Material* StaticModel::findMaterialByName(const std::string& materialName)
    359 {
    360   std::list<ModelMaterial*>::iterator modMat;
    361   for  (modMat = this->materialList.begin(); modMat != this->materialList.end(); modMat++)
    362     if (materialName == (*modMat)->material->getName())
    363       return (*modMat)->material;
    364   return NULL;
    365 }
    366 
    367 /**
    368  * @brief parses a group String
    369  * @param groupString the new Group to create
    370  *
    371  * This function initializes a new Group.
    372  * With it you should be able to create Models with more than one SubModel inside
    373  */
    374 bool StaticModel::addGroup(const std::string& groupString)
    375 {
    376   PRINTF(5)("Read Group: %s.\n", groupString.c_str());
    377   if (this->groupCount != 0 && this->currentGroup->faceCount > 0)
    378   {
    379     // finalizeGroup(currentGroup);
    380     this->currentGroup = this->currentGroup->next = new ModelGroup;
    381   }
    382   // setting the group name if not default.
    383   if (groupString == "default")
    384   {
    385     this->currentGroup->name = groupString;
    386   }
    387   ++this->groupCount;
    388   return true;
    389 }
    390 
    391 /**
    392  * @brief parses a vertex-String
    393  * @param vertexString The String that will be parsed.
    394  *
    395  *  If a vertex line is found this function will inject it into the vertex-Array
    396  */
    397 bool StaticModel::addVertex (const std::string& vertexString)
    398 {
    399   float subbuffer1;
    400   float subbuffer2;
    401   float subbuffer3;
    402   sscanf (vertexString.c_str(), "%f %f %f", &subbuffer1, &subbuffer2, &subbuffer3);
    403   this->vertices.push_back(subbuffer1*scaleFactor);
    404   this->vertices.push_back(subbuffer2*scaleFactor);
    405   this->vertices.push_back(subbuffer3*scaleFactor);
    406   this->pModelInfo.numVertices++;
    407   return true;
    408 }
    409 
    410 /**
    411  * @brief parses a vertex-String
    412  * @param x the X-coordinate of the Vertex to add.
    413  * @param y the Y-coordinate of the Vertex to add.
    414  * @param z the Z-coordinate of the Vertex to add.
    415  */
    416 bool StaticModel::addVertex(float x, float y, float z)
    417 {
    418   PRINTF(5)("reading in a vertex: %f %f %f\n", x, y, z);
    419   this->vertices.push_back(x*scaleFactor);
    420   this->vertices.push_back(y*scaleFactor);
    421   this->vertices.push_back(z*scaleFactor);
    422   this->pModelInfo.numVertices++;
    423   return true;
    424 }
    425 
    426 /**
    427  * @brief parses a vertexNormal-String
    428  * @param normalString The String that will be parsed.
    429  *
    430  * If a vertexNormal line is found this function will inject it into the vertexNormal-Array
    431  */
    432 bool StaticModel::addVertexNormal (const std::string& normalString)
    433 {
    434   float subbuffer1;
    435   float subbuffer2;
    436   float subbuffer3;
    437   sscanf (normalString.c_str(), "%f %f %f", &subbuffer1, &subbuffer2, &subbuffer3);
    438   this->normals.push_back(subbuffer1);
    439   this->normals.push_back(subbuffer2);
    440   this->normals.push_back(subbuffer3);
    441   this->pModelInfo.numNormals++;
    442   return true;
    443 }
    444 
    445 /**
    446  * @brief adds a VertexNormal.
    447  * @param x The x coordinate of the Normal.
    448  * @param y The y coordinate of the Normal.
    449  * @param z The z coordinate of the Normal.
    450  *
    451  * If a vertexNormal line is found this function will inject it into the vertexNormal-Array
    452  */
    453 bool StaticModel::addVertexNormal(float x, float y, float z)
    454 {
    455   PRINTF(5)("found vertex-Normal %f, %f, %f\n", x, y, z);
    456   this->normals.push_back(x);
    457   this->normals.push_back(y);
    458   this->normals.push_back(z);
    459   this->pModelInfo.numNormals++;
    460   return true;
    461 }
    462 
    463 /**
    464  * @brief parses a vertexTextureCoordinate-String
    465  * @param vTextureString The String that will be parsed.
    466  *
    467  * If a vertexTextureCoordinate line is found,
    468  * this function will inject it into the vertexTexture-Array
    469  *
    470  * !! WARNING THIS IS DIFFERNT FROM addVervexTexture(float, float); because it changes the second entry to 1-v !!
    471  */
    472 bool StaticModel::addVertexTexture (const std::string& vTextureString)
    473 {
    474   float subbuffer1;
    475   float subbuffer2;
    476   sscanf (vTextureString.c_str(), "%f %f", &subbuffer1, &subbuffer2);
    477   this->vTexture.push_back(subbuffer1);
    478   this->vTexture.push_back(1 - subbuffer2);
    479   this->pModelInfo.numTexCoor++;
    480   return true;
    481 }
    482 
    483 /**
    484  * @brief adds a Texture Coordinate
    485  * @param u The u coordinate of the TextureCoordinate.
    486  * @param v The y coordinate of the TextureCoordinate.
    487  *
    488  * If a TextureCoordinate line is found this function will
    489  *  inject it into the TextureCoordinate-Array
    490  */
    491 bool StaticModel::addVertexTexture(float u, float v)
    492 {
    493   PRINTF(5)("found vertex-Texture %f, %f\n", u, v);
    494   this->vTexture.push_back(u);
    495   this->vTexture.push_back(v);
    496   this->pModelInfo.numTexCoor++;
    497   return true;
    498 }
    499 
    500 /**
    501  * @brief parses a face-string
    502  * @param faceString The String that will be parsed.
    503  *
    504  * If a face line is found this function will add it to the glList.
    505  *
    506  * String is different from the argument addFace,
    507  * in this, that the first Vertex/Normal/Texcoord is 1 instead of 0
    508  *
    509  * @TODO make it std::string conform
    510  */
    511 bool StaticModel::addFace (const std::string& faceStringInput)
    512 {
    513   const char* faceString = faceStringInput.c_str();
    514   if (this->currentGroup->faceCount >0)
    515     this->currentGroup->currentFace = this->currentGroup->currentFace->next = new ModelFace;
    516 
    517   ModelFaceElement* tmpElem = this->currentGroup->currentFace->firstElem = new ModelFaceElement;
    518   tmpElem->next = NULL;
    519   while(strcmp (faceString, "\0"))
    520   {
    521     if (this->currentGroup->currentFace->vertexCount>0)
    522       tmpElem = tmpElem->next = new ModelFaceElement;
    523     tmpElem->next = NULL;
    524 
    525     char tmpValue [50];
    526     int tmpLen;
    527     char* vertex = NULL;
    528     char* texture = NULL;
    529     char* normal = NULL;
    530 
    531     sscanf (faceString, "%s", tmpValue);
    532     tmpLen = strlen(tmpValue);
    533     vertex = tmpValue;
    534 
    535     if ((texture = strstr (vertex, "/")) != NULL)
    536     {
    537       texture[0] = '\0';
    538       texture ++;
    539 
    540       if ((normal = strstr (texture, "/")) !=NULL)
    541       {
    542         normal[0] = '\0';
    543         normal ++;
    544       }
    545     }
    546     if (vertex)
    547       tmpElem->vertexNumber = atoi(vertex)-1;
    548     if (texture)
    549       tmpElem->texCoordNumber = atoi(texture)-1;
    550     if (normal)
    551       tmpElem->normalNumber = atoi(normal)-1;
    552 
    553     faceString += tmpLen;
    554     if (strcmp (faceString, "\0"))
    555       faceString++;
    556     this->currentGroup->currentFace->vertexCount++;
    557   }
    558 
    559   this->currentGroup->faceCount += this->currentGroup->currentFace->vertexCount -2;
    560   this->faceCount += this->currentGroup->currentFace->vertexCount -2;
    561   return true;
     90  this->data = data;
     91  this->updateBase();
    56292}
    56393
     
    56999bool StaticModel::addFace(int faceElemCount, VERTEX_FORMAT type, ...)
    570100{
    571   if (this->currentGroup->faceCount > 0)
    572     this->currentGroup->currentFace = this->currentGroup->currentFace->next = new ModelFace;
    573 
    574   ModelFaceElement* tmpElem = this->currentGroup->currentFace->firstElem = new ModelFaceElement;
    575 
    576101  va_list itemlist;
    577102  va_start (itemlist, type);
    578 
    579   for (int i = 0; i < faceElemCount; i++)
    580   {
    581     if (this->currentGroup->currentFace->vertexCount > 0)
    582       tmpElem = tmpElem->next = new ModelFaceElement;
    583 
    584     tmpElem->vertexNumber = va_arg (itemlist, int);
    585     if (type & TEXCOORD)
    586       tmpElem->texCoordNumber = va_arg (itemlist, int);
    587     if (type & NORMAL)
    588       tmpElem->normalNumber = va_arg(itemlist, int);
    589     this->currentGroup->currentFace->vertexCount++;
    590   }
     103  bool retVal = this->data->addFace(faceElemCount, type, itemlist);
    591104  va_end(itemlist);
    592 
    593   this->currentGroup->faceCount += this->currentGroup->currentFace->vertexCount - 2;
    594   this->faceCount += this->currentGroup->currentFace->vertexCount -2;
    595   return true;
     105  return retVal;
    596106}
    597107
    598 /**
    599  * Function that selects a material, if changed in the obj file.
    600  * @param matString the Material that will be set.
    601 */
    602 bool StaticModel::setMaterial(const std::string& matString)
     108void StaticModel::updateBase()
    603109{
    604   if (this->currentGroup->faceCount > 0)
    605     this->currentGroup->currentFace = this->currentGroup->currentFace->next = new ModelFace;
     110  // write out the modelInfo data used for the collision detection!
     111  this->pModelInfo.pVertices = &this->data->getVertices()[0];
     112  this->pModelInfo.numVertices = this->data->getVertices().size();
     113  this->pModelInfo.pNormals = &this->data->getNormals()[0];
     114  this->pModelInfo.numNormals = this->data->getNormals().size();
     115  this->pModelInfo.pTexCoor = &this->data->getTexCoords()[0];
     116  this->pModelInfo.numTexCoor = this->data->getTexCoords().size();
    606117
    607   this->currentGroup->currentFace->material = this->findMaterialByName(matString);
    608 
    609   if (this->currentGroup->faceCount == 0)
    610     this->currentGroup->faceCount++;
    611   return true;
    612 }
    613 
    614 /**
    615  * Function that selects a material, if changed in the obj file.
    616  * @param mtl the Material that will be set.
    617 */
    618 bool StaticModel::setMaterial(Material* mtl)
    619 {
    620   if (this->currentGroup->faceCount > 0)
    621     this->currentGroup->currentFace = this->currentGroup->currentFace->next = new ModelFace;
    622 
    623   this->currentGroup->currentFace->material = mtl;
    624 
    625   if (this->currentGroup->faceCount == 0)
    626     this->currentGroup->faceCount++;
    627   return true;
    628 }
    629 
    630 /**
    631  * @brief A routine that is able to create normals.
    632  *
    633  * The algorithm does the following:
    634  * 1. It calculates creates Vectors for each normale, and sets them to zero.
    635  * 2. It then Walks through a) all the Groups b) all the Faces c) all the FaceElements
    636  * 3. It searches for a points two neighbours per Face, takes Vecotrs to them calculates FaceNormals and adds it to the Points Normal.
    637  * 4. It goes through all the normale-Points and calculates the VertexNormale and includes it in the normals-Array.
    638  */
    639 bool StaticModel::buildVertexNormals ()
    640 {
    641   PRINTF(4)("Normals are being calculated.\n");
    642 
    643   Vector* normArray = new Vector [vertices.size()/3];
    644   for (unsigned int i=0; i<vertices.size()/3;i++)
    645     normArray[i] = Vector(.0,.0,.0);
    646 
    647   Vector prevV;
    648   Vector nextV;
    649   Vector curV;
    650 
    651   ModelGroup* tmpGroup = firstGroup;
    652   while (tmpGroup != NULL)
    653   {
    654     ModelFace* tmpFace = tmpGroup->firstFace;
    655     while (tmpFace != NULL)
    656     {
    657       if (tmpFace->firstElem != NULL)
    658       {
    659         ModelFaceElement* firstElem = tmpFace->firstElem;
    660         ModelFaceElement* prevElem;
    661         ModelFaceElement* curElem = firstElem;
    662         ModelFaceElement* nextElem;
    663         ModelFaceElement* lastElem;
    664         // find last Element of the Chain. !! IMPORTANT:the last Element of the Chain must point to NULL, or it will resolv into an infinity-loop.
    665         while (curElem != NULL)
    666         {
    667           prevElem = curElem;
    668           curElem = curElem->next;
    669         }
    670         lastElem = prevElem;
    671 
    672         curElem = firstElem;
    673         for (unsigned int j = 0; j < tmpFace->vertexCount; j++)
    674         {
    675           if (!(nextElem = curElem->next))
    676             nextElem = firstElem;
    677           curElem->normalNumber = curElem->vertexNumber;
    678 
    679           curV = Vector (this->vertices[curElem->vertexNumber*3],
    680                          this->vertices[curElem->vertexNumber*3+1],
    681                          this->vertices[curElem->vertexNumber*3+2]);
    682 
    683           prevV = Vector (this->vertices[prevElem->vertexNumber*3],
    684                           this->vertices[prevElem->vertexNumber*3+1],
    685                           this->vertices[prevElem->vertexNumber*3+2]) - curV;
    686 
    687           nextV = Vector (this->vertices[nextElem->vertexNumber*3],
    688                           this->vertices[nextElem->vertexNumber*3+1],
    689                           this->vertices[nextElem->vertexNumber*3+2]) - curV;
    690           normArray[curElem->vertexNumber] = normArray[curElem->vertexNumber] + nextV.cross(prevV);
    691 
    692           prevElem = curElem;
    693           curElem = curElem->next;
    694         }
    695       }
    696       tmpFace = tmpFace->next;
    697     }
    698     tmpGroup = tmpGroup->next;
    699   }
    700 
    701   for (unsigned int i=0; i < this->vertices.size()/3;i++)
    702   {
    703     normArray[i].normalize();
    704     PRINTF(5)("Found Normale number %d: (%f; %f, %f).\n", i, normArray[i].x, normArray[i].y, normArray[i].z);
    705 
    706     this->addVertexNormal(normArray[i].x, normArray[i].y, normArray[i].z);
    707 
    708   }
    709   delete[] normArray;
    710   return true;
    711 }
    712 
    713 ////////////
    714 // openGL //
    715 ////////////
    716 /**
    717  *  reads and includes the Faces/Materials into the openGL state Machine
    718 */
    719 bool StaticModel::importToDisplayList()
    720 {
    721   // finalize the Arrays
    722   if (normals.size() == 0) // vertices-Array must be built for this
    723     this->buildVertexNormals();
    724 
    725   this->currentGroup = this->firstGroup;
    726 
    727   while (this->currentGroup != NULL)
    728   {
    729 
    730     // creating a glList for the Group
    731     if ((this->currentGroup->listNumber = glGenLists(1)) == 0)
    732     {
    733       PRINTF(2)("glList could not be created for this Model\n");
    734       return false;
    735     }
    736     glNewList (this->currentGroup->listNumber, GL_COMPILE);
    737 
    738     // Putting Faces to GL
    739     ModelFace* tmpFace = this->currentGroup->firstFace;
    740     while (tmpFace != NULL)
    741     {
    742       if (tmpFace->vertexCount == 0 && tmpFace->material != NULL)
    743       {
    744         if (this->currentGroup->faceMode != -1)
    745           glEnd();
    746         this->currentGroup->faceMode = 0;
    747         if (tmpFace->material != NULL)
    748         {
    749           tmpFace->material->select();
    750           PRINTF(5)("using material %s for coming Faces.\n", tmpFace->material->getCName());
    751         }
    752       }
    753 
    754       else if (tmpFace->vertexCount == 3)
    755       {
    756         if (this->currentGroup->faceMode != 3)
    757         {
    758           if (this->currentGroup->faceMode != -1)
    759             glEnd();
    760           glBegin(GL_TRIANGLES);
    761         }
    762 
    763         this->currentGroup->faceMode = 3;
    764         PRINTF(5)("found triag.\n");
    765       }
    766 
    767       else if (tmpFace->vertexCount == 4)
    768       {
    769         if (this->currentGroup->faceMode != 4)
    770         {
    771           if (this->currentGroup->faceMode != -1)
    772             glEnd();
    773           glBegin(GL_QUADS);
    774         }
    775         this->currentGroup->faceMode = 4;
    776         PRINTF(5)("found quad.\n");
    777       }
    778 
    779       else if (tmpFace->vertexCount > 4)
    780       {
    781         if (this->currentGroup->faceMode != -1)
    782           glEnd();
    783         glBegin(GL_POLYGON);
    784         PRINTF(5)("Polygon with %i faces found.", tmpFace->vertexCount);
    785         this->currentGroup->faceMode = tmpFace->vertexCount;
    786       }
    787 
    788       ModelFaceElement* tmpElem = tmpFace->firstElem;
    789       while (tmpElem != NULL)
    790       {
    791         //      PRINTF(2)("%s\n", tmpElem->value);
    792         this->addGLElement(tmpElem);
    793         tmpElem = tmpElem->next;
    794       }
    795       tmpFace = tmpFace->next;
    796     }
    797     glEnd();
    798     glEndList();
    799 
    800     this->currentGroup = this->currentGroup->next;
    801   }
    802   return true;
     118  this->pModelInfo.pTriangles = this->data->getTrianglesExt();
     119  this->pModelInfo.numTriangles = this->data->getTriangles().size();
    803120}
    804121
    805122
    806123/**
    807  *  builds an array of triangles, that can later on be used for obb separation and octree separation
     124 *  Includes a default model
     125 *
     126 * This will inject a Cube, because this is the most basic model.
    808127 */
    809 bool StaticModel::buildTriangleList()
    810 {
    811   if( unlikely(this->pModelInfo.pTriangles != NULL))
    812     return true;
    813   /* make sure, that all the arrays are finalized */
    814   if( normals.size() == 0) // vertices-Array must be built for this
    815     this->buildVertexNormals();
    816 
    817   int                index = 0;                   //!< the counter for the triangle array
    818   ModelFaceElement*  tmpElem;       //!< the temporary faceelement reference
    819   ModelFace*         tmpFace;              //!< the temporary face referece
    820 
    821   bool warned = false;
    822 
    823   this->pModelInfo.numTriangles = 0;
    824 
    825   /* count the number of triangles */
    826   /* now iterate through all groups and build up the triangle list */
    827   this->currentGroup = this->firstGroup;
    828   while( this->currentGroup != NULL)
    829   {
    830     tmpFace = this->currentGroup->firstFace;
    831     while( tmpFace != NULL)
    832     {
    833       /* if its a triangle just add it to the list */
    834       if( tmpFace->vertexCount == 3){
    835         ++this->pModelInfo.numTriangles;
    836       } /* if the polygon is a quad */
    837       else if( tmpFace->vertexCount == 4) {
    838         this->pModelInfo.numTriangles += 2;
    839       }
    840       else if( tmpFace->vertexCount > 4) {
    841         if (!warned)        {
    842           PRINTF(2)("This model (%s) got over 4 vertices per face <=> conflicts in the CD engine!\n", this->getCName());
    843           warned = true;
    844         }
    845       }
    846       tmpFace = tmpFace->next;
    847     }
    848     this->currentGroup = this->currentGroup->next;
    849   }
    850 
    851   PRINTF(3)("got %i triangles, %i vertices\n", this->pModelInfo.numTriangles, this->pModelInfo.numVertices);
    852 
    853 
    854   /* write MODELINFO structure */
    855 
    856   /* allocate memory for the new triangle structures */
    857   if( (this->pModelInfo.pTriangles = new sTriangleExt[this->pModelInfo.numTriangles]) == NULL)
    858   {
    859     PRINTF(1)("Could not allocate memory for triangle list\n");
    860     return false;
    861   }
    862 
    863   /* now iterate through all groups and build up the triangle list */
    864   this->currentGroup = this->firstGroup;
    865   while( this->currentGroup != NULL)
    866   {
    867     tmpFace = this->currentGroup->firstFace;
    868     while( tmpFace != NULL)
    869     {
    870       tmpElem = tmpFace->firstElem;
    871 
    872       /* if its a triangle just add it to the list */
    873       if( tmpFace->vertexCount == 3)
    874       {
    875         for( int j = 0; j < 3; ++j)
    876         {
    877           this->pModelInfo.pTriangles[index].indexToVertices[j] = (unsigned int)tmpElem->vertexNumber * 3 ;
    878           this->pModelInfo.pTriangles[index].indexToNormals[j] = (unsigned int)tmpElem->normalNumber * 3 ;
    879           this->pModelInfo.pTriangles[index].indexToTexCoor[j] = (unsigned int)tmpElem->texCoordNumber * 3 ;
    880           tmpElem = tmpElem->next;
    881 
    882         }
    883         ++index;
    884       } /* if the polygon is a quad */
    885       else if( tmpFace->vertexCount == 4)
    886       {
    887 
    888         this->pModelInfo.pTriangles[index].indexToVertices[0] = (unsigned int)tmpElem->vertexNumber * 3;
    889         this->pModelInfo.pTriangles[index].indexToNormals[0] = (unsigned int)tmpElem->normalNumber * 3;
    890         this->pModelInfo.pTriangles[index].indexToTexCoor[0] = (unsigned int)tmpElem->texCoordNumber * 3;
    891 
    892         this->pModelInfo.pTriangles[index + 1].indexToVertices[0] = (unsigned int)tmpElem->vertexNumber * 3;
    893         this->pModelInfo.pTriangles[index + 1].indexToNormals[0] = (unsigned int)tmpElem->normalNumber * 3;
    894         this->pModelInfo.pTriangles[index + 1].indexToTexCoor[0] = (unsigned int)tmpElem->texCoordNumber * 3;
    895         tmpElem = tmpElem->next;
    896 
    897         this->pModelInfo.pTriangles[index].indexToVertices[1] = (unsigned int)tmpElem->vertexNumber * 3;
    898         this->pModelInfo.pTriangles[index].indexToNormals[1] = (unsigned int)tmpElem->normalNumber * 3;
    899         this->pModelInfo.pTriangles[index].indexToTexCoor[1] = (unsigned int)tmpElem->texCoordNumber * 3;
    900         tmpElem = tmpElem->next;
    901 
    902         this->pModelInfo.pTriangles[index].indexToVertices[2] = (unsigned int)tmpElem->vertexNumber * 3;
    903         this->pModelInfo.pTriangles[index].indexToNormals[2] = (unsigned int)tmpElem->normalNumber * 3;
    904         this->pModelInfo.pTriangles[index].indexToTexCoor[2] = (unsigned int)tmpElem->texCoordNumber * 3;
    905 
    906         this->pModelInfo.pTriangles[index + 1].indexToVertices[2] = (unsigned int)tmpElem->vertexNumber * 3;
    907         this->pModelInfo.pTriangles[index + 1].indexToNormals[2] = (unsigned int)tmpElem->normalNumber * 3;
    908         this->pModelInfo.pTriangles[index + 1].indexToTexCoor[2] = (unsigned int)tmpElem->texCoordNumber * 3;
    909         tmpElem = tmpElem->next;
    910 
    911         this->pModelInfo.pTriangles[index + 1].indexToVertices[1] = (unsigned int)tmpElem->vertexNumber * 3;
    912         this->pModelInfo.pTriangles[index + 1].indexToNormals[1] = (unsigned int)tmpElem->normalNumber * 3;
    913         this->pModelInfo.pTriangles[index + 1].indexToTexCoor[1] = (unsigned int)tmpElem->texCoordNumber * 3;
    914 
    915         index += 2;
    916       }
    917       tmpFace = tmpFace->next;
    918     }
    919     this->currentGroup = this->currentGroup->next;
    920   }
    921   return true;
    922 }
    923 
    924 
    925 /**
    926  *  Adds a Face-element (one vertex of a face) with all its information.
    927  * @param elem The FaceElement to add to the OpenGL-environment.
    928 
    929    It does this by searching:
    930    1. The Vertex itself
    931    2. The VertexNormale
    932    3. The VertexTextureCoordinate
    933    merging this information, the face will be drawn.
    934 */
    935 bool StaticModel::addGLElement (ModelFaceElement* elem)
    936 {
    937   PRINTF(5)("importing grafical Element to openGL.\n");
    938 
    939   if (elem->texCoordNumber > -1)
    940   {
    941     if (likely((unsigned int)elem->texCoordNumber < this->pModelInfo.numTexCoor))
    942       glTexCoord2fv(&this->vTexture[0] + elem->texCoordNumber * 2);
    943     else
    944       PRINTF(2)("TextureCoordinate %d is not in the List (max: %d)\nThe Model might be incomplete\n",
    945                 elem->texCoordNumber, this->pModelInfo.numTexCoor);
    946   }
    947   if (elem->normalNumber > -1)
    948   {
    949     if (likely((unsigned int)elem->normalNumber < this->pModelInfo.numNormals))
    950       glNormal3fv(&this->normals[0] + elem->normalNumber * 3);
    951     else
    952       PRINTF(2)("Normal %d is not in the List (max: %d)\nThe Model might be incomplete",
    953                 elem->normalNumber, this->pModelInfo.numNormals);
    954   }
    955   if (elem->vertexNumber > -1)
    956   {
    957     if (likely((unsigned int)elem->vertexNumber < this->pModelInfo.numVertices))
    958       glVertex3fv(&this->vertices[0]+ elem->vertexNumber * 3);
    959     else
    960       PRINTF(2)("Vertex %d is not in the List (max: %d)\nThe Model might be incomplete",
    961                 elem->vertexNumber, this->pModelInfo.numVertices);
    962   }
    963 
    964   return true;
    965 }
    966 
    967 /**
    968  *  Includes a default model
    969 
    970    This will inject a Cube, because this is the most basic model.
    971 */
    972128void StaticModel::cubeModel()
    973129{
  • trunk/src/lib/graphics/importer/static_model.h

    r7221 r9869  
    1010
    1111#include "material.h"
    12 #include "glincl.h"
    1312#include <vector>
    14 #include <list>
    15 
    16 // definition of different modes for setting up Faces
    17 #define VERTEX 0       //!< If Faces are created WITH Vertex-Coordinate
    18 #define NORMAL 1       //!< If Faces are created WITH Normals (otherwise autocalculate)
    19 #define TEXCOORD 2     //!< If Faces are created WITH TextureCoordinate
    20 
    21 //! an enumerator for VERTEX_FORMAT
    22 typedef enum VERTEX_FORMAT {
    23   VERTEX_ONLY = VERTEX,
    24   VERTEX_NORMAL = NORMAL,
    25   VERTEX_TEXCOORD = TEXCOORD,
    26   VERTEX_TEXCOORD_NORMAL = NORMAL | TEXCOORD
    27 };
    28 
    29 ////////////////////
    30 /// SUB-ELEMENTS ///
    31 ////////////////////
    32 //! This is the placeholder of one Vertex beloning to a Face.
    33 class ModelFaceElement
    34 {
    35  public:
    36   ModelFaceElement();
    37   ~ModelFaceElement();
    38 
    39   int                 vertexNumber;         //!< The number of the Vertex out of the Array* vertices, this vertex points to.
    40   int                 normalNumber;         //!< The number of the Normal out of the Array* normals, this vertex points to.
    41   int                 texCoordNumber;       //!< The number of the textureCoordinate out of the Array* vTexture, this vertex points to.
    42 
    43   ModelFaceElement*   next;                 //!< Point to the next FaceElement in this List.
    44 };
    45 
    46 //! This is the placeholder of a Face belonging to a Group of Faces.
    47 class ModelFace
    48 {
    49  public:
    50   ModelFace();
    51   ~ModelFace();
    52 
    53   unsigned int        vertexCount;     //!< The Count of vertices this Face has.
    54   ModelFaceElement*   firstElem;       //!< Points to the first Vertex (FaceElement) of this Face.
    55   Material*           material;        //!< The Material to use.
    56 
    57   ModelFace*          next;            //!< Pointer to the next Face.
    58 };
    59 
    60 //! Group to handle multiple Models per obj-file.
    61 class ModelGroup
    62 {
    63  public:
    64   ModelGroup();
    65   ~ModelGroup();
    66 
    67   void cleanup();
    68 
    69   std::string  name;           //!< the Name of the Group. this is an identifier, that can be accessed via the draw (std::string name) function.
    70   GLubyte*     indices;        //!< The indices of the Groups. Needed for vertex-arrays
    71   GLuint       listNumber;     //!< The number of the GL-List this Group gets.
    72   ModelFace*   firstFace;      //!< The first Face in this group.
    73   ModelFace*   currentFace;    //!< The current Face in this Group (the one we are currently working with.)
    74   int          faceMode;       //!< The Mode the Face is in: initially -1, 0 for FaceList opened, 1 for Material,  3 for triangle, 4 for Quad, 5+ for Poly @todo ENUM...
    75   int          faceCount;      //!< The Number of Faces this Group holds.
    76 
    77   ModelGroup*  next;           //!< Pointer to the next Group.
    78 };
    79 
    80 struct ModelMaterial
    81 {
    82   Material* material;
    83   bool external;
    84 };
     13#include "static_model_data.h"
    8514
    8615/////////////
     
    9423class StaticModel : public Model
    9524{
    96  public:
     25  ObjectListDeclaration(StaticModel);
     26public:
    9727  StaticModel(const std::string& modelName = "");
     28  StaticModel(const StaticModel& staticModel);
    9829  virtual ~StaticModel();
    9930
    100   virtual void draw() const;
    101   void draw(int groupNumber) const;
    102   void draw(const std::string& groupName) const;
     31  StaticModel& operator=(const StaticModel& model);
    10332
    104   void rebuild();
     33  virtual void draw() const { data->draw(); };
     34  void draw(int groupNumber) const { data->draw(groupNumber); };
     35  void draw(const std::string& groupName) const { data->draw(groupName); };
    10536
    106   Material* addMaterial(Material* material);
    107   Material* addMaterial(const std::string& materialName);
     37  void rebuild() { data->rebuild(); };
    10838
    109   bool addGroup(const std::string& groupString);
     39  Material* addMaterial(Material* material) { return data->addMaterial(material); };
     40  Material* addMaterial(const std::string& materialName) { return data->addMaterial(materialName); };
    11041
    111   bool addVertex(const std::string& vertexString);
    112   bool addVertex(float x, float y, float z);
     42  bool addGroup(const std::string& groupString) { return data->addGroup(groupString); };
    11343
    114   bool addFace(const std::string& faceString);
     44  bool addVertex(const std::string& vertexString) { return data->addVertex(vertexString); };
     45  bool addVertex(float x, float y, float z) { return data->addVertex(x, y, z); };
     46
     47  bool addFace(const std::string& faceString) { return data->addFace(faceString); };
    11548  bool addFace(int faceElemCount, VERTEX_FORMAT type, ...);
    11649
    117   bool addVertexNormal(const std::string& normalString);
    118   bool addVertexNormal(float x, float y, float z);
     50  bool addVertexNormal(const std::string& normalString) { return this->data->addVertexNormal(normalString); };
     51  bool addVertexNormal(float x, float y, float z) { return this->data->addVertexNormal(x,y,z); };
    11952
    120   bool addVertexTexture(const std::string& vTextureString);
    121   bool addVertexTexture(float u, float v);
     53  bool addVertexTexture(const std::string& vTextureString) { return this->data->addVertexTexture(vTextureString); };
     54  bool addVertexTexture(float u, float v) { return this->data->addVertexTexture(u, v); };
    12255
    123   bool setMaterial(const std::string& mtlString);
    124   bool setMaterial(Material* mtl);
     56  bool setMaterial(const std::string& mtlString) { return data->setMaterial(mtlString); };
     57  bool setMaterial(Material* mtl) { return data->setMaterial(mtl);};
    12558
    12659  void finalize();
    12760
     61  void acquireData(const StaticModelData::Pointer& data);
     62  const StaticModelData::Pointer& dataPointer() const { return this->data; };
    12863
    129  protected:
     64  inline void setScaleFactor(float scaleFactor) { this->data->setScaleFactor(scaleFactor); };
     65  float getScaleFactor() const { return data->getScaleFactor(); }
     66
     67protected:
    13068  void cubeModel();
    13169
    132   Material* findMaterialByName(const std::string& materialName);
    133 
    134  protected:
    135   float            scaleFactor;     //!< The Factor with which the Model should be scaled. @todo maybe one wants to scale the Model after Initialisation
    136 
    137  private:
    138   bool buildVertexNormals();
    139 
    140   bool importToDisplayList();
    141   bool buildTriangleList();
    142 
    143   bool addGLElement(ModelFaceElement* elem);
    144 
    145   bool cleanup();
    146 
    147  private:
    148   bool                       finalized;       //!< Sets the Object to be finalized.
    149 
    150   unsigned int               faceCount;       //!< A modelwide Counter for the faces
    151 
    152   std::vector<GLfloat>       vertices;        //!< The Array that handles the Vertices.
    153   std::vector<GLfloat>       normals;         //!< The Array that handles the Normals.
    154   std::vector<GLfloat>       vTexture;        //!< The Array that handles the VertexTextureCoordinates.
    155 
    156   ModelGroup*                firstGroup;      //!< The first of all groups.
    157   ModelGroup*                currentGroup;    //!< The currentGroup. this is the one we will work with.
    158   int                        groupCount;      //!< The Count of Groups.
    159 
    160   std::list<ModelMaterial*>  materialList;    //!< A list for all the Materials in this Model
     70private:
     71  void updateBase();
     72private:
     73  StaticModelData::Pointer         data;
    16174};
    16275
  • trunk/src/lib/graphics/importer/texture.cc

    r9406 r9869  
    6464#endif
    6565
    66 
     66ObjectListDefinition(Texture);
    6767
    6868/**
     
    8686    : data(texture.data)
    8787{
    88   this->setClassID(CL_TEXTURE, "Texture");
     88  this->registerObject(this, Texture::_objectList);
    8989  this->priority = 0.5;
    9090}
     
    149149void Texture::init()
    150150{
    151   this->setClassID(CL_TEXTURE, "Texture");
    152 
    153   this->data = TextureDataPointer(new TextureData());
     151  this->registerObject(this, Texture::_objectList);
     152
     153  this->data = TextureData::Pointer(new TextureData());
    154154
    155155  this->priority = 0.5;
     
    176176}
    177177
    178 Texture& Texture::operator=(const TextureDataPointer& textureDataPointer)
     178Texture& Texture::operator=(const TextureData::Pointer& textureDataPointer)
    179179{
    180180  this->data = textureDataPointer;
  • trunk/src/lib/graphics/importer/texture.h

    r8761 r9869  
    11/*!
    22 * @file texture.h
    3  * @brief Contains the texture class, that handles the reading of Images into Texutre-files.
     3 * @brief Contains the texture class, that handles the reading of Images into Texture-files.
    44 */
    55
     
    2020class Texture : public BaseObject
    2121{
     22  ObjectListDeclaration(Texture);
    2223public:
    2324  Texture();
     
    2829
    2930  Texture& operator=(const Texture& texture);
    30   Texture& operator=(const TextureDataPointer& textureDataPointer);
     31  Texture& operator=(const TextureData::Pointer& textureDataPointer);
     32  void acquireData(const TextureData::Pointer& textureDataPointer) { this->data = textureDataPointer; };
     33  const TextureData::Pointer& dataPointer() const { return data; }
    3134
    3235  virtual ~Texture();
     
    6265
    6366private:
    64   TextureDataPointer            data;               //!< The TextureData
     67  TextureData::Pointer          data;               //!< The TextureData
    6568  GLclampf                      priority;           //!< the priority of the current texture (used for garphics cards with limited mem)
    6669
  • trunk/src/lib/graphics/importer/texture_data.h

    r8761 r9869  
    1818class TextureData
    1919{
     20  public:
     21    typedef CountPointer<TextureData> Pointer;
    2022  public:
    2123    TextureData();
     
    4345};
    4446
    45 typedef CountPointer<TextureData> TextureDataPointer;
    46 
    4747#endif /* _TEXTURE_DATA_H */
  • trunk/src/lib/graphics/importer/texture_sequence.cc

    r9406 r9869  
    2828#endif
    2929
     30ObjectListDefinition(TextureSequence);
     31
    3032/**
    3133 * @brief Constructor for a Texture
     
    3335TextureSequence::TextureSequence(unsigned int count, ...)
    3436{
    35   this->setClassID(CL_TEXTURE_SEQUENCE, "TextureSequence");
     37  this->registerObject(this, TextureSequence::_objectList);
    3638
    3739  va_list textureNameList;
     
    5456TextureSequence::TextureSequence(const std::vector<std::string>& textureNames, const std::string& prependFolder)
    5557{
    56   this->setClassID(CL_TEXTURE_SEQUENCE, "TextureSequence");
     58  this->registerObject(this, TextureSequence::_objectList);
    5759  this->loadImageSeries(textureNames, prependFolder);
    5860}
  • trunk/src/lib/graphics/importer/texture_sequence.h

    r8324 r9869  
    1515class TextureSequence : public Texture
    1616{
     17  ObjectListDeclaration(TextureSequence);
    1718  public:
    1819    TextureSequence(unsigned int count = 0, ...);
  • trunk/src/lib/graphics/importer/vertex_array_model.cc

    r9406 r9869  
    2424
    2525
     26ObjectListDefinition(VertexArrayModel);
    2627
    2728/////////////
     
    3536VertexArrayModel::VertexArrayModel()
    3637{
    37   this->setClassID(CL_MODEL, "VertexArrayModel");
     38  this->registerObject(this, VertexArrayModel::_objectList);
    3839
    3940  this->newStripe();
     
    4950VertexArrayModel::VertexArrayModel(const Model& model)
    5051{
    51   this->setClassID(CL_MODEL, "VertexArrayModel");
     52  this->registerObject(this, VertexArrayModel::_objectList);
    5253
    5354  // importing the data to the new Model.
  • trunk/src/lib/graphics/importer/vertex_array_model.h

    r6769 r9869  
    2727class VertexArrayModel : public Model
    2828{
    29  public:
     29  ObjectListDeclaration(VertexArrayModel);
     30  public:
    3031  VertexArrayModel();
    3132  VertexArrayModel(const Model& model);
  • trunk/src/lib/graphics/light.cc

    r8742 r9869  
    2222#include "glincl.h"
    2323#include "vector.h"
    24 #include "parser/tinyxml/tinyxml.h"
    25 #include "util/loading/load_param.h"
     24#include "util/loading/load_param_xml.h"
    2625#include "util/loading/factory.h"
    2726#include "debug.h"
    2827
    29 CREATE_FACTORY(Light, CL_LIGHT);
     28#include "class_id_DEPRECATED.h"
     29
     30ObjectListDefinitionID(Light, CL_LIGHT);
     31CREATE_FACTORY(Light);
    3032
    3133//! Definition of the Lights and their Names
     
    5153  PRINTF(4)("initializing Light number %d.\n", this->lightNumber);
    5254
     55  this->registerObject(this, Light::_objectList);
     56
    5357  this->lightNumber = LightManager::getInstance()->registerLight(this);
    5458
    55   this->setClassID(CL_LIGHT, "Light");
    5659  char tmpName[10];
    5760  sprintf(tmpName, "Light[%d]", this->lightNumber);
     
    211214** LIGHT-MANAGER **
    212215******************/
     216ObjectListDefinition(LightManager);
    213217/**
    214218 *  standard constructor for a Light
     
    216220LightManager::LightManager ()
    217221{
    218   this->setClassID(CL_LIGHT_MANAGER, "LightManager");
     222  this->registerObject(this, LightManager::_objectList);
    219223
    220224  glEnable (GL_LIGHTING);
  • trunk/src/lib/graphics/light.h

    r8255 r9869  
    2525class Light : public PNode
    2626{
    27         public:
    28                 Light(const TiXmlElement* root = NULL);
    29                 virtual ~Light();
    30                
    31                 virtual void loadParams(const TiXmlElement* root);
    32                
    33                 void setDiffuseColor(GLfloat r, GLfloat g, GLfloat b);
    34                 void setSpecularColor(GLfloat r, GLfloat g, GLfloat b);
    35                 void setAttenuation(float constantAttenuation, float linearAttenuation, float quadraticAttenuation);
    36                 void setSpotDirection(const Vector& direction);
    37                 void setSpotDirection(float x, float y, float z) { setSpotDirection(Vector(x,y,z)); };
    38                 void setSpotCutoff(GLfloat cutoff);
    39                
    40                 /** @returns the lightNumber*/
    41                 int getLightNumber() const {return this->lightNumber;}
    42                
    43                 virtual void draw() const;
    44                
    45                 void debug() const;
    46        
    47         // attributes
    48         private:
    49                 int              lightNumber;               //!< The number of this Light.
    50                 GLfloat          diffuseColor[4];           //!< The Diffuse Color this Light emmits.
    51                 GLfloat          specularColor[4];          //!< The specular Color of this Light.
    52                 float            constantAttenuation;       //!< The Factor of the the Constant Attenuation.
    53                 float            linearAttenuation;         //!< The Factor of the the Linear Attenuation.
    54                 float            quadraticAttenuation;      //!< The Factor of the the Quadratic Attenuation.
    55                 GLfloat          spotDirection[4];          //!< The direction of the Spot Light.
    56                 GLfloat          spotCutoff;                //!< The cutoff Angle of the Light Source
     27  ObjectListDeclaration(Light);
     28public:
     29  Light(const TiXmlElement* root = NULL);
     30  virtual ~Light();
     31
     32  virtual void loadParams(const TiXmlElement* root);
     33
     34  void setDiffuseColor(GLfloat r, GLfloat g, GLfloat b);
     35  void setSpecularColor(GLfloat r, GLfloat g, GLfloat b);
     36  void setAttenuation(float constantAttenuation, float linearAttenuation, float quadraticAttenuation);
     37  void setSpotDirection(const Vector& direction);
     38  void setSpotDirection(float x, float y, float z) { setSpotDirection(Vector(x,y,z)); };
     39  void setSpotCutoff(GLfloat cutoff);
     40
     41  /** @returns the lightNumber*/
     42  int getLightNumber() const {return this->lightNumber;}
     43
     44  virtual void draw() const;
     45
     46  void debug() const;
     47
     48  // attributes
     49private:
     50  int              lightNumber;               //!< The number of this Light.
     51  GLfloat          diffuseColor[4];           //!< The Diffuse Color this Light emmits.
     52  GLfloat          specularColor[4];          //!< The specular Color of this Light.
     53  float            constantAttenuation;       //!< The Factor of the the Constant Attenuation.
     54  float            linearAttenuation;         //!< The Factor of the the Linear Attenuation.
     55  float            quadraticAttenuation;      //!< The Factor of the the Quadratic Attenuation.
     56  GLfloat          spotDirection[4];          //!< The direction of the Spot Light.
     57  GLfloat          spotCutoff;                //!< The cutoff Angle of the Light Source
    5758};
    58        
    59        
    60        
     59
     60
     61
    6162//! A class that handles Lights
    6263/**
     
    8788*/
    8889class LightManager : public BaseObject
    89         {
    90         friend class Light;
     90{
     91  ObjectListDeclaration(LightManager);
    9192
    92         public:
    93                 virtual ~LightManager();
    94                 /** @returns a Pointer to the only object of this Class */
    95                 inline static LightManager* getInstance() { if (!singletonRef) singletonRef = new LightManager();  return singletonRef; };
     93  friend class Light;
     94public:
     95  virtual ~LightManager();
     96  /** @returns a Pointer to the only object of this Class */
     97  inline static LightManager* getInstance() { if (!singletonRef) singletonRef = new LightManager();  return singletonRef; };
    9698
    97                 virtual void loadParams(const TiXmlElement* root);
    98                 void loadLights(const TiXmlElement* root);
     99  virtual void loadParams(const TiXmlElement* root);
     100  void loadLights(const TiXmlElement* root);
    99101
    100                 void setAmbientColor(GLfloat r, GLfloat g, GLfloat b);
    101                 // HACK: Assuming r = g = b values
    102                 inline GLfloat getAmbientColor() {  return this->ambientColor[0]; }
     102  void setAmbientColor(GLfloat r, GLfloat g, GLfloat b);
     103  // HACK: Assuming r = g = b values
     104inline GLfloat getAmbientColor() {  return this->ambientColor[0]; }
    103105
    104                 Light* getLight(int lightNumber) const;
    105                 inline Light* getLight() const { return this->currentLight; };
     106  Light* getLight(int lightNumber) const;
     107  inline Light* getLight() const { return this->currentLight; };
    106108
    107                 void draw() const;
     109  void draw() const;
    108110
    109                 void debug() const;
     111  void debug() const;
    110112
    111         private:
    112                 LightManager();
     113private:
     114  LightManager();
    113115
    114                 int  registerLight(Light* light);
    115                 void unregisterLight(Light* light);
     116  int  registerLight(Light* light);
     117  void unregisterLight(Light* light);
    116118
    117         private:
    118                 static LightManager*    singletonRef;       //!< This is the LightHandlers Reference.
    119                 GLfloat                 ambientColor[4];    //!< The ambient Color of the scene.
     119private:
     120  static LightManager*    singletonRef;       //!< This is the LightHandlers Reference.
     121  GLfloat                 ambientColor[4];    //!< The ambient Color of the scene.
    120122
    121                 Light**                 lights;             //!< An array of Lenght NUMBEROFLIGHTS, that holds pointers to all LightValues.
    122                 Light*                  currentLight;       //!< The current Light, we are working with.
     123  Light**                 lights;             //!< An array of Lenght NUMBEROFLIGHTS, that holds pointers to all LightValues.
     124  Light*                  currentLight;       //!< The current Light, we are working with.
    123125
    124126};
  • trunk/src/lib/graphics/render2D/element_2d.cc

    r9406 r9869  
    2929#include "graphics_engine.h"
    3030#include "util/loading/load_param.h"
    31 #include "class_list.h"
    3231
    3332#include "color.h"
    34 
     33#include "debug.h"
    3534#include "shell_command.h"
     35
    3636SHELL_COMMAND(debug, Element2D, debug2D);
     37
     38ObjectListDefinition(Element2D);
    3739
    3840
     
    4648Element2D::Element2D (Element2D* parent, E2D_LAYER layer, short nodeFlags)
    4749{
    48   this->setClassID(CL_ELEMENT_2D, "Element2D");
     50  this->registerObject(this, Element2D::_objectList);
    4951
    5052  this->setVisibility(true);
     
    268270void Element2D::setBindNode(const std::string& bindNode)
    269271{
    270   const PNode* tmpBindNode = dynamic_cast<const PNode*>(ClassList::getObject(bindNode, CL_PARENT_NODE));
     272  const PNode* tmpBindNode = PNode::objectList().getObject(bindNode);
    271273  if (tmpBindNode != NULL)
    272274    this->bindNode = tmpBindNode;
     
    640642void Element2D::addChild2D (const std::string& childName)
    641643{
    642   Element2D* childNode = dynamic_cast<Element2D*>(ClassList::getObject(childName, CL_ELEMENT_2D));
     644  Ele