Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9869 in orxonox.OLD for trunk/src/lib/graphics


Ignore:
Timestamp:
Oct 3, 2006, 12:19:30 AM (18 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/src/lib/graphics
Files:
1 deleted
59 edited
16 copied

Legend:

Unmodified
Added
Removed
  • 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  Element2D* childNode = Element2D::objectList().getObject(childName);
    643645  if (childNode != NULL)
    644646    this->addChild2D(childNode);
     
    718720void Element2D::setParent2D (const std::string& parentName)
    719721{
    720   Element2D* parentNode = dynamic_cast<Element2D*>(ClassList::getObject(parentName, CL_ELEMENT_2D));
     722  Element2D* parentNode = Element2D::objectList().getObject(parentName);
    721723  if (parentNode != NULL)
    722724    parentNode->addChild2D(this);
     
    771773void Element2D::setParentSoft2D(const std::string& parentName, float bias)
    772774{
    773   Element2D* parentNode = dynamic_cast<Element2D*>(ClassList::getObject(parentName, CL_ELEMENT_2D));
     775  Element2D* parentNode = Element2D::objectList().getObject(parentName);
    774776  if (parentNode != NULL)
    775777    this->setParentSoft2D(parentNode, bias);
  • trunk/src/lib/graphics/render2D/element_2d.h

    r8360 r9869  
    4747
    4848  E2D_PARENT_MOVEMENT                = 0x0004,    //!< Moves all children along with the parent.
    49 // special linkage modes
     49  // special linkage modes
    5050  E2D_PARENT_ALL                     = 0x0003,    //!< Moves all children around the center of their parent, and also rotates their centers
    5151  E2D_PARENT_ROTATE_AND_MOVE         = 0x0005,    //!< Rotates all children around their axis, and moves them as the Parent Moves, but does not rotate around the center of their parent.
     
    5858  E2D_REPARENT_DELETE_CHILDREN       = 0x0040,    //!< Deletes the Children of the node when This Node is Removed. (Use with care).
    5959  /// FIXME
    60    E2D_REPARENT_KEEP_POSITION         = 0x0080,   //!< Tries to keep the Position if the Node is reparented.
     60  E2D_REPARENT_KEEP_POSITION         = 0x0080,   //!< Tries to keep the Position if the Node is reparented.
    6161
    6262
     
    8787 * -> the tree is sorted on insertion of a new Child: @see Element2D::addChild2D()
    8888 */
    89 class Element2D : virtual public BaseObject {
    90 
    91   public:
    92     Element2D(Element2D* parent = Element2D::getNullElement(), E2D_LAYER layer = E2D_DEFAULT_LAYER, short nodeFlags = E2D_PARENT_MODE_DEFAULT);
    93     virtual ~Element2D();
    94 
    95     virtual void loadParams(const TiXmlElement* root);
    96 
    97     // ACTIVATION //
    98     inline void activate2D() { this->bActive = this->bRelCoorChanged = this->bRelDirChanged = true; };
    99     inline void deactivate2D() { this->bActive = false; };
    100     inline bool get2DActiveState() { return this->bActive; };
    101 
    102     // ALIGNMENT //
    103     /** @param alignment the new Alignment of the 2D-Element */
    104     inline void setAlignment(E2D_ALIGNMENT alignment) { this->alignment = alignment; };
    105     void setAlignment(const std::string& alignment);
    106     inline E2D_ALIGNMENT getAlignment() const { return this->alignment; };
    107 
    108     // LAYERING //
    109     void setLayer(E2D_LAYER layer);
    110     void setLayer(const std::string& layer);
    111     /** @returns the Layer this Element is drawn to */
    112     inline E2D_LAYER getLayer() const { return this->layer; };
    113 
    114     // VISIBILITY //
    115     /** @param visible true if the Element should be visible false otherwise (will not be rendered) */
    116     inline void setVisibility(bool visible) { this->bVisible = visible; };
    117     /** @returns the visibility state */
    118     inline bool isVisible() const { return (this->bVisible && this->bCurrentlyVisible);  };
    119 
    120 
    121     // POSITIONAL (E2D-specials) //
    122     /** @param bindNode the Node this 2D-element should follow. if NULL the Element will not follow anything */
    123     void setBindNode(const PNode* bindNode);
    124     void setBindNode(const std::string& bindNode);
    125     inline const PNode* getBindNode() const { return this->bindNode; };
    126 
    127     inline void setSize2D(float x, float y) { this->size = Vector2D(x, y); };
    128     inline void setSize2D(const Vector2D& size) { this->size = size; };
    129     inline const Vector2D& getSize2D() const { return this->size; };
    130     void setSizeSoft2D(float x, float y, float bias = 1.0);
    131     inline void setSizeX2D(float x) { this->size.x = x; };
    132     inline void setSizeY2D(float y) { this->size.y = y; };
    133     inline float getSizeX2D() const { return this->size.x; };
    134     inline float getSizeY2D() const { return this->size.y; };
    135 
    136   public:
    137     virtual void tick(float dt) {};
    138     virtual void draw() const  {};
    139     void tick2D(float dt);
    140     void draw2D(E2D_LAYER from, E2D_LAYER to) const;
    141     void drawChildren(E2D_LAYER from, E2D_LAYER to) const;
    142 
    143     // LIKE PNODE
    144   public:
    145     void setRelCoor2D (const Vector2D& relCoord);
    146     void setRelCoorX2D(float x);
    147     void setRelCoorY2D(float y);
    148     void setRelCoor2D (float x, float y);
    149     void setRelCoor2Dpx (int x, int y);
    150     void setRelCoorSoft2D (const Vector2D& relCoordSoft, float bias = 1.0);
    151     void setRelCoorSoft2D (float x, float y, float bias = 1.0);
    152     void setRelCoorSoft2Dpx (int x, int y, float bias = 1.0);
    153     /** @returns the relative position */
    154     inline const Vector2D& getRelCoor2D () const { return this->prevRelCoordinate; };
    155     /** @returns the Relative Coordinate Destination */
    156     inline const Vector2D& getRelCoorSoft2D() const { return (this->toCoordinate)?*this->toCoordinate:this->relCoordinate; };
    157     const Vector2D& getRelCoor2Dpx() const;
    158     void setAbsCoor2D (const Vector2D& absCoord);
    159     void setAbsCoor2D (float x, float y);
    160     void setAbsCoorX2D(float x);
    161     void setAbsCoorY2D(float y);
    162     void setAbsCoor2Dpx (int x, int y);
    163     void setAbsCoorSoft2D (const Vector2D& absCoordSoft, float bias = 1.0);
    164     void setAbsCoorSoft2D (float x, float y, float bias = 1.0);
    165     /** @returns the absolute position */
    166     inline const Vector2D& getAbsCoor2D () const { return this->absCoordinate; };
    167     const Vector2D& getAbsCoor2Dpx () const;
    168 
    169     void shiftCoor2D (const Vector2D& shift);
    170     void shiftCoor2Dpx (int x, int y);
    171 
    172     void setRelDir2D (float relDir);
    173     void setRelDirSoft2D(float relDirSoft, float bias = 1.0);
    174     /** @returns the relative Direction */
    175     inline float getRelDir2D () const { return this->prevRelDirection; };
    176     /** @returns the Relative Directional Destination */
    177     inline float getRelDirSoft2D() const { return (this->toDirection)?*this->toDirection:this->relDirection; };
    178     void setAbsDir2D (float absDir);
    179     void setAbsDirSoft2D (float absDirSoft, float bias = 1.0);
    180     /** @returns the absolute Direction */
    181     inline float getAbsDir2D () const { return this->absDirection; };
    182     void shiftDir2D (float shiftDir);
    183 
    184     /** @returns the Speed of the Node */
    185     inline float getSpeed() const { return 0; };
    186     /** @returns the Velocity of the Node */
    187     inline const Vector2D& getVelocity() const { return this->velocity; };
    188 
    189 
    190     void addChild2D (Element2D* child);
    191     void addChild2D (const std::string& childName);
    192     void removeChild2D (Element2D* child);
    193     void remove2D();
    194 
    195     /** @param parent the new parent of this Element2D */
    196     void setParent2D (Element2D* parent) { parent->addChild2D(this); };
    197     void setParent2D (const std::string& parentName);
    198     /** @returns the parent of this Element2D */
    199     inline Element2D* getParent2D () const { return this->parent; };
    200     /** @returns the List of Children of this Element2D */
    201     inline const std::list<Element2D*>& getChildren2D() const { return this->children; };
    202 
    203     void setParentSoft2D(Element2D* parentNode, float bias = 1.0);
    204     void setParentSoft2D(const std::string& parentName, float bias = 1.0);
    205 
    206     void setParentMode2D (E2D_PARENT_MODE parentMode);
    207     void setParentMode2D (const std::string& parentingMode);
    208     /** @returns the Parenting mode of this node */
    209     int getParentMode2D() const { return this->parentMode; };
    210 
    211     // NULL_PARENT //
    212     /** @returns the NullParent, the (main) ROOT of the PNode Tree. If it does not yet exist, it will be created. */
    213     static Element2D* getNullElement()  { return (Element2D::nullElement != NULL)? Element2D::nullElement : Element2D::createNullElement(); };
    214 
    215 
    216     void update2D (float dt);
    217 
    218     void debug2D (unsigned int depth = 1, unsigned int level = 0) const;
    219     void debugDraw2D(unsigned int depth = 1, float size = 1.0, Vector color = Vector(1,0,0), unsigned int level = 0) const;
    220 
    221     // helper functions //
    222     static const char* parentingModeToString2D(int parentingMode);
    223     static E2D_PARENT_MODE stringToParentingMode2D(const std::string& parentingMode);
    224 
    225     static const char* layer2DToChar(E2D_LAYER layer);
    226     static E2D_LAYER charToLayer2D(const std::string& layer);
    227 
    228     static bool layerSortPredicate(const Element2D* elem1, const Element2D* elem2);
    229 
    230   private:
    231     void eraseChild2D(Element2D* child);
    232     /** tells the child that the parent's Coordinate has changed */
    233     inline void parentCoorChanged2D () { this->bRelCoorChanged = true; }
    234     /** tells the child that the parent's Direction has changed */
    235     inline void parentDirChanged2D () { this->bRelDirChanged = true; }
    236     /** @returns the last calculated coordinate */
    237     inline Vector2D getLastAbsCoor2D() { return this->lastAbsCoordinate; }
    238 
    239     void reparent2D();
    240     static Element2D* createNullElement();
    241     bool checkIntegrity(const Element2D* checkParent) const;
    242 
    243 
    244   private:
    245     const PNode*            bindNode;           //!< a node over which to display this 2D-element
    246     Vector2D                size;               //!< The size of the rendered item
    247     Vector2D*               toSize;             //!< The Size to iterate to.
    248 
    249     E2D_ALIGNMENT           alignment;          //!< How the Element is aligned around its Position
    250 
    251     bool                    bVisible;           //!< If the given Element2D is visible.
    252     bool                    bCurrentlyVisible;  //!< Evaluated in the TICK process, to see if the Element is Currently visible.
    253     bool                    bActive;            //!< If the given Element2D is active.
    254     E2D_LAYER               layer;              //!< What layer this Element2D is on.
    255 
    256     bool                    bRelCoorChanged;    //!< If Relative Coordinate has changed since last time we checked
    257     bool                    bRelDirChanged;     //!< If Relative Direction has changed since last time we checked
    258 
    259     Vector2D                relCoordinate;      //!< coordinates relative to the parent
    260     Vector2D                absCoordinate;      //!< absolute coordinates in the world ( from (0,0,0) )
    261     float                   relDirection;       //!< direction relative to the parent
    262     float                   absDirection;       //!< absolute diretion in the world ( from (0,0,1) )
    263 
    264     Vector2D                prevRelCoordinate;  //!< The last Relative Coordinate from the last update-Cycle.
    265     Vector2D                lastAbsCoordinate;  //!< this is used for speedcalculation, it stores the last coordinate
    266     float                   prevRelDirection;   //!< The last Relative Direciton from the last update-Cycle.
    267 
    268     Vector2D                velocity;           //!< Saves the velocity.
    269 
    270     Vector2D*               toCoordinate;       //!< a position to which to iterate. (This is used in conjunction with setParentSoft.and set*CoorSoft)
    271     float*                  toDirection;        //!< a direction to which to iterate. (This is used in conjunction with setParentSoft and set*DirSoft)
    272     float                   bias;               //!< how fast to iterate to the given position (default is 1)
    273 
    274     Element2D*              parent;             //!< a pointer to the parent node
    275     std::list<Element2D*>   children;           //!< list of the children of this Element2D
    276 
    277     unsigned int            parentMode;         //!< the mode of the binding
    278 
    279     static Element2D*       nullElement;        //!< The top-most Element
     89class Element2D : virtual public BaseObject
     90{
     91  ObjectListDeclaration(Element2D);
     92
     93public:
     94  Element2D(Element2D* parent = Element2D::getNullElement(), E2D_LAYER layer = E2D_DEFAULT_LAYER, short nodeFlags = E2D_PARENT_MODE_DEFAULT);
     95  virtual ~Element2D();
     96
     97  virtual void loadParams(const TiXmlElement* root);
     98
     99  // ACTIVATION //
     100  inline void activate2D() { this->bActive = this->bRelCoorChanged = this->bRelDirChanged = true; };
     101  inline void deactivate2D() { this->bActive = false; };
     102  inline bool get2DActiveState() { return this->bActive; };
     103
     104  // ALIGNMENT //
     105  /** @param alignment the new Alignment of the 2D-Element */
     106  inline void setAlignment(E2D_ALIGNMENT alignment) { this->alignment = alignment; };
     107  void setAlignment(const std::string& alignment);
     108  inline E2D_ALIGNMENT getAlignment() const { return this->alignment; };
     109
     110  // LAYERING //
     111  void setLayer(E2D_LAYER layer);
     112  void setLayer(const std::string& layer);
     113  /** @returns the Layer this Element is drawn to */
     114  inline E2D_LAYER getLayer() const { return this->layer; };
     115
     116  // VISIBILITY //
     117  /** @param visible true if the Element should be visible false otherwise (will not be rendered) */
     118  inline void setVisibility(bool visible) { this->bVisible = visible; };
     119  /** @returns the visibility state */
     120  inline bool isVisible() const { return (this->bVisible && this->bCurrentlyVisible);  };
     121
     122
     123  // POSITIONAL (E2D-specials) //
     124  /** @param bindNode the Node this 2D-element should follow. if NULL the Element will not follow anything */
     125  void setBindNode(const PNode* bindNode);
     126  void setBindNode(const std::string& bindNode);
     127  inline const PNode* getBindNode() const { return this->bindNode; };
     128
     129  inline void setSize2D(float x, float y) { this->size = Vector2D(x, y); };
     130  inline void setSize2D(const Vector2D& size) { this->size = size; };
     131  inline const Vector2D& getSize2D() const { return this->size; };
     132  void setSizeSoft2D(float x, float y, float bias = 1.0);
     133  inline void setSizeX2D(float x) { this->size.x = x; };
     134  inline void setSizeY2D(float y) { this->size.y = y; };
     135  inline float getSizeX2D() const { return this->size.x; };
     136  inline float getSizeY2D() const { return this->size.y; };
     137
     138public:
     139  virtual void tick(float dt) {};
     140  virtual void draw() const  {};
     141  void tick2D(float dt);
     142  void draw2D(E2D_LAYER from, E2D_LAYER to) const;
     143  void drawChildren(E2D_LAYER from, E2D_LAYER to) const;
     144
     145  // LIKE PNODE
     146public:
     147  void setRelCoor2D (const Vector2D& relCoord);
     148  void setRelCoorX2D(float x);
     149  void setRelCoorY2D(float y);
     150  void setRelCoor2D (float x, float y);
     151  void setRelCoor2Dpx (int x, int y);
     152  void setRelCoorSoft2D (const Vector2D& relCoordSoft, float bias = 1.0);
     153  void setRelCoorSoft2D (float x, float y, float bias = 1.0);
     154  void setRelCoorSoft2Dpx (int x, int y, float bias = 1.0);
     155  /** @returns the relative position */
     156  inline const Vector2D& getRelCoor2D () const { return this->prevRelCoordinate; };
     157  /** @returns the Relative Coordinate Destination */
     158inline const Vector2D& getRelCoorSoft2D() const { return (this->toCoordinate)?*this->toCoordinate:this->relCoordinate; };
     159  const Vector2D& getRelCoor2Dpx() const;
     160  void setAbsCoor2D (const Vector2D& absCoord);
     161  void setAbsCoor2D (float x, float y);
     162  void setAbsCoorX2D(float x);
     163  void setAbsCoorY2D(float y);
     164  void setAbsCoor2Dpx (int x, int y);
     165  void setAbsCoorSoft2D (const Vector2D& absCoordSoft, float bias = 1.0);
     166  void setAbsCoorSoft2D (float x, float y, float bias = 1.0);
     167  /** @returns the absolute position */
     168  inline const Vector2D& getAbsCoor2D () const { return this->absCoordinate; };
     169  const Vector2D& getAbsCoor2Dpx () const;
     170
     171  void shiftCoor2D (const Vector2D& shift);
     172  void shiftCoor2Dpx (int x, int y);
     173
     174  void setRelDir2D (float relDir);
     175  void setRelDirSoft2D(float relDirSoft, float bias = 1.0);
     176  /** @returns the relative Direction */
     177  inline float getRelDir2D () const { return this->prevRelDirection; };
     178  /** @returns the Relative Directional Destination */
     179inline float getRelDirSoft2D() const { return (this->toDirection)?*this->toDirection:this->relDirection; };
     180  void setAbsDir2D (float absDir);
     181  void setAbsDirSoft2D (float absDirSoft, float bias = 1.0);
     182  /** @returns the absolute Direction */
     183  inline float getAbsDir2D () const { return this->absDirection; };
     184  void shiftDir2D (float shiftDir);
     185
     186  /** @returns the Speed of the Node */
     187  inline float getSpeed() const { return 0; };
     188  /** @returns the Velocity of the Node */
     189  inline const Vector2D& getVelocity() const { return this->velocity; };
     190
     191
     192  void addChild2D (Element2D* child);
     193  void addChild2D (const std::string& childName);
     194  void removeChild2D (Element2D* child);
     195  void remove2D();
     196
     197  /** @param parent the new parent of this Element2D */
     198  void setParent2D (Element2D* parent) { parent->addChild2D(this); };
     199  void setParent2D (const std::string& parentName);
     200  /** @returns the parent of this Element2D */
     201  inline Element2D* getParent2D () const { return this->parent; };
     202  /** @returns the List of Children of this Element2D */
     203  inline const std::list<Element2D*>& getChildren2D() const { return this->children; };
     204
     205  void setParentSoft2D(Element2D* parentNode, float bias = 1.0);
     206  void setParentSoft2D(const std::string& parentName, float bias = 1.0);
     207
     208  void setParentMode2D (E2D_PARENT_MODE parentMode);
     209  void setParentMode2D (const std::string& parentingMode);
     210  /** @returns the Parenting mode of this node */
     211  int getParentMode2D() const { return this->parentMode; };
     212
     213  // NULL_PARENT //
     214  /** @returns the NullParent, the (main) ROOT of the PNode Tree. If it does not yet exist, it will be created. */
     215static Element2D* getNullElement()  { return (Element2D::nullElement != NULL)? Element2D::nullElement : Element2D::createNullElement(); };
     216
     217
     218  void update2D (float dt);
     219
     220  void debug2D (unsigned int depth = 1, unsigned int level = 0) const;
     221  void debugDraw2D(unsigned int depth = 1, float size = 1.0, Vector color = Vector(1,0,0), unsigned int level = 0) const;
     222
     223  // helper functions //
     224  static const char* parentingModeToString2D(int parentingMode);
     225  static E2D_PARENT_MODE stringToParentingMode2D(const std::string& parentingMode);
     226
     227  static const char* layer2DToChar(E2D_LAYER layer);
     228  static E2D_LAYER charToLayer2D(const std::string& layer);
     229
     230  static bool layerSortPredicate(const Element2D* elem1, const Element2D* elem2);
     231
     232private:
     233  void eraseChild2D(Element2D* child);
     234  /** tells the child that the parent's Coordinate has changed */
     235  inline void parentCoorChanged2D () { this->bRelCoorChanged = true; }
     236  /** tells the child that the parent's Direction has changed */
     237  inline void parentDirChanged2D () { this->bRelDirChanged = true; }
     238  /** @returns the last calculated coordinate */
     239  inline Vector2D getLastAbsCoor2D() { return this->lastAbsCoordinate; }
     240
     241  void reparent2D();
     242  static Element2D* createNullElement();
     243  bool checkIntegrity(const Element2D* checkParent) const;
     244
     245
     246private:
     247  const PNode*            bindNode;           //!< a node over which to display this 2D-element
     248  Vector2D                size;               //!< The size of the rendered item
     249  Vector2D*               toSize;             //!< The Size to iterate to.
     250
     251  E2D_ALIGNMENT           alignment;          //!< How the Element is aligned around its Position
     252
     253  bool                    bVisible;           //!< If the given Element2D is visible.
     254  bool                    bCurrentlyVisible;  //!< Evaluated in the TICK process, to see if the Element is Currently visible.
     255  bool                    bActive;            //!< If the given Element2D is active.
     256  E2D_LAYER               layer;              //!< What layer this Element2D is on.
     257
     258  bool                    bRelCoorChanged;    //!< If Relative Coordinate has changed since last time we checked
     259  bool                    bRelDirChanged;     //!< If Relative Direction has changed since last time we checked
     260
     261  Vector2D                relCoordinate;      //!< coordinates relative to the parent
     262  Vector2D                absCoordinate;      //!< absolute coordinates in the world ( from (0,0,0) )
     263  float                   relDirection;       //!< direction relative to the parent
     264  float                   absDirection;       //!< absolute diretion in the world ( from (0,0,1) )
     265
     266  Vector2D                prevRelCoordinate;  //!< The last Relative Coordinate from the last update-Cycle.
     267  Vector2D                lastAbsCoordinate;  //!< this is used for speedcalculation, it stores the last coordinate
     268  float                   prevRelDirection;   //!< The last Relative Direciton from the last update-Cycle.
     269
     270  Vector2D                velocity;           //!< Saves the velocity.
     271
     272  Vector2D*               toCoordinate;       //!< a position to which to iterate. (This is used in conjunction with setParentSoft.and set*CoorSoft)
     273  float*                  toDirection;        //!< a direction to which to iterate. (This is used in conjunction with setParentSoft and set*DirSoft)
     274  float                   bias;               //!< how fast to iterate to the given position (default is 1)
     275
     276  Element2D*              parent;             //!< a pointer to the parent node
     277  std::list<Element2D*>   children;           //!< list of the children of this Element2D
     278
     279  unsigned int            parentMode;         //!< the mode of the binding
     280
     281  static Element2D*       nullElement;        //!< The top-most Element
    280282};
    281283
  • trunk/src/lib/graphics/render2D/image_plane.cc

    r9406 r9869  
    2121
    2222#include "graphics_engine.h"
    23 #include "glincl.h"
    2423#include "p_node.h"
    2524
    2625
     26#include "class_id_DEPRECATED.h"
    2727
    28 
    29 
    30 CREATE_FACTORY(ImagePlane, CL_IMAGE_ENTITY);
     28ObjectListDefinitionID(ImagePlane, CL_IMAGE_PLANE);
     29CREATE_FACTORY(ImagePlane);
    3130
    3231
     
    5655void ImagePlane::init()
    5756{
    58   this->setClassID(CL_IMAGE_PLANE, "ImagePlane");
     57  this->registerObject(this, ImagePlane::_objectList);
    5958  this->setName("ImagePlane");
    6059
  • trunk/src/lib/graphics/render2D/image_plane.h

    r7843 r9869  
    1717class ImagePlane :  public Element2D
    1818{
    19 
     19  ObjectListDeclaration(ImagePlane);
    2020  public:
    2121    ImagePlane(const TiXmlElement* root = NULL);
  • trunk/src/lib/graphics/render2D/render_2d.cc

    r9406 r9869  
    1919
    2020#include "graphics_engine.h"
    21 #include "class_list.h"
    2221#include "element_2d.h"
    2322
     23ObjectListDefinition(Render2D);
    2424
    2525
     
    2929Render2D::Render2D ()
    3030{
    31    this->setClassID(CL_RENDER_2D, "Render2D");
    32    this->setName("Render2D");
     31  this->registerObject(this, Render2D::_objectList);
     32  this->setName("Render2D");
    3333
    34    this->showNodes = false;
     34  this->showNodes = false;
    3535}
    3636
  • trunk/src/lib/graphics/render2D/render_2d.h

    r7840 r9869  
    1212
    1313//! A default singleton class.
    14 class Render2D : public BaseObject {
     14class Render2D : public BaseObject
     15{
     16  ObjectListDeclaration(Render2D);
     17
    1518  friend class Element2D;
    1619
    17   public:
    18     virtual ~Render2D();
    19     /** @returns a Pointer to the only object of this Class */
    20     inline static Render2D* getInstance() { if (!singletonRef) singletonRef = new Render2D();  return singletonRef; };
     20public:
     21  virtual ~Render2D();
     22  /** @returns a Pointer to the only object of this Class */
     23  inline static Render2D* getInstance() { if (!singletonRef) singletonRef = new Render2D();  return singletonRef; };
    2124
    22     void toggleNodesVisibility() { this->showNodes = !this->showNodes; };
     25void toggleNodesVisibility() { this->showNodes = !this->showNodes; };
    2326
    24     void update(float dt);
    25     void tick(float dt);
    26     void draw(E2D_LAYER from, E2D_LAYER to) const;
     27  void update(float dt);
     28  void tick(float dt);
     29  void draw(E2D_LAYER from, E2D_LAYER to) const;
    2730
    28   private:
    29     Render2D();
    30     static Render2D*              singletonRef;                    //!< Reference to this class.
     31private:
     32  Render2D();
     33  static Render2D*              singletonRef;                    //!< Reference to this class.
    3134
    32     bool                          showNodes;                       //!< If the debug-Nodes should be visible
    33  };
     35  bool                          showNodes;                       //!< If the debug-Nodes should be visible
     36};
    3437
    3538#endif /* _RENDER_2D_H */
  • trunk/src/lib/graphics/shader.cc

    r9406 r9869  
    1818#include "shader.h"
    1919
    20 #include "stdlibincl.h"
    2120#include "compiler.h"
    2221//#include <stdio.h>
     
    2524#include "debug.h"
    2625
    27 #include "util/loading/resource_manager.h"
    2826
    2927
     
    3331
    3432
     33ObjectListDefinition(Shader);
    3534
     35void Shader::Uniform::setV(unsigned int count, float* vv) const
     36{
     37  switch (count)
     38  {
     39    case 1:
     40    glUniform1fv(this->uniform, 1, vv);
     41    break;
     42    case 2:
     43    glUniform2fv(this->uniform, 2, vv);
     44    break;
     45    case 3:
     46    glUniform3fv(this->uniform, 3, vv);
     47    break;
     48    case 4:
     49    glUniform4fv(this->uniform, 4, vv);
     50    break;
     51  }
     52}
     53void Shader::Uniform::setV(unsigned int count, int* vv) const
     54{
     55  switch (count)
     56  {
     57    case 1:
     58    glUniform1iv(this->uniform, 1, vv);
     59    break;
     60    case 2:
     61    glUniform2iv(this->uniform, 2, vv);
     62    break;
     63    case 3:
     64    glUniform3iv(this->uniform, 3, vv);
     65    break;
     66    case 4:
     67    glUniform4iv(this->uniform, 4, vv);
     68    break;
     69  }
     70}
     71
     72
     73
     74Shader::Shader()
     75  : data(new ShaderData)
     76{
     77
     78}
    3679
    3780/**
     
    3982*/
    4083Shader::Shader (const std::string& vertexShaderFile, const std::string& fragmentShaderFile)
     84  : data(new ShaderData)
    4185{
    42    this->setClassID(CL_SHADER, "Shader");
     86  if (!Shader::checkShaderAbility())
     87    PRINTF(2)("Your system does not support shaders\n");
     88  this->load(vertexShaderFile, fragmentShaderFile);
    4389
    44    this->shaderProgram = 0;
    45    this->vertexShader = 0;
    46    this->fragmentShader = 0;
    47 
    48    if (GLEW_ARB_shader_objects && GLEW_ARB_shading_language_100)
    49      {
    50        this->shaderProgram = glCreateProgramObjectARB();
    51 
    52        if (!vertexShaderFile.empty())
    53          this->loadShaderProgramm(Shader::Vertex, vertexShaderFile);
    54        if (!fragmentShaderFile.empty())
    55          this->loadShaderProgramm(Shader::Fragment, fragmentShaderFile);
    56 
    57        this->linkShaderProgram();
    58 
    59     }
    60    else
    61      {
    62        PRINTF(2)("Shaders are not supported on your hardware\n");
    63      }
    6490}
    6591
     92const Shader* Shader::storedShader = NULL;
    6693
    67 /**
    68  * standard deconstructor
    69  */
    70 Shader::~Shader ()
     94void Shader::activateShader() const
    7195{
    72   if (this->shaderProgram == glGetHandleARB(GL_PROGRAM_OBJECT_ARB))
    73     Shader::deactivateShader();
    74 
    75   // delete what has to be deleted here
    76   this->deleteProgram(Shader::Vertex);
    77   this->deleteProgram(Shader::Fragment);
    78 
    79   if (this->fragmentShader != 0)
     96  if (likely (this->getProgram() != 0))
    8097  {
    81     glDetachObjectARB(this->shaderProgram, this->fragmentShader);
    82     glDeleteObjectARB(this->fragmentShader);
    83   }
    84   if (this->vertexShader != 0)
    85   {
    86     glDetachObjectARB(this->shaderProgram, this->vertexShader);
    87     glDeleteObjectARB(this->vertexShader);
    88   }
    89   if (this->shaderProgram != 0)
    90   {
    91     GLint status = 0;
    92     //glLinkProgramARB(this->shaderProgram);
    93     glDeleteObjectARB(this->shaderProgram);
    94        // link error checking
    95     glGetObjectParameterivARB(this->shaderProgram, GL_OBJECT_DELETE_STATUS_ARB, &status);
    96     if (status == GL_INVALID_VALUE || status == GL_INVALID_OPERATION)
    97       this->printError(this->shaderProgram);
    98   }
    99 }
    100 
    101 Shader* Shader::getShader(const std::string& vertexShaderFile, const std::string& fragmentShaderFile)
    102 {
    103   return (Shader*)ResourceManager::getInstance()->load(vertexShaderFile, SHADER,  RP_LEVEL, fragmentShaderFile);
    104 }
    105 
    106 bool Shader::unload(Shader* shader)
    107 {
    108   return ResourceManager::getInstance()->unload(shader);
    109 }
    110 
    111 Shader* Shader::storedShader = NULL;
    112 
    113 
    114 bool Shader::loadShaderProgramm(Shader::Type type, const std::string& fileName)
    115 {
    116   GLhandleARB shader = 0;
    117 
    118   if (type != Shader::Vertex && type != Shader::Fragment)
    119     return false;
    120   this->deleteProgram(type);
    121 
    122 
    123   std::string program;
    124   if (!readShader(fileName, program))
    125     return false;
    126 
    127   if (type == Shader::Vertex && GLEW_ARB_vertex_shader)
    128   {
    129     this->vertexShaderFile = fileName;
    130 
    131     shader = this->vertexShader = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
    132   }
    133 
    134   if (type == Shader::Fragment && GLEW_ARB_fragment_shader)
    135   {
    136     this->fragmentShaderFile = fileName;
    137 
    138     shader = this->fragmentShader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
    139   }
    140 
    141   if (shader != 0)
    142   {
    143     GLint status = 0;
    144     const char* prog = program.c_str();
    145 
    146     glShaderSourceARB(shader, 1, &prog, NULL);
    147     glCompileShaderARB(shader);
    148     // checking on error.
    149     glGetObjectParameterivARB(shader, GL_OBJECT_COMPILE_STATUS_ARB, &status);
    150     if (status == GL_INVALID_VALUE || status == GL_INVALID_OPERATION)
    151       this->printError(shader);
    152     else
    153       glAttachObjectARB(this->shaderProgram, shader);
    154   }
    155   return true;
    156 }
    157 
    158 
    159 void Shader::linkShaderProgram()
    160 {
    161   GLint status = 0;
    162 
    163   glLinkProgramARB(this->shaderProgram);
    164        // link error checking
    165   glGetObjectParameterivARB(this->shaderProgram, GL_OBJECT_LINK_STATUS_ARB, &status);
    166   if (status == GL_INVALID_VALUE || status == GL_INVALID_OPERATION)
    167     this->printError(this->shaderProgram);
    168 }
    169 
    170 
    171 bool Shader::readShader(const std::string& fileName, std::string& output)
    172 {
    173   char lineBuffer[PARSELINELENGTH];
    174 
    175   std::ifstream shader;
    176   shader.open(fileName.c_str());
    177   if (!shader.is_open())
    178     return false;
    179 
    180 
    181   while (!shader.eof())
    182   {
    183     shader.getline(lineBuffer, PARSELINELENGTH);
    184     output += lineBuffer;
    185     output += "\n";
    186   }
    187 
    188 
    189   shader.close();
    190   return true;
    191 }
    192 
    193 
    194 
    195 void Shader::activateShader()
    196 {
    197   if (likely (this->shaderProgram != 0))
    198   {
    199     glUseProgramObjectARB(this->shaderProgram);
     98    glUseProgramObjectARB(this->getProgram());
    20099    Shader::storedShader = this;
    201100  }
    202101}
    203 
    204 void Shader::bindShader(const char* name, const float* value, size_t size)
    205 {
    206         if (likely (this->shaderProgram != 0)) {
    207                 glUseProgramObjectARB(this->shaderProgram);
    208 
    209                 unsigned int location = glGetUniformLocationARB(this->shaderProgram, name);
    210                 /* This is EXPENSIVE and should be avoided. */
    211 
    212                 if      (size == 1)  glUniform1fvARB(location, 1, value);
    213                 else if (size == 2)  glUniform2fvARB(location, 1, value);
    214                 else if (size == 3)  glUniform3fvARB(location, 1, value);
    215                 else if (size == 4)  glUniform4fvARB(location, 1, value);
    216                 else if (size == 9)  glUniformMatrix3fvARB(location, 1, false, value);
    217                 else if (size == 16) glUniformMatrix4fvARB(location, 1, false, value);
    218 
    219         }
    220 }
    221 
    222102void Shader::deactivateShader()
    223103{
    224  if (storedShader != NULL)
    225    glUseProgramObjectARB(0);
    226  Shader::storedShader = NULL;
    227 }
    228 
    229 
    230 void Shader::deleteProgram(Shader::Type type)
    231 {
    232   GLint status = 0;
    233   if (type == Shader::Vertex && this->vertexShader != 0)
    234   {
    235     this->vertexShaderFile = "";
    236     glDetachObjectARB(this->shaderProgram, this->vertexShader);
    237     glDeleteObjectARB(this->vertexShader);
    238     glGetObjectParameterivARB(this->vertexShader, GL_OBJECT_DELETE_STATUS_ARB, &status);
    239     if (status == GL_INVALID_VALUE || status == GL_INVALID_OPERATION)
    240       Shader::printError(this->vertexShader);
    241     this->vertexShader = 0;
    242   }
    243   else if (type == Shader::Fragment && this->fragmentShader != 0)
    244   {
    245     this->fragmentShaderFile = "";
    246     glDetachObjectARB(this->shaderProgram, this->fragmentShader);
    247     glDeleteObjectARB(this->fragmentShader);
    248     glGetObjectParameterivARB(this->fragmentShader, GL_OBJECT_DELETE_STATUS_ARB, &status);
    249     if (status == GL_INVALID_VALUE || status == GL_INVALID_OPERATION)
    250       Shader::printError(this->fragmentShader);
    251     this->fragmentShader = 0;
    252   }
    253   else
    254     return;
    255 }
    256 
    257 
    258 void Shader::printError(GLhandleARB program)
    259 {
    260   if (program == 0)
    261     return;
    262 
    263   int infologLength = 0;
    264   int charsWritten  = 0;
    265   char *infoLog;
    266 
    267   glGetObjectParameterivARB(program, GL_OBJECT_INFO_LOG_LENGTH_ARB,
    268                             &infologLength);
    269 
    270   if (infologLength > 0)
    271   {
    272     infoLog = new char[infologLength+1];
    273     glGetInfoLogARB(program, infologLength, &charsWritten, infoLog);
    274     printf("%s\n", infoLog);
    275     delete[] infoLog;
    276   }
     104  if (storedShader != NULL)
     105    glUseProgramObjectARB(0);
     106  Shader::storedShader = NULL;
    277107}
    278108
     
    288118}
    289119
    290 void Shader::debug() const
    291 {
    292   PRINT(3)("Shader info: (SHADER: %d)\n", this->shaderProgram);
    293   if (this->vertexShader != 0)
    294   {
    295 /*    PRINT(3)("VertexShaderProgramm: number=%d, file='%s'\n", this->vertexShader, this->vertexShaderFile);
    296     if (this->vertexShaderSource != NULL)
    297       for (unsigned int i = 0; i < this->vertexShaderSource->getCount(); i++)
    298         PRINT(3)("%d: %s\n", i, this->vertexShaderSource->getEntry(i));
    299   }
    300   if (this->fragmentShader != 0)
    301   {
    302     PRINT(3)("FragmentShaderProgramm: number=%d, file='%s'\n", this->fragmentShader, this->fragmentShaderFile);
    303     if (this->fragmentShaderSource != NULL)
    304       for (unsigned int i = 0; i < this->fragmentShaderSource->getCount(); i++)
    305         PRINT(3)("%d: %s\n", i, this->fragmentShaderSource->getEntry(i));*/
    306   }
    307 }
    308120
  • trunk/src/lib/graphics/shader.h

    r8255 r9869  
    88
    99#include "base_object.h"
    10 #include "glincl.h"
    11 #include <vector>
    12 
     10#include "shader_data.h"
    1311
    1412// FORWARD DECLARATION
     
    1614
    1715
    18 //! A class for ...
     16//! The Shader is a Class-wrapper around the OpenGL Shader Language (GLSL).
    1917class Shader : public BaseObject
    2018{
     19  ObjectListDeclaration(Shader);
    2120public:
    2221  class Uniform
    2322  {
    2423  public:
    25     Uniform(const Shader* shader, const std::string& location) { this->uniform = glGetUniformLocationARB(shader->getProgram(), location.c_str()) ; }
    2624    Uniform(const Shader& shader, const std::string& location) { this->uniform = glGetUniformLocation(shader.getProgram(), location.c_str()) ; };
    2725    Uniform(GLhandleARB shaderProgram, const std::string& location) { this->uniform = glGetUniformLocation(shaderProgram, location.c_str()) ; };
     
    3735    void set(int v0, int v1, int v2, int v3) const { glUniform4i(this->uniform, v0, v1, v2, v3); }
    3836
    39     void setV(unsigned int count, float* vv) const
    40     {
    41       switch (count)
    42       {
    43         case 1:
    44           glUniform1fv(this->uniform, 1, vv);
    45           break;
    46         case 2:
    47           glUniform2fv(this->uniform, 2, vv);
    48           break;
    49         case 3:
    50           glUniform3fv(this->uniform, 3, vv);
    51           break;
    52         case 4:
    53           glUniform4fv(this->uniform, 4, vv);
    54           break;
    55       }
    56     }
    57     void setV(unsigned int count, int* vv) const
    58     {
    59       switch (count)
    60       {
    61         case 1:
    62           glUniform1iv(this->uniform, 1, vv);
    63           break;
    64         case 2:
    65           glUniform2iv(this->uniform, 2, vv);
    66           break;
    67         case 3:
    68           glUniform3iv(this->uniform, 3, vv);
    69           break;
    70         case 4:
    71           glUniform4iv(this->uniform, 4, vv);
    72           break;
    73       }
    74     }
    75     private:
     37    void setV(unsigned int count, float* vv) const;
     38    void setV(unsigned int count, int* vv) const;
     39
     40  private:
    7641    GLint uniform;
    7742  };
    7843
    79   typedef enum
    80   {
    81     None       = 0,
    82     Fragment   = 1,
    83     Vertex     = 2,
    84 
    85     Program    = 4,
    86   }
    87   Type;
    8844
    8945public:
    90   Shader(const std::string& vertexShaderFile = "", const std::string& fragmentShaderFile = "");
    91   virtual ~Shader();
    92   static Shader* getShader(const std::string& vertexShaderFile, const std::string& fragmentShaderFile);
    93   static bool unload(Shader* shader);
     46  Shader();
     47  Shader(const std::string& vertexShaderFile, const std::string& fragmentShaderFile = "");
     48
     49  Shader& operator=(const Shader& shader) { this->data = shader.data; return *this; };
     50  const ShaderData::Pointer& dataPointer() const { return data; };
     51  void acquireData(const ShaderData::Pointer& pointer) { this->data = pointer; };
     52
     53  bool load(const std::string& vertexShaderFile, const std::string& fragmentShaderFile = "")
     54    { return this->data->load(vertexShaderFile, fragmentShaderFile); }
     55
     56
     57  Shader::Uniform getUniform(const std::string& location) { return Shader::Uniform(*this, location); }
     58
     59  GLhandleARB getProgram() const { return this->data->getProgram(); }
     60  GLhandleARB getVertexS() const { return this->data->getVertexS(); }
     61  GLhandleARB getFragmentS() const { return this->data->getFragmentS(); }
     62
     63  void activateShader() const;
     64  static void deactivateShader();
     65
     66  void debug() const { this->data->debug(); };
    9467
    9568
    9669  static bool checkShaderAbility();
    97   void activateShader();
    98   void bindShader(const char* name, const float* value, size_t size);
    99   static void deactivateShader();
    10070
    101   Shader::Uniform getUniform(const std::string& location) { return Shader::Uniform(this, location); }
     71  inline static bool isShaderActive() { return (Shader::storedShader != NULL) ? true : false; };
     72  inline static const Shader* getActiveShader() { return Shader::storedShader; };
    10273
    103   bool loadShaderProgramm(Shader::Type type, const std::string& fileName);
    104   void deleteProgram(Shader::Type type);
    105 
    106   void linkShaderProgram();
    107 
    108 
    109   bool readShader(const std::string& fileName, std::string& output);
    110 
    111 
    112 inline static bool shaderActive() { return (Shader::storedShader != NULL)? true : false; };
    113   inline static Shader* getActiveShader() { return Shader::storedShader; };
    114   inline static void suspendShader() { Shader* currShader = storedShader; if (storedShader!= NULL) { Shader::deactivateShader(); Shader::storedShader = currShader;} };
     74  inline static void suspendShader() { const Shader* currShader = storedShader; if (storedShader!= NULL) { Shader::deactivateShader(); Shader::storedShader = currShader;} };
    11575  inline static void restoreShader() { if (storedShader != NULL) storedShader->activateShader(); storedShader = NULL; };
    11676
     77private:
     78  ShaderData::Pointer    data;
    11779
    118 
    119 
    120   GLhandleARB getProgram() const { return this->shaderProgram; }
    121   GLhandleARB getVertexS() const { return this->vertexShader; }
    122   GLhandleARB getFragmentS() const { return this->fragmentShader; }
    123 
    124   void debug() const;
    125 
    126   static void printError(GLhandleARB program);
    127 
    128 
    129 private:
    130   std::string            fragmentShaderFile;
    131   std::string            vertexShaderFile;
    132 
    133   GLhandleARB            shaderProgram;
    134 
    135   GLhandleARB            vertexShader;
    136   GLhandleARB            fragmentShader;
    137 
    138 
    139   static Shader*         storedShader;
     80  static const Shader*         storedShader;
    14081};
    14182
  • trunk/src/lib/graphics/spatial_separation/quadtree.cc

    r9406 r9869  
    2727#define QUADTREE_MATERIAL_COUNT       4
    2828
     29ObjectListDefinition(Quadtree);
    2930/**
    3031 *  standard constructor
     
    3233Quadtree::Quadtree (const modelInfo* pModelInfo, const int treeDepth)
    3334{
    34   this->setClassID(CL_QUADTREE, "Quadtree");
     35  this->registerObject(this, Quadtree::_objectList);
    3536  this->pModelInfo = pModelInfo;
    3637  this->treeDepth = treeDepth;
  • trunk/src/lib/graphics/spatial_separation/quadtree.h

    r6022 r9869  
    2121//! A class for quadtree separation of the world
    2222class Quadtree : public BaseObject {
    23 
     23  ObjectListDeclaration(Quadtree);
    2424
    2525  public:
  • trunk/src/lib/graphics/spatial_separation/quadtree_node.cc

    r9406 r9869  
    2727
    2828
    29 
     29ObjectListDefinition(QuadtreeNode);
    3030
    3131/**
     
    102102void QuadtreeNode::init()
    103103{
    104   this->setClassID(CL_QUADTREE_NODE, "QuadtreeNode");
     104  this->registerObject(this, QuadtreeNode::_objectList);
    105105
    106106  /* init the rest of the variables for both init types */
  • trunk/src/lib/graphics/spatial_separation/quadtree_node.h

    r6617 r9869  
    2626//! A class for a Quadtree Node representation
    2727class QuadtreeNode : public BaseObject {
     28  ObjectListDeclaration(QuadtreeNode);
    2829
    2930  public:
  • trunk/src/lib/graphics/spatial_separation/spatial_separation.cc

    r9406 r9869  
    2424
    2525
    26 
     26ObjectListDefinition(SpatialSeparation);
    2727
    2828/**
    29  * standard constructor
     29 * @brief standard constructor
    3030 * @param model the model that is to be separated
    3131 * @param overlapSize each box will overlap for a given size
    32 
    33    The boxes are overlaping because this makes collision detection a lot simpler
    34 
     32 *
     33 * The boxes are overlaping because this makes collision detection a lot simpler
     34 *
    3535 */
    3636SpatialSeparation::SpatialSeparation (Model* model, float overlapSize)
     
    3939  PRINT(3)("+-| (Event) Spatial Separation process kicked on\n");
    4040
    41   this->setClassID(CL_SPATIAL_SEPARATION, "SpatialSeparation");
     41  this->registerObject(this, SpatialSeparation::_objectList);
    4242  /* debug vice */
    4343  this->createQuadtree(model);
     
    4646
    4747/**
    48  * standard constructor
     48 * @brief standard constructor
    4949 * @param model the model that is to be separated
    5050 * @param overlapSize each box will overlap for a given size
     
    5454SpatialSeparation::SpatialSeparation (Model* model, Model* playerModel)
    5555{
    56   this->setClassID(CL_SPATIAL_SEPARATION, "SpatialSeparation");
     56  this->registerObject(this, SpatialSeparation::_objectList);
    5757
    5858}
     
    6060
    6161/**
    62  * standard deconstructor
     62 * @brief standard deconstructor
    6363 */
    6464SpatialSeparation::~SpatialSeparation ()
     
    7070
    7171/**
    72  * creates a quadtree
     72 * @brief creates a quadtree
    7373 * @param model the model to do a quadtree on
    7474 * @param minLength the minimal length of a quadtree node
     
    8383
    8484/**
    85  *  brief creates a quadtree
     85 * @brief creates a quadtree
    8686 * @param model the model to do a quadtree on
    8787 * @param minLength the minimal length of a quadtree node
     
    9595
    9696/**
    97  * creates a quadtree
     97 * @brief creates a quadtree
    9898 * @param model the model to do a quadtree on
    9999 * @param minLength the minimal length of a quadtree node
     
    109109
    110110/**
    111  * draws all the quadtrees
     111 * @brief draws all the quadtrees
    112112 */
    113113void SpatialSeparation::drawQuadtree()
     
    118118  this->quadtree->drawTree();
    119119}
    120 
    121 
    122 
    123 
    124 
    125 
    126 
    127 
    128 
    129 
    130 
    131 
  • trunk/src/lib/graphics/spatial_separation/spatial_separation.h

    r6022 r9869  
    1919//! A class for spatial separation of vertices based arrays
    2020class SpatialSeparation : public BaseObject {
     21  ObjectListDeclaration(SpatialSeparation);
    2122
    2223  public:
  • trunk/src/lib/graphics/text_engine/font.cc

    r8989 r9869  
    2929#include "compiler.h"
    3030
     31ObjectListDefinition(Font);
    3132
    3233Font::Font()
     
    3435{
    3536  this->init();
    36 
    3737}
    3838
     
    118118  Material::operator=(font);
    119119  this->data = font.data;
     120  this->setTexture(this->data->textureData());
    120121
    121122  return *this;
     
    130131  this->setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    131132
    132   this->setClassID(CL_FONT, "Font");
    133   if (Font::defaultFontData.get() == NULL)
     133  this->registerObject(this, Font::_objectList);
     134  if (Font::defaultFontData.isNull())
    134135  {
    135136    Font::initDefaultFont();
     
    138139}
    139140
    140 FontDataPointer Font::defaultFontData(NULL);
     141FontData::Pointer Font::defaultFontData(NULL);
    141142
    142143/**
     
    146147{
    147148  // temporarily create a Font.
    148   Font::defaultFontData = FontDataPointer(new FontData);
     149  Font::defaultFontData = FontData::Pointer(new FontData);
    149150  // apply the Data.
    150151  Font::defaultFontData = Font(font_xpm).data;
     
    159160bool Font::loadFontFromTTF(const std::string& fontFile, unsigned int renderSize)
    160161{
    161   this->data = FontDataPointer (new FontData());
     162  this->data = FontData::Pointer (new FontData());
    162163  bool retVal = this->data->loadFontFromTTF(fontFile, renderSize);
    163164  if (!retVal)
     
    174175bool Font::loadFontFromSDL_Surface(SDL_Surface* surface)
    175176{
    176   this->data = FontDataPointer (new FontData());
     177  this->data = FontData::Pointer (new FontData());
    177178  bool retVal = this->data->loadFontFromSDL_Surface(surface);
    178179  if (!retVal)
     
    196197
    197198
    198 void Font::setTexture(const TextureDataPointer& texDataPointer)
     199void Font::setTexture(const TextureData::Pointer& texDataPointer)
    199200{
    200201  this->setDiffuseMap(texDataPointer);
  • trunk/src/lib/graphics/text_engine/font.h

    r8766 r9869  
    1919class Font : public Material
    2020{
    21 
     21  ObjectListDeclaration(Font);
     22public:
     23  typedef FontData::Glyph Glyph;
    2224public:
    2325  Font();
     
    3941
    4042  /** @returns a Pointer to the Array of Glyphs */
    41   inline Glyph** getGlyphArray() const { return this->data->getGlyphArray(); };
     43  inline const Glyph* const * const getGlyphArray() const { return this->data->getGlyphArray(); };
    4244
    4345  inline int getMaxHeight() const { return data->getMaxHeight(); };
     
    5052  void debug() const;
    5153
     54  void acquireData(const FontData::Pointer& data) { this->data = data; };
     55  const FontData::Pointer& dataPointer() const { return data; };
    5256private:
    5357  void init();
    5458  static void initDefaultFont();
    5559
    56   void setTexture(const TextureDataPointer& texDataPointer);
     60  void setTexture(const TextureData::Pointer& texDataPointer);
    5761
    5862private:
    59   FontDataPointer           data;                //!< A Data-Pointer to a Font.
     63  FontData::Pointer         data;                //!< A Data-Pointer to a Font.
    6064
    61   static FontDataPointer    defaultFontData;     //!< a default font, that is used, if other fonts were unable to be loaded.
     65  static FontData::Pointer  defaultFontData;     //!< a default font, that is used, if other fonts were unable to be loaded.
    6266};
    6367
  • trunk/src/lib/graphics/text_engine/font_data.h

    r8768 r9869  
    2626#define FONT_DEFAULT_RENDER_SIZE     50            //!< At what Resolution to render fonts.
    2727
     28class FontData
     29{
     30
     31
     32public:
     33
    2834//! A struct for handling glyphs
    2935/**
    3036 * a Glyph is one letter of a certain font
    3137 */
    32 struct Glyph
    33 {
     38  struct Glyph
     39  {
    3440  // Glyph-specific (size and so on)
    35   Uint16   character;         //!< The character
    36   float    minX;              //!< The minimum distance from the origin in X
    37   float    maxX;              //!< The maximum distance from the origin in X
    38   float    minY;              //!< The minimum distance from the origin in Y
    39   float    maxY;              //!< The maximum distance from the origin in Y
    40   float    width;             //!< The width of the Glyph
    41   float    height;            //!< The height of the Glyph
    42   float    bearingX;          //!< How much is right of the Origin
    43   float    bearingY;          //!< How much is above the Origin
    44   float    advance;           //!< How big a Glyph would be in monospace-mode
     41    Uint16   character;         //!< The character
     42    float    minX;              //!< The minimum distance from the origin in X
     43    float    maxX;              //!< The maximum distance from the origin in X
     44    float    minY;              //!< The minimum distance from the origin in Y
     45    float    maxY;              //!< The maximum distance from the origin in Y
     46    float    width;             //!< The width of the Glyph
     47    float    height;            //!< The height of the Glyph
     48    float    bearingX;          //!< How much is right of the Origin
     49    float    bearingY;          //!< How much is above the Origin
     50    float    advance;           //!< How big a Glyph would be in monospace-mode
    4551
    46   GLfloat texCoord[4];        //!< Texture coordinates: 0:left, 1:right, 2: top, 3: bottom.
    47 };
     52    GLfloat texCoord[4];        //!< Texture coordinates: 0:left, 1:right, 2: top, 3: bottom.
     53  };
    4854
    49 
    50 class FontData
    51 {
     55  typedef CountPointer<FontData> Pointer;
    5256public:
    5357  FontData();
     
    6165
    6266  /** @returns a Pointer to the Array of Glyphs */
    63   inline Glyph** getGlyphArray() const { return this->glyphArray; };
     67  inline const Glyph* const * const getGlyphArray() const { return this->glyphArray; };
    6468
    6569  int getMaxHeight() const { return maxHeight; };
     
    6872
    6973  /** @returns the Texture-Data of this FontData */
    70   const TextureDataPointer& textureData() const { return texData; };
     74  const TextureData::Pointer& textureData() const { return texData; };
    7175
    7276  bool rebuild() { return texData->rebuild(); };
     
    9195  int           maxDescent;          //!< Max Desent of the Font.
    9296
    93   TextureDataPointer   texData;
     97  TextureData::Pointer   texData;
    9498};
    9599
    96 typedef CountPointer<FontData> FontDataPointer;
    97 
    98100#endif /* _FONT_DATA_H */
  • trunk/src/lib/graphics/text_engine/limited_width_text.cc

    r9406 r9869  
    1919#include "font.h"
    2020
     21ObjectListDefinition(LimitedWidthText);
    2122/**
    2223 * @brief creates a new Text Element
     
    2728    : Text(fontFile, textSize)
    2829{
    29   this->setClassID(CL_LIMITED_WIDTH_TEXT, "LimitedWidthText");
     30  this->registerObject(this, LimitedWidthText::_objectList);
    3031
    3132  this->_dotsPosition = End;
     
    7576  glRotatef(this->getAbsDir2D(), 0, 0, 1);
    7677
    77   Glyph* tmpGlyph;
     78  const Font::Glyph* tmpGlyph;
    7879  float posX = 0.0f;
    7980  glBegin(GL_QUADS);
  • trunk/src/lib/graphics/text_engine/limited_width_text.h

    r8980 r9869  
    1414class LimitedWidthText : public Text
    1515{
     16  ObjectListDeclaration(LimitedWidthText);
    1617  public:
    1718    typedef enum {
  • trunk/src/lib/graphics/text_engine/multi_line_text.cc

    r9406 r9869  
    1919#include "font.h"
    2020
     21ObjectListDefinition(MultiLineText);
     22
    2123/**
    2224 * @brief creates a new Text Element
     
    2729  : Text(fontFile, textSize)
    2830{
    29   this->setClassID(CL_MULTI_LINE_TEXT, "MultiLineText");
     31  this->registerObject(this, MultiLineText::_objectList);
    3032
    3133  this->lineSpacing = 1.0;
     
    7880  glRotatef(this->getAbsDir2D(), 0, 0, 1);
    7981
    80   Glyph* tmpGlyph;
     82  const Font::Glyph* tmpGlyph;
    8183  float posX = 0.0f;
    8284  float posY = 0.0f;
  • trunk/src/lib/graphics/text_engine/multi_line_text.h

    r7757 r9869  
    1414class MultiLineText : public Text
    1515{
     16  ObjectListDeclaration(MultiLineText);
    1617  public:
    1718    MultiLineText(const std::string& fontFile = "", unsigned int fontSize = TEXT_DEFAULT_SIZE, float lineWidth = 100.0);
  • trunk/src/lib/graphics/text_engine/text.cc

    r9406 r9869  
    1717
    1818#include "text.h"
     19#include "resource_font.h"
    1920#include "font.h"
    20 
    21 #include "util/loading/resource_manager.h"
    2221#include "debug.h"
     22
     23ObjectListDefinition(Text);
    2324
    2425/**
     
    2829 */
    2930Text::Text(const std::string& fontFile, unsigned int textSize)
    30     // : _font(fontFile, FONT_DEFAULT_RENDER_SIZE)
    31 {
    32   this->setClassID(CL_TEXT, "Text");
     31// : _font(fontFile, FONT_DEFAULT_RENDER_SIZE)
     32{
     33  this->registerObject(this, Text::_objectList);
    3334
    3435  // initialize this Text
    35   this->setFont(fontFile, FONT_DEFAULT_RENDER_SIZE);
     36  if (!fontFile.empty())
     37    this->setFont(fontFile, FONT_DEFAULT_RENDER_SIZE);
     38  else
     39    this->setFont("fonts/final_frontier.ttf", FONT_DEFAULT_RENDER_SIZE);
    3640  this->_size = textSize;
    3741  this->setSizeY2D(textSize);
     
    4448    : _font()
    4549{
    46   this->setClassID(CL_TEXT, "Text");
     50  this->registerObject(this, Text::_objectList);
    4751
    4852  *this = text;
     
    169173void Text::setFont(const std::string& fontFile, unsigned int fontSize)
    170174{
    171   Font* newFont = NULL;
    172   //  Font* oldFont = this->_font;
    173 
    174   // load a new Font
    175   if (!fontFile.empty())
    176   {
    177     newFont = (Font*)ResourceManager::getInstance()->load(fontFile, TTF, RP_GAME, (int)fontSize);
    178     if (newFont == NULL)
    179     {
    180       //      newFont = &Font::();
    181       PRINTF(2)("Font %s could not be loaded, probably file not found\n", fontFile.c_str());
    182     }
    183   }
    184 
    185   if (newFont == NULL)
    186     this->_font = Font();
    187   else
    188     this->_font = *newFont;
     175  this->_font = ResourceFont(fontFile, fontSize);
    189176
    190177  this->setupTextWidth();
     
    233220  glRotatef(this->getAbsDir2D(), 0, 0, 1);
    234221
    235   Glyph* tmpGlyph;
     222  const Font::Glyph* tmpGlyph;
    236223  float posX = 0.0f;
    237224  glBegin(GL_QUADS);
  • trunk/src/lib/graphics/text_engine/text.h

    r8764 r9869  
    2626class Text : public Element2D
    2727{
     28  ObjectListDeclaration(Text);
    2829  public:
    2930    Text(const std::string& fontFile = "", unsigned int fontSize = TEXT_DEFAULT_SIZE);
  • trunk/src/lib/graphics/text_engine/text_engine.cc

    r9406 r9869  
    3333
    3434#include "graphics_engine.h"
    35 #include "util/loading/resource_manager.h"
    36 #include "class_list.h"
    3735
    3836#include "debug.h"
     
    4038/// TEXT-ENGINE ///
    4139///////////////////
     40ObjectListDefinition(TextEngine);
    4241/**
    4342 *  standard constructor
     
    4544TextEngine::TextEngine ()
    4645{
    47    this->setClassID(CL_TEXT_ENGINE, "TextEngine");
    48    this->setName("TextEngine");
    49    this->enableFonts();
     46  this->registerObject(this, TextEngine::_objectList);
     47  this->setName("TextEngine");
     48  this->enableFonts();
    5049}
    5150
     
    6261{
    6362  // first remove all the remaining Texts (if any).
    64   const std::list<BaseObject*>* textList = ClassList::getList(CL_TEXT);
    65   if (textList != NULL)
    66   {
    67     while(textList->size() > 0)
    68       delete dynamic_cast<Text*>(textList->front());
    69   }
     63  while (!Text::objectList().empty())
     64    delete Text::objectList().front();
    7065  // delete all remaining fonts (There should not be Anything to do here)
    71   const std::list<BaseObject*>* fontList = ClassList::getList(CL_FONT);
    72   if (fontList != NULL)
     66
     67  //const std::list<BaseObject*>* fontList = ClassList::getList(CL_FONT);
     68  //if (fontList != NULL)
    7369  {
    7470    ///FIXME
    75 //    while (fontList->size() > 0)
     71    //    while (fontList->size() > 0)
    7672    {
    77 //      Font* font = dynamic_cast<Font*>(fontList->back());
     73      //      Font* font = dynamic_cast<Font*>(fontList->back());
    7874      //if (likely(font != Font::getDefaultFont()))
    7975      //        ResourceManager::getInstance()->unload(font, RP_GAME);
     
    9187{
    9288  if (!TTF_WasInit())
    93     {
    94       if(TTF_Init()==-1)
    95         PRINTF(1)("TTF_Init: %s\n", TTF_GetError());
     89  {
     90    if(TTF_Init()==-1)
     91      PRINTF(1)("TTF_Init: %s\n", TTF_GetError());
    9692
    97       TextEngine::checkVersion();
    98     }
     93    TextEngine::checkVersion();
     94  }
    9995  else
    10096    PRINTF(4)("Fonts already initialized\n");
     
    107103{
    108104  if (TTF_WasInit())
    109     {
    110 //      Font::removeDefaultFont();
    111       TTF_Quit();
    112     }
     105  {
     106    //      Font::removeDefaultFont();
     107    TTF_Quit();
     108  }
    113109  else
    114110    PRINTF(4)("Fonts were not initialized.\n");
     
    122118void TextEngine::debug() const
    123119{
    124   const std::list<BaseObject*>* textList = ClassList::getList(CL_TEXT);
    125   if (textList != NULL)
     120  PRINT(0)("+-------------------------------+\n");
     121  PRINT(0)("+ TEXT ENGINE DEBUG INFORMATION +\n");
     122  PRINT(0)("+-------------------------------+\n");
     123  PRINT(0)("Reference: %p; Text Counts: %d\n", this, Text::objectList().size());
     124
     125  for (ObjectList<Text>::const_iterator it = Text::objectList().begin();
     126       it != Text::objectList().end();
     127       ++it)
    126128  {
    127     PRINT(0)("+-------------------------------+\n");
    128     PRINT(0)("+ TEXT ENGINE DEBUG INFORMATION +\n");
    129     PRINT(0)("+-------------------------------+\n");
    130     PRINT(0)("Reference: %p; Text Counts: %d\n", this, textList->size());
    131 
    132     std::list<BaseObject*>::const_iterator text;
    133     for ( text = textList->begin(); text != textList->end(); text++)
    134       dynamic_cast<Text*>(*text)->debug();
     129      (*it)->debug();
    135130    PRINT(0)("+---------------------------TE--+\n");
    136131  }
     
    152147      compile_version.minor == link_version.minor &&
    153148      compile_version.patch == link_version.patch)
    154     {
    155       return true;
    156     }
     149  {
     150    return true;
     151  }
    157152  else
    158     {
    159       PRINTF(2)("compiled with SDL_ttf version: %d.%d.%d\n",
    160                 compile_version.major,
    161                 compile_version.minor,
    162                 compile_version.patch);
     153  {
     154    PRINTF(2)("compiled with SDL_ttf version: %d.%d.%d\n",
     155              compile_version.major,
     156              compile_version.minor,
     157              compile_version.patch);
    163158
    164       PRINTF(2)("running with SDL_ttf version: %d.%d.%d\n",
    165                 link_version.major,
    166                 link_version.minor,
    167                 link_version.patch);
    168       return false;
    169     }
     159    PRINTF(2)("running with SDL_ttf version: %d.%d.%d\n",
     160              link_version.major,
     161              link_version.minor,
     162              link_version.patch);
     163    return false;
     164  }
    170165}
  • trunk/src/lib/graphics/text_engine/text_engine.h

    r5515 r9869  
    2424class TextEngine : public BaseObject
    2525{
    26  public:
     26  ObjectListDeclaration(TextEngine);
     27  public:
    2728  virtual ~TextEngine();
    2829  /** @returns a Pointer to the only object of this Class */
Note: See TracChangeset for help on using the changeset viewer.