source: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.h @ 3237

Revision 3237, 2.9 KB checked in by mattausch, 16 years ago (diff)

debug version

RevLine 
[3057]1#ifndef __RESOURCEMANAGER_H__
2#define __RESOURCEMANAGER_H__
[2747]3
[2795]4
[2747]5#include <string>
[2755]6#include <iostream>
7#include <fstream>
[2757]8#include <map>
[2755]9#include "common.h"
[2747]10
[2840]11
[3019]12
[2795]13class igzstream;
[2747]14
[2795]15
[2776]16namespace CHCDemoEngine
[2755]17{
18
19class SceneEntity;
20class Material;
[2747]21class Geometry;
[2757]22class Texture;
[2795]23class Matrix4x4;
[2840]24class Transform3;
[3036]25class ShaderProgram;
[2747]26
[2840]27
[2795]28/** Loads a scene and also handles the cleanup
29*/
30class ResourceManager
[2747]31{
32public:
33
[3237]34        /** Loads a scene containing of several scene entities. the entities are added to
35                the previously loaded entities. Returns the number of entities in the
36                scene.
[2795]37        */
[3237]38        int Load(const std::string &filename, SceneEntityContainer &geometry);
[3052]39        /** Returns number of scene entities loaded with this manager.
40        */
[2948]41        int GetNumEntities() const { return (int)mSceneEntities.size(); }
[3054]42        /** Returns pointer to shape container.
43        */
44        const ShapeContainer * const GetShapes() const { return &mShapes; }
45        /** Returns pointer to scene entity container.
46        */
47        const SceneEntityContainer * const GetSceneEntities() const { return &mSceneEntities; }
[3052]48        /** Returns the resource manager as a singleton.
49        */
50        inline static ResourceManager *GetSingleton();
51        /** We also want full control over the delete.
52        */
53        static void DelSingleton();
[3215]54        /** Adds a scene entity to the resource mananger, which from now on is handled by the manager.
[3070]55        */
56        void AddSceneEntity(SceneEntity *ent);
[3215]57        /** Creates a new transform.
[3070]58        */
59        Transform3 *CreateTransform(const Matrix4x4 &m);
[3215]60        /** Creates a new default material that is handled by the manager.
61        */
62        Material *CreateMaterial();
[3038]63
[3237]64        /////////////////
65
[3215]66        /// giant hack: set this to true if the geometry to load has tangent data for normal mapping
[3127]67        bool mUseNormalMapping;
[3226]68        bool mUseSpecialColors;
[3127]69
[3216]70
[2747]71protected:
[2755]72       
[3037]73        /** Default constructor. The constructor is protected
74                to have control over instantiation using the
75                singleton pattern.
76        */
[3038]77        ResourceManager();
[3037]78
79        ~ResourceManager();
80
[3237]81        int LoadTextures(igzstream &str);
82        int LoadShapes(igzstream &str);
83        int LoadSceneEntities(igzstream &str, SceneEntityContainer &entities);
[2757]84
[2795]85        SceneEntity *LoadSceneEntity(igzstream &str);
86        Material *LoadMaterial(igzstream &str);
87        Geometry *LoadGeometry(igzstream &str);
[2747]88
[3127]89
[2757]90        std::map<int, Texture *> mTextureTable;
[2764]91        std::map<int, Material *> mMaterialTable;
92        std::map<int, Geometry *> mGeometryTable;
[2842]93        //std::map<int, Shape *> mShapesTable;
[2795]94
[3038]95
96        /////////////
97        //-- these are kept to be able to delete these resources afterwards
98
[3036]99        TextureContainer mTextures;
100        MaterialContainer mMaterials;
101        GeometryContainer mGeometry;
102        TransformContainer mTrafos;
[2842]103        ShapeContainer mShapes;
[3127]104       
[2948]105        /// the scene entities
[2946]106        SceneEntityContainer mSceneEntities;
[3037]107
108private:
109
110        static ResourceManager *sResourceManager;
[2747]111};
112
[3037]113
[3052]114ResourceManager *ResourceManager::GetSingleton()
115{
116        if (!sResourceManager)
117                sResourceManager = new ResourceManager();
118       
119        return sResourceManager;
[2755]120}
[3052]121
122
123}
[2747]124#endif
Note: See TracBrowser for help on using the repository browser.