source: GTP/trunk/App/Demos/Geom/OgreStuff/include/OgreMaterialManager.h @ 1092

Revision 1092, 8.7 KB checked in by gumbau, 18 years ago (diff)

LodStrips? and LODTrees demos

Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2005 The OGRE Team
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23-----------------------------------------------------------------------------
24*/
25#ifndef __MATERIALMANAGER_H__
26#define __MATERIALMANAGER_H__
27
28#include "OgrePrerequisites.h"
29
30#include "OgreSingleton.h"
31#include "OgreResourceManager.h"
32#include "OgreMaterial.h"
33#include "OgreStringVector.h"
34#include "OgreMaterialSerializer.h"
35
36namespace Ogre {
37
38
39    /** Class for managing Material settings for Ogre.
40        @remarks
41            Materials control the eventual surface rendering properties of geometry. This class
42            manages the library of materials, dealing with programmatic registrations and lookups,
43            as well as loading predefined Material settings from scripts.
44        @par
45            When loaded from a script, a Material is in an 'unloaded' state and only stores the settings
46            required. It does not at that stage load any textures. This is because the material settings may be
47            loaded 'en masse' from bulk material script files, but only a subset will actually be required.
48        @par
49            Because this is a subclass of ResourceManager, any files loaded will be searched for in any path or
50            archive added to the resource paths/archives. See ResourceManager for details.
51        @par
52            For a definition of the material script format, see the Tutorials/MaterialScript.html file.
53    */
54    class _OgreExport MaterialManager : public ResourceManager, public Singleton<MaterialManager>
55    {
56    protected:
57
58        /// Default Texture filtering - minification
59        FilterOptions mDefaultMinFilter;
60        /// Default Texture filtering - magnification
61        FilterOptions mDefaultMagFilter;
62        /// Default Texture filtering - mipmapping
63        FilterOptions mDefaultMipFilter;
64        /// Default Texture anisotropy
65        unsigned int mDefaultMaxAniso;
66
67        /// Serializer
68        MaterialSerializer mSerializer;
69                /// Default settings
70                MaterialPtr mDefaultSettings;
71                /// Overridden from ResourceManager
72                Resource* createImpl(const String& name, ResourceHandle handle,
73                        const String& group, bool isManual, ManualResourceLoader* loader,
74            const NameValuePairList* params);
75
76    public:
77        /** Default constructor.
78        */
79        MaterialManager();
80
81        /** Default destructor.
82        */
83        virtual ~MaterialManager();
84
85                /** Intialises the material manager, which also triggers it to
86                 * parse all available .program and .material scripts. */
87                void initialise(void);
88       
89                /** @see ScriptLoader::parseScript
90        */
91        void parseScript(DataStreamPtr& stream, const String& groupName);
92
93
94        /** Sets the default texture filtering to be used for loaded textures, for when textures are
95            loaded automatically (e.g. by Material class) or when 'load' is called with the default
96            parameters by the application.
97            @note
98                The default value is TFO_BILINEAR.
99        */
100        virtual void setDefaultTextureFiltering(TextureFilterOptions fo);
101        /** Sets the default texture filtering to be used for loaded textures, for when textures are
102            loaded automatically (e.g. by Material class) or when 'load' is called with the default
103            parameters by the application.
104        */
105        virtual void setDefaultTextureFiltering(FilterType ftype, FilterOptions opts);
106        /** Sets the default texture filtering to be used for loaded textures, for when textures are
107            loaded automatically (e.g. by Material class) or when 'load' is called with the default
108            parameters by the application.
109        */
110        virtual void setDefaultTextureFiltering(FilterOptions minFilter, FilterOptions magFilter, FilterOptions mipFilter);
111
112                /// get the default texture filtering
113        virtual FilterOptions getDefaultTextureFiltering(FilterType ftype) const;
114
115        /** Sets the default anisotropy level to be used for loaded textures, for when textures are
116            loaded automatically (e.g. by Material class) or when 'load' is called with the default
117            parameters by the application.
118            @note
119                The default value is 1 (no anisotropy).
120        */
121                void setDefaultAnisotropy(unsigned int maxAniso);
122                /// get the default maxAnisotropy
123                unsigned int getDefaultAnisotropy() const;
124
125        /** Returns a pointer to the default Material settings.
126            @remarks
127                Ogre comes configured with a set of defaults for newly created
128                materials. If you wish to have a different set of defaults,
129                simply call this method and change the returned Material's
130                settings. All materials created from then on will be configured
131                with the new defaults you have specified.
132            @par
133                The default settings begin as a single Technique with a single, non-programmable Pass:
134                <ul>
135                <li>ambient = ColourValue::White</li>
136                <li>diffuse = ColourValue::White</li>
137                <li>specular = ColourValue::Black</li>
138                <li>emmissive = ColourValue::Black</li>
139                <li>shininess = 0</li>
140                <li>No texture unit settings (& hence no textures)</li>
141                <li>SourceBlendFactor = SBF_ONE</li>
142                <li>DestBlendFactor = SBF_ZERO (no blend, replace with new
143                  colour)</li>
144                <li>Depth buffer checking on</li>
145                <li>Depth buffer writing on</li>
146                <li>Depth buffer comparison function = CMPF_LESS_EQUAL</li>
147                <li>Colour buffer writing on for all channels</li>
148                <li>Culling mode = CULL_CLOCKWISE</li>
149                <li>Ambient lighting = ColourValue(0.5, 0.5, 0.5) (mid-grey)</li>
150                <li>Dynamic lighting enabled</li>
151                <li>Gourad shading mode</li>
152                <li>Bilinear texture filtering</li>
153                </ul>
154        */
155                virtual MaterialPtr getDefaultSettings(void) const { return mDefaultSettings; }
156
157        /** Override standard Singleton retrieval.
158        @remarks
159        Why do we do this? Well, it's because the Singleton
160        implementation is in a .h file, which means it gets compiled
161        into anybody who includes it. This is needed for the
162        Singleton template to work, but we actually only want it
163        compiled into the implementation of the class based on the
164        Singleton, not all of them. If we don't change this, we get
165        link errors when trying to use the Singleton-based class from
166        an outside dll.
167        @par
168        This method just delegates to the template version anyway,
169        but the implementation stays in this single compilation unit,
170        preventing link errors.
171        */
172        static MaterialManager& getSingleton(void);
173        /** Override standard Singleton retrieval.
174        @remarks
175        Why do we do this? Well, it's because the Singleton
176        implementation is in a .h file, which means it gets compiled
177        into anybody who includes it. This is needed for the
178        Singleton template to work, but we actually only want it
179        compiled into the implementation of the class based on the
180        Singleton, not all of them. If we don't change this, we get
181        link errors when trying to use the Singleton-based class from
182        an outside dll.
183        @par
184        This method just delegates to the template version anyway,
185        but the implementation stays in this single compilation unit,
186        preventing link errors.
187        */
188        static MaterialManager* getSingletonPtr(void);
189
190    };
191
192}
193
194#endif
Note: See TracBrowser for help on using the repository browser.