Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9831 in orxonox.OLD for branches/new_class_id/src/lib/graphics


Ignore:
Timestamp:
Sep 26, 2006, 3:18:28 PM (18 years ago)
Author:
bensch
Message:

added resource_obj for new resource managed obj-loader

Location:
branches/new_class_id/src/lib/graphics/importer
Files:
5 edited
2 copied

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/graphics/importer/Makefile.am

    r9829 r9831  
    1313                static_model_data.cc \
    1414                objModel.cc \
     15                resource_obj.cc \
    1516                primitive_model.cc \
    1617                height_map.cc \
     
    6061                static_model_data.h \
    6162                objModel.h \
     63                resource_obj.h \
    6264                primitive_model.h \
    6365                anorms.h \
  • branches/new_class_id/src/lib/graphics/importer/objModel.cc

    r9830 r9831  
    1818#include "objModel.h"
    1919
    20 #include <stdio.h>
    2120#include <string.h>
    22 #include <stdlib.h>
    2321
    2422#define PARSELINELENGTH 8192
  • branches/new_class_id/src/lib/graphics/importer/objModel.h

    r9715 r9831  
    1313{
    1414  ObjectListDeclaration(OBJModel);
    15   public:
    16    OBJModel(const std::string& fileName, float scaling = 1.0);
     15public:
     16  OBJModel(const std::string& fileName, float scaling = 1.0);
    1717  virtual ~OBJModel();
    1818
    19  private:
     19private:
    2020  ///// readin /////
    21    bool importFile (const std::string& fileName);
    22    bool readFromObjFile (const std::string& fileName);
    23    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);
    2424
    25   private:
    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);
     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);
    3232
    33  private:
    34    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.
    3535};
    3636
  • branches/new_class_id/src/lib/graphics/importer/resource_obj.cc

    r9830 r9831  
    11
    2 #include "resource_texture.h"
     2#include "resource_obj.h"
    33#include "substring.h"
    44#include "multi_type.h"
     
    66
    77
    8 ResourceTexture::ResourceTexture(const std::string& imageName, GLenum target)
    9     : NewResource(&ResourceTexture::type)
     8ResourceOBJ::ResourceOBJ(const std::string& imageName, float scaling)
     9    : NewResource(&ResourceOBJ::type)
    1010{
    11   Resources::StorePointer* ptr = this->acquireResource(imageName + ',' + "TEST");
     11  Resources::StorePointer* ptr = this->acquireResource(imageName + ',' + MultiType(scaling).getString());
    1212
    1313  if (ptr)
    1414  {
    15     PRINTF(5)("FOUNT TEXTURE: %s\n", imageName.c_str());
    16     this->acquireData(static_cast<ResourceTexture::TextureResourcePointer*>(ptr)->ptr());
     15    PRINTF(5)("FOUND OBJ: %s\n", imageName.c_str());
     16    this->acquireData(static_cast<ResourceOBJ::OBJResourcePointer*>(ptr)->ptr());
    1717  }
    1818  else
    1919  {
    20     PRINTF(5)("NOT FOUNT TEXTURE: %s\n", imageName.c_str());
     20    PRINTF(5)("NOT FOUND OBJ: %s\n", imageName.c_str());
    2121    std::string fileName = this->NewResource::locateFile(imageName);
    22     this->Texture::loadImage(fileName, target);
    23     this->NewResource::addResource(new ResourceTexture::TextureResourcePointer(imageName + ',' + "TEST", Resources::KeepLevel(0), this->Texture::dataPointer()));
     22    this->acquireData(OBJModel(fileName, scaling).dataPointer());
     23    this->NewResource::addResource(new ResourceOBJ::OBJResourcePointer(imageName + ',' + MultiType(scaling).getString(), Resources::KeepLevel(0), this->StaticModel::dataPointer()));
    2424  }
    2525}
    2626
    27 ResourceTexture ResourceTexture::createFromString(const std::string& loadString)
     27ResourceOBJ ResourceOBJ::createFromString(const std::string& loadString)
    2828{
    2929  SubString loadValues(loadString, ',');
    3030  std::string imageName;
    31   GLenum target = GL_TEXTURE_2D;
     31  float scaling = 1.0f;
    3232  if (loadValues.size() > 0)
    3333    imageName = loadValues[0];
    3434  if (loadValues.size() > 1)
    35     target = (GLenum)MultiType(loadValues[2]).getInt();
     35    scaling = (GLenum)MultiType(loadValues[2]).getFloat();
    3636
    37   return ResourceTexture(imageName, target);
     37  return ResourceOBJ(imageName, scaling);
    3838}
    3939
    4040
    4141
    42 Resources::tType<ResourceTexture> ResourceTexture::type("Texture");
     42Resources::tType<ResourceOBJ> ResourceOBJ::type("OBJ");
    4343
    4444
     
    4646
    4747
    48 ResourceTexture::TextureResourcePointer::TextureResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const TextureData::Pointer& data)
     48ResourceOBJ::OBJResourcePointer::OBJResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const StaticModelData::Pointer& data)
    4949    : Resources::StorePointer(loadString, keepLevel) , pointer(data)
    5050{}
  • branches/new_class_id/src/lib/graphics/importer/resource_obj.h

    r9830 r9831  
    11/*!
    2  * @file resource_texture.h
    3  * @brief Contains the ResourceTexture class, that handles the Resource-specific loading part of the Texture.
     2 * @file resource_obj.h
     3 * @brief Contains the ResourceOBJ class, that handles the Resource-specific loading part of the OBJ.
    44 *
    55 */
    66
    7 #ifndef _RESOURCE_TEXTURE_H
    8 #define _RESOURCE_TEXTURE_H
     7#ifndef _RESOURCE_OBJ_H
     8#define _RESOURCE_OBJ_H
    99
    1010#include "util/loading/resource.h"
    11 #include "texture.h"
     11#include "objModel.h"
    1212
    13 
    14 class ResourceTexture : public Texture, public Resources::NewResource
     13class ResourceOBJ : public StaticModel, public Resources::NewResource
    1514{
    1615public:
    17   ResourceTexture(const std::string& imageName, GLenum target = GL_TEXTURE_2D);
    18   static ResourceTexture createFromString(const std::string& loadString);
     16  ResourceOBJ(const std::string& imageName, float scaling = 1.0f);
     17  static ResourceOBJ createFromString(const std::string& loadString);
    1918
    2019private:
    21 class TextureResourcePointer : public Resources::StorePointer
     20class OBJResourcePointer : public Resources::StorePointer
    2221  {
    2322  public:
    24     TextureResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const TextureData::Pointer& data);
    25     inline const TextureData::Pointer& ptr() const { return pointer; }
     23    OBJResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const StaticModelData::Pointer& data);
     24    inline const StaticModelData::Pointer& ptr() const { return pointer; }
    2625private:
    27     TextureData::Pointer pointer;
     26    StaticModelData::Pointer pointer;
    2827  };
    2928
    3029private:
    31   static Resources::tType<ResourceTexture> type;
     30  static Resources::tType<ResourceOBJ> type;
    3231};
    3332
    3433
    35 #endif /* _RESOURCE_TEXTURE_H */
     34#endif /* _RESOURCE_OBJ_H */
  • branches/new_class_id/src/lib/graphics/importer/resource_texture.cc

    r9823 r9831  
    1313  if (ptr)
    1414  {
    15     PRINTF(5)("FOUNT TEXTURE: %s\n", imageName.c_str());
     15    PRINTF(5)("FOUND TEXTURE: %s\n", imageName.c_str());
    1616    this->acquireData(static_cast<ResourceTexture::TextureResourcePointer*>(ptr)->ptr());
    1717  }
    1818  else
    1919  {
    20     PRINTF(5)("NOT FOUNT TEXTURE: %s\n", imageName.c_str());
     20    PRINTF(5)("NOT FOUND TEXTURE: %s\n", imageName.c_str());
    2121    std::string fileName = this->NewResource::locateFile(imageName);
    2222    this->Texture::loadImage(fileName, target);
  • branches/new_class_id/src/lib/graphics/importer/static_model.h

    r9830 r9831  
    2828  virtual ~StaticModel();
    2929
     30  StaticModel& operator=(const StaticModel& model) { this->data = model.data; return *this; };
     31
    3032  virtual void draw() const { data->draw(); };
    3133  void draw(int groupNumber) const { data->draw(groupNumber); };
     
    5658  void finalize();
    5759
     60  void acquireData(const StaticModelData::Pointer& data) { this->data = data; };
     61  const StaticModelData::Pointer& dataPointer() const { return this->data; };
     62
    5863  inline void setScaleFactor(float scaleFactor) { this->data->setScaleFactor(scaleFactor); };
    5964  float getScaleFactor() const { return data->getScaleFactor(); }
Note: See TracChangeset for help on using the changeset viewer.