Changeset 9831 in orxonox.OLD for branches/new_class_id/src/lib/graphics
- Timestamp:
- Sep 26, 2006, 3:18:28 PM (18 years ago)
- 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 13 13 static_model_data.cc \ 14 14 objModel.cc \ 15 resource_obj.cc \ 15 16 primitive_model.cc \ 16 17 height_map.cc \ … … 60 61 static_model_data.h \ 61 62 objModel.h \ 63 resource_obj.h \ 62 64 primitive_model.h \ 63 65 anorms.h \ -
branches/new_class_id/src/lib/graphics/importer/objModel.cc
r9830 r9831 18 18 #include "objModel.h" 19 19 20 #include <stdio.h>21 20 #include <string.h> 22 #include <stdlib.h>23 21 24 22 #define PARSELINELENGTH 8192 -
branches/new_class_id/src/lib/graphics/importer/objModel.h
r9715 r9831 13 13 { 14 14 ObjectListDeclaration(OBJModel); 15 16 15 public: 16 OBJModel(const std::string& fileName, float scaling = 1.0); 17 17 virtual ~OBJModel(); 18 18 19 19 private: 20 20 ///// readin ///// 21 22 23 21 bool importFile (const std::string& fileName); 22 bool readFromObjFile (const std::string& fileName); 23 bool readMtlLib (const std::string& matFile); 24 24 25 26 27 28 29 30 31 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); 32 32 33 34 33 private: 34 std::string objPath; //!< The Path where the obj and mtl-file are located. 35 35 }; 36 36 -
branches/new_class_id/src/lib/graphics/importer/resource_obj.cc
r9830 r9831 1 1 2 #include "resource_ texture.h"2 #include "resource_obj.h" 3 3 #include "substring.h" 4 4 #include "multi_type.h" … … 6 6 7 7 8 Resource Texture::ResourceTexture(const std::string& imageName, GLenum target)9 : NewResource(&Resource Texture::type)8 ResourceOBJ::ResourceOBJ(const std::string& imageName, float scaling) 9 : NewResource(&ResourceOBJ::type) 10 10 { 11 Resources::StorePointer* ptr = this->acquireResource(imageName + ',' + "TEST");11 Resources::StorePointer* ptr = this->acquireResource(imageName + ',' + MultiType(scaling).getString()); 12 12 13 13 if (ptr) 14 14 { 15 PRINTF(5)("FOUN T TEXTURE: %s\n", imageName.c_str());16 this->acquireData(static_cast<Resource Texture::TextureResourcePointer*>(ptr)->ptr());15 PRINTF(5)("FOUND OBJ: %s\n", imageName.c_str()); 16 this->acquireData(static_cast<ResourceOBJ::OBJResourcePointer*>(ptr)->ptr()); 17 17 } 18 18 else 19 19 { 20 PRINTF(5)("NOT FOUN T TEXTURE: %s\n", imageName.c_str());20 PRINTF(5)("NOT FOUND OBJ: %s\n", imageName.c_str()); 21 21 std::string fileName = this->NewResource::locateFile(imageName); 22 this-> Texture::loadImage(fileName, target);23 this->NewResource::addResource(new Resource Texture::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())); 24 24 } 25 25 } 26 26 27 Resource Texture ResourceTexture::createFromString(const std::string& loadString)27 ResourceOBJ ResourceOBJ::createFromString(const std::string& loadString) 28 28 { 29 29 SubString loadValues(loadString, ','); 30 30 std::string imageName; 31 GLenum target = GL_TEXTURE_2D;31 float scaling = 1.0f; 32 32 if (loadValues.size() > 0) 33 33 imageName = loadValues[0]; 34 34 if (loadValues.size() > 1) 35 target = (GLenum)MultiType(loadValues[2]).getInt();35 scaling = (GLenum)MultiType(loadValues[2]).getFloat(); 36 36 37 return Resource Texture(imageName, target);37 return ResourceOBJ(imageName, scaling); 38 38 } 39 39 40 40 41 41 42 Resources::tType<Resource Texture> ResourceTexture::type("Texture");42 Resources::tType<ResourceOBJ> ResourceOBJ::type("OBJ"); 43 43 44 44 … … 46 46 47 47 48 Resource Texture::TextureResourcePointer::TextureResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const TextureData::Pointer& data)48 ResourceOBJ::OBJResourcePointer::OBJResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const StaticModelData::Pointer& data) 49 49 : Resources::StorePointer(loadString, keepLevel) , pointer(data) 50 50 {} -
branches/new_class_id/src/lib/graphics/importer/resource_obj.h
r9830 r9831 1 1 /*! 2 * @file resource_ texture.h3 * @brief Contains the Resource Texture 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. 4 4 * 5 5 */ 6 6 7 #ifndef _RESOURCE_ TEXTURE_H8 #define _RESOURCE_ TEXTURE_H7 #ifndef _RESOURCE_OBJ_H 8 #define _RESOURCE_OBJ_H 9 9 10 10 #include "util/loading/resource.h" 11 #include " texture.h"11 #include "objModel.h" 12 12 13 14 class ResourceTexture : public Texture, public Resources::NewResource 13 class ResourceOBJ : public StaticModel, public Resources::NewResource 15 14 { 16 15 public: 17 Resource Texture(const std::string& imageName, GLenum target = GL_TEXTURE_2D);18 static Resource TexturecreateFromString(const std::string& loadString);16 ResourceOBJ(const std::string& imageName, float scaling = 1.0f); 17 static ResourceOBJ createFromString(const std::string& loadString); 19 18 20 19 private: 21 class TextureResourcePointer : public Resources::StorePointer20 class OBJResourcePointer : public Resources::StorePointer 22 21 { 23 22 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; } 26 25 private: 27 TextureData::Pointer pointer;26 StaticModelData::Pointer pointer; 28 27 }; 29 28 30 29 private: 31 static Resources::tType<Resource Texture> type;30 static Resources::tType<ResourceOBJ> type; 32 31 }; 33 32 34 33 35 #endif /* _RESOURCE_ TEXTURE_H */34 #endif /* _RESOURCE_OBJ_H */ -
branches/new_class_id/src/lib/graphics/importer/resource_texture.cc
r9823 r9831 13 13 if (ptr) 14 14 { 15 PRINTF(5)("FOUN TTEXTURE: %s\n", imageName.c_str());15 PRINTF(5)("FOUND TEXTURE: %s\n", imageName.c_str()); 16 16 this->acquireData(static_cast<ResourceTexture::TextureResourcePointer*>(ptr)->ptr()); 17 17 } 18 18 else 19 19 { 20 PRINTF(5)("NOT FOUN TTEXTURE: %s\n", imageName.c_str());20 PRINTF(5)("NOT FOUND TEXTURE: %s\n", imageName.c_str()); 21 21 std::string fileName = this->NewResource::locateFile(imageName); 22 22 this->Texture::loadImage(fileName, target); -
branches/new_class_id/src/lib/graphics/importer/static_model.h
r9830 r9831 28 28 virtual ~StaticModel(); 29 29 30 StaticModel& operator=(const StaticModel& model) { this->data = model.data; return *this; }; 31 30 32 virtual void draw() const { data->draw(); }; 31 33 void draw(int groupNumber) const { data->draw(groupNumber); }; … … 56 58 void finalize(); 57 59 60 void acquireData(const StaticModelData::Pointer& data) { this->data = data; }; 61 const StaticModelData::Pointer& dataPointer() const { return this->data; }; 62 58 63 inline void setScaleFactor(float scaleFactor) { this->data->setScaleFactor(scaleFactor); }; 59 64 float getScaleFactor() const { return data->getScaleFactor(); }
Note: See TracChangeset
for help on using the changeset viewer.