[148] | 1 | /* |
---|
| 2 | ----------------------------------------------------------------------------- |
---|
| 3 | This source file is part of OGRE |
---|
| 4 | (Object-oriented Graphics Rendering Engine) |
---|
| 5 | For the latest info, see http://www.ogre3d.org/ |
---|
| 6 | |
---|
| 7 | Copyright (c) 2000-2013 Torus Knot Software Ltd |
---|
| 8 | |
---|
| 9 | Permission is hereby granted, free of charge, to any person obtaining a copy |
---|
| 10 | of this software and associated documentation files (the "Software"), to deal |
---|
| 11 | in the Software without restriction, including without limitation the rights |
---|
| 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
---|
| 13 | copies of the Software, and to permit persons to whom the Software is |
---|
| 14 | furnished to do so, subject to the following conditions: |
---|
| 15 | |
---|
| 16 | The above copyright notice and this permission notice shall be included in |
---|
| 17 | all copies or substantial portions of the Software. |
---|
| 18 | |
---|
| 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
---|
| 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
---|
| 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
---|
| 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
---|
| 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
---|
| 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
---|
| 25 | THE SOFTWARE. |
---|
| 26 | ----------------------------------------------------------------------------- |
---|
| 27 | */ |
---|
| 28 | #ifndef _Material_H__ |
---|
| 29 | #define _Material_H__ |
---|
| 30 | |
---|
| 31 | #include "OgrePrerequisites.h" |
---|
| 32 | |
---|
| 33 | #include "OgreResource.h" |
---|
| 34 | #include "OgreIteratorWrappers.h" |
---|
| 35 | #include "OgreCommon.h" |
---|
| 36 | #include "OgreColourValue.h" |
---|
| 37 | #include "OgreBlendMode.h" |
---|
| 38 | #include "OgreHeaderPrefix.h" |
---|
| 39 | |
---|
| 40 | namespace Ogre { |
---|
| 41 | |
---|
| 42 | // Forward declaration |
---|
| 43 | class LodStrategy; |
---|
| 44 | |
---|
| 45 | /** \addtogroup Core |
---|
| 46 | * @{ |
---|
| 47 | */ |
---|
| 48 | /** \addtogroup Materials |
---|
| 49 | * @{ |
---|
| 50 | */ |
---|
| 51 | /** Class encapsulates rendering properties of an object. |
---|
| 52 | @remarks |
---|
| 53 | Ogre's material class encapsulates ALL aspects of the visual appearance, |
---|
| 54 | of an object. It also includes other flags which |
---|
| 55 | might not be traditionally thought of as material properties such as |
---|
| 56 | culling modes and depth buffer settings, but these affect the |
---|
| 57 | appearance of the rendered object and are convenient to attach to the |
---|
| 58 | material since it keeps all the settings in one place. This is |
---|
| 59 | different to Direct3D which treats a material as just the colour |
---|
| 60 | components (diffuse, specular) and not texture maps etc. An Ogre |
---|
| 61 | Material can be thought of as equivalent to a 'Shader'. |
---|
| 62 | @par |
---|
| 63 | A Material can be rendered in multiple different ways depending on the |
---|
| 64 | hardware available. You may configure a Material to use high-complexity |
---|
| 65 | fragment shaders, but these won't work on every card; therefore a Technique |
---|
| 66 | is an approach to creating the visual effect you are looking for. You are advised |
---|
| 67 | to create fallback techniques with lower hardware requirements if you decide to |
---|
| 68 | use advanced features. In addition, you also might want lower-detail techniques |
---|
| 69 | for distant geometry. |
---|
| 70 | @par |
---|
| 71 | Each technique can be made up of multiple passes. A fixed-function pass |
---|
| 72 | may combine multiple texture layers using multitexturing, but Ogre can |
---|
| 73 | break that into multiple passes automatically if the active card cannot |
---|
| 74 | handle that many simultaneous textures. Programmable passes, however, cannot |
---|
| 75 | be split down automatically, so if the active graphics card cannot handle the |
---|
| 76 | technique which contains these passes, OGRE will try to find another technique |
---|
| 77 | which the card can do. If, at the end of the day, the card cannot handle any of the |
---|
| 78 | techniques which are listed for the material, the engine will render the |
---|
| 79 | geometry plain white, which should alert you to the problem. |
---|
| 80 | @par |
---|
| 81 | Ogre comes configured with a number of default settings for a newly |
---|
| 82 | created material. These can be changed if you wish by retrieving the |
---|
| 83 | default material settings through |
---|
| 84 | SceneManager::getDefaultMaterialSettings. Any changes you make to the |
---|
| 85 | Material returned from this method will apply to any materials created |
---|
| 86 | from this point onward. |
---|
| 87 | */ |
---|
| 88 | class _OgreExport Material : public Resource |
---|
| 89 | { |
---|
| 90 | friend class SceneManager; |
---|
| 91 | friend class MaterialManager; |
---|
| 92 | |
---|
| 93 | public: |
---|
| 94 | /// distance list used to specify LOD |
---|
| 95 | typedef vector<Real>::type LodValueList; |
---|
| 96 | typedef ConstVectorIterator<LodValueList> LodValueIterator; |
---|
| 97 | protected: |
---|
| 98 | |
---|
| 99 | |
---|
| 100 | /** Internal method which sets the material up from the default settings. |
---|
| 101 | */ |
---|
| 102 | void applyDefaults(void); |
---|
| 103 | |
---|
| 104 | typedef vector<Technique*>::type Techniques; |
---|
| 105 | /// All techniques, supported and unsupported |
---|
| 106 | Techniques mTechniques; |
---|
| 107 | /// Supported techniques of any sort |
---|
| 108 | Techniques mSupportedTechniques; |
---|
| 109 | typedef map<unsigned short, Technique*>::type LodTechniques; |
---|
| 110 | typedef map<unsigned short, LodTechniques*>::type BestTechniquesBySchemeList; |
---|
| 111 | /** Map of scheme -> list of LOD techniques. |
---|
| 112 | Current scheme is set on MaterialManager, |
---|
| 113 | and can be set per Viewport for auto activation. |
---|
| 114 | */ |
---|
| 115 | BestTechniquesBySchemeList mBestTechniquesBySchemeList; |
---|
| 116 | |
---|
| 117 | LodValueList mUserLodValues; |
---|
| 118 | LodValueList mLodValues; |
---|
| 119 | const LodStrategy *mLodStrategy; |
---|
| 120 | bool mReceiveShadows; |
---|
| 121 | bool mTransparencyCastsShadows; |
---|
| 122 | /// Does this material require compilation? |
---|
| 123 | bool mCompilationRequired; |
---|
| 124 | /// Text description of why any techniques are not supported |
---|
| 125 | String mUnsupportedReasons; |
---|
| 126 | |
---|
| 127 | /** Insert a supported technique into the local collections. */ |
---|
| 128 | void insertSupportedTechnique(Technique* t); |
---|
| 129 | |
---|
| 130 | /** Clear the best technique list. |
---|
| 131 | */ |
---|
| 132 | void clearBestTechniqueList(void); |
---|
| 133 | |
---|
| 134 | /** Overridden from Resource. |
---|
| 135 | */ |
---|
| 136 | void prepareImpl(void); |
---|
| 137 | |
---|
| 138 | /** Overridden from Resource. |
---|
| 139 | */ |
---|
| 140 | void unprepareImpl(void); |
---|
| 141 | |
---|
| 142 | /** Overridden from Resource. |
---|
| 143 | */ |
---|
| 144 | void loadImpl(void); |
---|
| 145 | |
---|
| 146 | /** Unloads the material, frees resources etc. |
---|
| 147 | @see |
---|
| 148 | Resource |
---|
| 149 | */ |
---|
| 150 | void unloadImpl(void); |
---|
| 151 | /// @copydoc Resource::calculateSize |
---|
| 152 | size_t calculateSize(void) const; |
---|
| 153 | public: |
---|
| 154 | |
---|
| 155 | /** Constructor - use resource manager's create method rather than this. |
---|
| 156 | */ |
---|
| 157 | Material(ResourceManager* creator, const String& name, ResourceHandle handle, |
---|
| 158 | const String& group, bool isManual = false, ManualResourceLoader* loader = 0); |
---|
| 159 | |
---|
| 160 | ~Material(); |
---|
| 161 | /** Assignment operator to allow easy copying between materials. |
---|
| 162 | */ |
---|
| 163 | Material& operator=( const Material& rhs ); |
---|
| 164 | |
---|
| 165 | /** Determines if the material has any transparency with the rest of the scene (derived from |
---|
| 166 | whether any Techniques say they involve transparency). |
---|
| 167 | */ |
---|
| 168 | bool isTransparent(void) const; |
---|
| 169 | |
---|
| 170 | /** Sets whether objects using this material will receive shadows. |
---|
| 171 | @remarks |
---|
| 172 | This method allows a material to opt out of receiving shadows, if |
---|
| 173 | it would otherwise do so. Shadows will not be cast on any objects |
---|
| 174 | unless the scene is set up to support shadows |
---|
| 175 | (@see SceneManager::setShadowTechnique), and not all techniques cast |
---|
| 176 | shadows on all objects. In any case, if you have a need to prevent |
---|
| 177 | shadows being received by material, this is the method you call to |
---|
| 178 | do it. |
---|
| 179 | @note |
---|
| 180 | Transparent materials never receive shadows despite this setting. |
---|
| 181 | The default is to receive shadows. |
---|
| 182 | */ |
---|
| 183 | void setReceiveShadows(bool enabled) { mReceiveShadows = enabled; } |
---|
| 184 | /** Returns whether or not objects using this material will receive shadows. */ |
---|
| 185 | bool getReceiveShadows(void) const { return mReceiveShadows; } |
---|
| 186 | |
---|
| 187 | /** Sets whether objects using this material be classified as opaque to the shadow caster system. |
---|
| 188 | @remarks |
---|
| 189 | This method allows a material to cast a shadow, even if it is transparent. |
---|
| 190 | By default, transparent materials neither cast nor receive shadows. Shadows |
---|
| 191 | will not be cast on any objects unless the scene is set up to support shadows |
---|
| 192 | (@see SceneManager::setShadowTechnique), and not all techniques cast |
---|
| 193 | shadows on all objects. |
---|
| 194 | */ |
---|
| 195 | void setTransparencyCastsShadows(bool enabled) { mTransparencyCastsShadows = enabled; } |
---|
| 196 | /** Returns whether or not objects using this material be classified as opaque to the shadow caster system. */ |
---|
| 197 | bool getTransparencyCastsShadows(void) const { return mTransparencyCastsShadows; } |
---|
| 198 | |
---|
| 199 | /** Creates a new Technique for this Material. |
---|
| 200 | @remarks |
---|
| 201 | A Technique is a single way of rendering geometry in order to achieve the effect |
---|
| 202 | you are intending in a material. There are many reason why you would want more than |
---|
| 203 | one - the main one being to handle variable graphics card abilities; you might have |
---|
| 204 | one technique which is impressive but only runs on 4th-generation graphics cards, |
---|
| 205 | for example. In this case you will want to create at least one fallback Technique. |
---|
| 206 | OGRE will work out which Techniques a card can support and pick the best one. |
---|
| 207 | @par |
---|
| 208 | If multiple Techniques are available, the order in which they are created is |
---|
| 209 | important - the engine will consider lower-indexed Techniques to be preferable |
---|
| 210 | to higher-indexed Techniques, ie when asked for the 'best' technique it will |
---|
| 211 | return the first one in the technique list which is supported by the hardware. |
---|
| 212 | */ |
---|
| 213 | Technique* createTechnique(void); |
---|
| 214 | /** Gets the indexed technique. */ |
---|
| 215 | Technique* getTechnique(unsigned short index); |
---|
| 216 | /** searches for the named technique. |
---|
| 217 | Return 0 if technique with name is not found |
---|
| 218 | */ |
---|
| 219 | Technique* getTechnique(const String& name); |
---|
| 220 | /** Retrieves the number of techniques. */ |
---|
| 221 | unsigned short getNumTechniques(void) const; |
---|
| 222 | /** Removes the technique at the given index. */ |
---|
| 223 | void removeTechnique(unsigned short index); |
---|
| 224 | /** Removes all the techniques in this Material. */ |
---|
| 225 | void removeAllTechniques(void); |
---|
| 226 | typedef VectorIterator<Techniques> TechniqueIterator; |
---|
| 227 | /** Get an iterator over the Techniques in this Material. */ |
---|
| 228 | TechniqueIterator getTechniqueIterator(void); |
---|
| 229 | /** Gets an iterator over all the Techniques which are supported by the current card. |
---|
| 230 | @remarks |
---|
| 231 | The supported technique list is only available after this material has been compiled, |
---|
| 232 | which typically happens on loading the material. Therefore, if this method returns |
---|
| 233 | an empty list, try calling Material::load. |
---|
| 234 | */ |
---|
| 235 | TechniqueIterator getSupportedTechniqueIterator(void); |
---|
| 236 | |
---|
| 237 | /** Gets the indexed supported technique. */ |
---|
| 238 | Technique* getSupportedTechnique(unsigned short index); |
---|
| 239 | /** Retrieves the number of supported techniques. */ |
---|
| 240 | unsigned short getNumSupportedTechniques(void) const; |
---|
| 241 | /** Gets a string explaining why any techniques are not supported. */ |
---|
| 242 | const String& getUnsupportedTechniquesExplanation() const { return mUnsupportedReasons; } |
---|
| 243 | |
---|
| 244 | /** Gets the number of levels-of-detail this material has in the |
---|
| 245 | given scheme, based on Technique::setLodIndex. |
---|
| 246 | @remarks |
---|
| 247 | Note that this will not be up to date until the material has been compiled. |
---|
| 248 | */ |
---|
| 249 | unsigned short getNumLodLevels(unsigned short schemeIndex) const; |
---|
| 250 | /** Gets the number of levels-of-detail this material has in the |
---|
| 251 | given scheme, based on Technique::setLodIndex. |
---|
| 252 | @remarks |
---|
| 253 | Note that this will not be up to date until the material has been compiled. |
---|
| 254 | */ |
---|
| 255 | unsigned short getNumLodLevels(const String& schemeName) const; |
---|
| 256 | |
---|
| 257 | /** Gets the best supported technique. |
---|
| 258 | @remarks |
---|
| 259 | This method returns the lowest-index supported Technique in this material |
---|
| 260 | (since lower-indexed Techniques are considered to be better than higher-indexed |
---|
| 261 | ones). |
---|
| 262 | @par |
---|
| 263 | The best supported technique is only available after this material has been compiled, |
---|
| 264 | which typically happens on loading the material. Therefore, if this method returns |
---|
| 265 | NULL, try calling Material::load. |
---|
| 266 | @param lodIndex The material LOD index to use |
---|
| 267 | @param rend Optional parameter specifying the Renderable that is requesting |
---|
| 268 | this technique. Only used if no valid technique for the active material |
---|
| 269 | scheme is found, at which point it is passed to |
---|
| 270 | MaterialManager::Listener::handleSchemeNotFound as information. |
---|
| 271 | */ |
---|
| 272 | Technique* getBestTechnique(unsigned short lodIndex = 0, const Renderable* rend = 0); |
---|
| 273 | |
---|
| 274 | |
---|
| 275 | /** Creates a new copy of this material with the same settings but a new name. |
---|
| 276 | @param newName The name for the cloned material |
---|
| 277 | @param changeGroup If true, the resource group of the clone is changed |
---|
| 278 | @param newGroup Only required if changeGroup is true; the new group to assign |
---|
| 279 | */ |
---|
| 280 | MaterialPtr clone(const String& newName, bool changeGroup = false, |
---|
| 281 | const String& newGroup = StringUtil::BLANK) const; |
---|
| 282 | |
---|
| 283 | /** Copies the details of this material into another, preserving the target's handle and name |
---|
| 284 | (unlike operator=) but copying everything else. |
---|
| 285 | @param mat Weak reference to material which will receive this material's settings. |
---|
| 286 | */ |
---|
| 287 | void copyDetailsTo(MaterialPtr& mat) const; |
---|
| 288 | |
---|
| 289 | /** 'Compiles' this Material. |
---|
| 290 | @remarks |
---|
| 291 | Compiling a material involves determining which Techniques are supported on the |
---|
| 292 | card on which OGRE is currently running, and for fixed-function Passes within those |
---|
| 293 | Techniques, splitting the passes down where they contain more TextureUnitState |
---|
| 294 | instances than the current card has texture units. |
---|
| 295 | @par |
---|
| 296 | This process is automatically done when the Material is loaded, but may be |
---|
| 297 | repeated if you make some procedural changes. |
---|
| 298 | @param |
---|
| 299 | autoManageTextureUnits If true, when a fixed function pass has too many TextureUnitState |
---|
| 300 | entries than the card has texture units, the Pass in question will be split into |
---|
| 301 | more than one Pass in order to emulate the Pass. If you set this to false and |
---|
| 302 | this situation arises, an Exception will be thrown. |
---|
| 303 | */ |
---|
| 304 | void compile(bool autoManageTextureUnits = true); |
---|
| 305 | |
---|
| 306 | // ------------------------------------------------------------------------------- |
---|
| 307 | // The following methods are to make migration from previous versions simpler |
---|
| 308 | // and to make code easier to write when dealing with simple materials |
---|
| 309 | // They set the properties which have been moved to Pass for all Techniques and all Passes |
---|
| 310 | |
---|
| 311 | /** Sets the point size properties for every Pass in every Technique. |
---|
| 312 | @note |
---|
| 313 | This property has been moved to the Pass class, which is accessible via the |
---|
| 314 | Technique. For simplicity, this method allows you to set these properties for |
---|
| 315 | every current Technique, and for every current Pass within those Techniques. If |
---|
| 316 | you need more precision, retrieve the Technique and Pass instances and set the |
---|
| 317 | property there. |
---|
| 318 | @see Pass::setPointSize |
---|
| 319 | */ |
---|
| 320 | void setPointSize(Real ps); |
---|
| 321 | |
---|
| 322 | /** Sets the ambient colour reflectance properties for every Pass in every Technique. |
---|
| 323 | @note |
---|
| 324 | This property has been moved to the Pass class, which is accessible via the |
---|
| 325 | Technique. For simplicity, this method allows you to set these properties for |
---|
| 326 | every current Technique, and for every current Pass within those Techniques. If |
---|
| 327 | you need more precision, retrieve the Technique and Pass instances and set the |
---|
| 328 | property there. |
---|
| 329 | @see Pass::setAmbient |
---|
| 330 | */ |
---|
| 331 | void setAmbient(Real red, Real green, Real blue); |
---|
| 332 | |
---|
| 333 | /** Sets the ambient colour reflectance properties for every Pass in every Technique. |
---|
| 334 | @note |
---|
| 335 | This property has been moved to the Pass class, which is accessible via the |
---|
| 336 | Technique. For simplicity, this method allows you to set these properties for |
---|
| 337 | every current Technique, and for every current Pass within those Techniques. If |
---|
| 338 | you need more precision, retrieve the Technique and Pass instances and set the |
---|
| 339 | property there. |
---|
| 340 | @see Pass::setAmbient |
---|
| 341 | */ |
---|
| 342 | void setAmbient(const ColourValue& ambient); |
---|
| 343 | |
---|
| 344 | /** Sets the diffuse colour reflectance properties of every Pass in every Technique. |
---|
| 345 | @note |
---|
| 346 | This property has been moved to the Pass class, which is accessible via the |
---|
| 347 | Technique. For simplicity, this method allows you to set these properties for |
---|
| 348 | every current Technique, and for every current Pass within those Techniques. If |
---|
| 349 | you need more precision, retrieve the Technique and Pass instances and set the |
---|
| 350 | property there. |
---|
| 351 | @see Pass::setDiffuse |
---|
| 352 | */ |
---|
| 353 | void setDiffuse(Real red, Real green, Real blue, Real alpha); |
---|
| 354 | |
---|
| 355 | /** Sets the diffuse colour reflectance properties of every Pass in every Technique. |
---|
| 356 | @note |
---|
| 357 | This property has been moved to the Pass class, which is accessible via the |
---|
| 358 | Technique. For simplicity, this method allows you to set these properties for |
---|
| 359 | every current Technique, and for every current Pass within those Techniques. If |
---|
| 360 | you need more precision, retrieve the Technique and Pass instances and set the |
---|
| 361 | property there. |
---|
| 362 | @see Pass::setDiffuse |
---|
| 363 | */ |
---|
| 364 | void setDiffuse(const ColourValue& diffuse); |
---|
| 365 | |
---|
| 366 | /** Sets the specular colour reflectance properties of every Pass in every Technique. |
---|
| 367 | @note |
---|
| 368 | This property has been moved to the Pass class, which is accessible via the |
---|
| 369 | Technique. For simplicity, this method allows you to set these properties for |
---|
| 370 | every current Technique, and for every current Pass within those Techniques. If |
---|
| 371 | you need more precision, retrieve the Technique and Pass instances and set the |
---|
| 372 | property there. |
---|
| 373 | @see Pass::setSpecular |
---|
| 374 | */ |
---|
| 375 | void setSpecular(Real red, Real green, Real blue, Real alpha); |
---|
| 376 | |
---|
| 377 | /** Sets the specular colour reflectance properties of every Pass in every Technique. |
---|
| 378 | @note |
---|
| 379 | This property has been moved to the Pass class, which is accessible via the |
---|
| 380 | Technique. For simplicity, this method allows you to set these properties for |
---|
| 381 | every current Technique, and for every current Pass within those Techniques. If |
---|
| 382 | you need more precision, retrieve the Technique and Pass instances and set the |
---|
| 383 | property there. |
---|
| 384 | @see Pass::setSpecular |
---|
| 385 | */ |
---|
| 386 | void setSpecular(const ColourValue& specular); |
---|
| 387 | |
---|
| 388 | /** Sets the shininess properties of every Pass in every Technique. |
---|
| 389 | @note |
---|
| 390 | This property has been moved to the Pass class, which is accessible via the |
---|
| 391 | Technique. For simplicity, this method allows you to set these properties for |
---|
| 392 | every current Technique, and for every current Pass within those Techniques. If |
---|
| 393 | you need more precision, retrieve the Technique and Pass instances and set the |
---|
| 394 | property there. |
---|
| 395 | @see Pass::setShininess |
---|
| 396 | */ |
---|
| 397 | void setShininess(Real val); |
---|
| 398 | |
---|
| 399 | /** Sets the amount of self-illumination of every Pass in every Technique. |
---|
| 400 | @note |
---|
| 401 | This property has been moved to the Pass class, which is accessible via the |
---|
| 402 | Technique. For simplicity, this method allows you to set these properties for |
---|
| 403 | every current Technique, and for every current Pass within those Techniques. If |
---|
| 404 | you need more precision, retrieve the Technique and Pass instances and set the |
---|
| 405 | property there. |
---|
| 406 | @see Pass::setSelfIllumination |
---|
| 407 | */ |
---|
| 408 | void setSelfIllumination(Real red, Real green, Real blue); |
---|
| 409 | |
---|
| 410 | /** Sets the amount of self-illumination of every Pass in every Technique. |
---|
| 411 | @note |
---|
| 412 | This property has been moved to the Pass class, which is accessible via the |
---|
| 413 | Technique. For simplicity, this method allows you to set these properties for |
---|
| 414 | every current Technique, and for every current Pass within those Techniques. If |
---|
| 415 | you need more precision, retrieve the Technique and Pass instances and set the |
---|
| 416 | property there. |
---|
| 417 | @see Pass::setSelfIllumination |
---|
| 418 | */ |
---|
| 419 | void setSelfIllumination(const ColourValue& selfIllum); |
---|
| 420 | |
---|
| 421 | /** Sets whether or not each Pass renders with depth-buffer checking on or not. |
---|
| 422 | @note |
---|
| 423 | This property has been moved to the Pass class, which is accessible via the |
---|
| 424 | Technique. For simplicity, this method allows you to set these properties for |
---|
| 425 | every current Technique, and for every current Pass within those Techniques. If |
---|
| 426 | you need more precision, retrieve the Technique and Pass instances and set the |
---|
| 427 | property there. |
---|
| 428 | @see Pass::setDepthCheckEnabled |
---|
| 429 | */ |
---|
| 430 | void setDepthCheckEnabled(bool enabled); |
---|
| 431 | |
---|
| 432 | /** Sets whether or not each Pass renders with depth-buffer writing on or not. |
---|
| 433 | @note |
---|
| 434 | This property has been moved to the Pass class, which is accessible via the |
---|
| 435 | Technique. For simplicity, this method allows you to set these properties for |
---|
| 436 | every current Technique, and for every current Pass within those Techniques. If |
---|
| 437 | you need more precision, retrieve the Technique and Pass instances and set the |
---|
| 438 | property there. |
---|
| 439 | @see Pass::setDepthWriteEnabled |
---|
| 440 | */ |
---|
| 441 | void setDepthWriteEnabled(bool enabled); |
---|
| 442 | |
---|
| 443 | /** Sets the function used to compare depth values when depth checking is on. |
---|
| 444 | @note |
---|
| 445 | This property has been moved to the Pass class, which is accessible via the |
---|
| 446 | Technique. For simplicity, this method allows you to set these properties for |
---|
| 447 | every current Technique, and for every current Pass within those Techniques. If |
---|
| 448 | you need more precision, retrieve the Technique and Pass instances and set the |
---|
| 449 | property there. |
---|
| 450 | @see Pass::setDepthFunction |
---|
| 451 | */ |
---|
| 452 | void setDepthFunction( CompareFunction func ); |
---|
| 453 | |
---|
| 454 | /** Sets whether or not colour buffer writing is enabled for each Pass. |
---|
| 455 | @note |
---|
| 456 | This property has been moved to the Pass class, which is accessible via the |
---|
| 457 | Technique. For simplicity, this method allows you to set these properties for |
---|
| 458 | every current Technique, and for every current Pass within those Techniques. If |
---|
| 459 | you need more precision, retrieve the Technique and Pass instances and set the |
---|
| 460 | property there. |
---|
| 461 | @see Pass::setColourWriteEnabled |
---|
| 462 | */ |
---|
| 463 | void setColourWriteEnabled(bool enabled); |
---|
| 464 | |
---|
| 465 | /** Sets the culling mode for each pass based on the 'vertex winding'. |
---|
| 466 | @note |
---|
| 467 | This property has been moved to the Pass class, which is accessible via the |
---|
| 468 | Technique. For simplicity, this method allows you to set these properties for |
---|
| 469 | every current Technique, and for every current Pass within those Techniques. If |
---|
| 470 | you need more precision, retrieve the Technique and Pass instances and set the |
---|
| 471 | property there. |
---|
| 472 | @see Pass::setCullingMode |
---|
| 473 | */ |
---|
| 474 | void setCullingMode( CullingMode mode ); |
---|
| 475 | |
---|
| 476 | /** Sets the manual culling mode, performed by CPU rather than hardware. |
---|
| 477 | @note |
---|
| 478 | This property has been moved to the Pass class, which is accessible via the |
---|
| 479 | Technique. For simplicity, this method allows you to set these properties for |
---|
| 480 | every current Technique, and for every current Pass within those Techniques. If |
---|
| 481 | you need more precision, retrieve the Technique and Pass instances and set the |
---|
| 482 | property there. |
---|
| 483 | @see Pass::setManualCullingMode |
---|
| 484 | */ |
---|
| 485 | void setManualCullingMode( ManualCullingMode mode ); |
---|
| 486 | |
---|
| 487 | /** Sets whether or not dynamic lighting is enabled for every Pass. |
---|
| 488 | @note |
---|
| 489 | This property has been moved to the Pass class, which is accessible via the |
---|
| 490 | Technique. For simplicity, this method allows you to set these properties for |
---|
| 491 | every current Technique, and for every current Pass within those Techniques. If |
---|
| 492 | you need more precision, retrieve the Technique and Pass instances and set the |
---|
| 493 | property there. |
---|
| 494 | @see Pass::setLightingEnabled |
---|
| 495 | */ |
---|
| 496 | void setLightingEnabled(bool enabled); |
---|
| 497 | |
---|
| 498 | /** Sets the type of light shading required |
---|
| 499 | @note |
---|
| 500 | This property has been moved to the Pass class, which is accessible via the |
---|
| 501 | Technique. For simplicity, this method allows you to set these properties for |
---|
| 502 | every current Technique, and for every current Pass within those Techniques. If |
---|
| 503 | you need more precision, retrieve the Technique and Pass instances and set the |
---|
| 504 | property there. |
---|
| 505 | @see Pass::setShadingMode |
---|
| 506 | */ |
---|
| 507 | void setShadingMode( ShadeOptions mode ); |
---|
| 508 | |
---|
| 509 | /** Sets the fogging mode applied to each pass. |
---|
| 510 | @note |
---|
| 511 | This property has been moved to the Pass class, which is accessible via the |
---|
| 512 | Technique. For simplicity, this method allows you to set these properties for |
---|
| 513 | every current Technique, and for every current Pass within those Techniques. If |
---|
| 514 | you need more precision, retrieve the Technique and Pass instances and set the |
---|
| 515 | property there. |
---|
| 516 | @see Pass::setFog |
---|
| 517 | */ |
---|
| 518 | void setFog( |
---|
| 519 | bool overrideScene, |
---|
| 520 | FogMode mode = FOG_NONE, |
---|
| 521 | const ColourValue& colour = ColourValue::White, |
---|
| 522 | Real expDensity = 0.001, Real linearStart = 0.0, Real linearEnd = 1.0 ); |
---|
| 523 | |
---|
| 524 | /** Sets the depth bias to be used for each Pass. |
---|
| 525 | @note |
---|
| 526 | This property has been moved to the Pass class, which is accessible via the |
---|
| 527 | Technique. For simplicity, this method allows you to set these properties for |
---|
| 528 | every current Technique, and for every current Pass within those Techniques. If |
---|
| 529 | you need more precision, retrieve the Technique and Pass instances and set the |
---|
| 530 | property there. |
---|
| 531 | @see Pass::setDepthBias |
---|
| 532 | */ |
---|
| 533 | void setDepthBias(float constantBias, float slopeScaleBias); |
---|
| 534 | |
---|
| 535 | /** Set texture filtering for every texture unit in every Technique and Pass |
---|
| 536 | @note |
---|
| 537 | This property has been moved to the TextureUnitState class, which is accessible via the |
---|
| 538 | Technique and Pass. For simplicity, this method allows you to set these properties for |
---|
| 539 | every current TeextureUnitState, If you need more precision, retrieve the Technique, |
---|
| 540 | Pass and TextureUnitState instances and set the property there. |
---|
| 541 | @see TextureUnitState::setTextureFiltering |
---|
| 542 | */ |
---|
| 543 | void setTextureFiltering(TextureFilterOptions filterType); |
---|
| 544 | /** Sets the anisotropy level to be used for all textures. |
---|
| 545 | @note |
---|
| 546 | This property has been moved to the TextureUnitState class, which is accessible via the |
---|
| 547 | Technique and Pass. For simplicity, this method allows you to set these properties for |
---|
| 548 | every current TeextureUnitState, If you need more precision, retrieve the Technique, |
---|
| 549 | Pass and TextureUnitState instances and set the property there. |
---|
| 550 | @see TextureUnitState::setTextureAnisotropy |
---|
| 551 | */ |
---|
| 552 | void setTextureAnisotropy(int maxAniso); |
---|
| 553 | |
---|
| 554 | /** Sets the kind of blending every pass has with the existing contents of the scene. |
---|
| 555 | @note |
---|
| 556 | This property has been moved to the Pass class, which is accessible via the |
---|
| 557 | Technique. For simplicity, this method allows you to set these properties for |
---|
| 558 | every current Technique, and for every current Pass within those Techniques. If |
---|
| 559 | you need more precision, retrieve the Technique and Pass instances and set the |
---|
| 560 | property there. |
---|
| 561 | @see Pass::setSceneBlending |
---|
| 562 | */ |
---|
| 563 | void setSceneBlending( const SceneBlendType sbt ); |
---|
| 564 | |
---|
| 565 | /** Sets the kind of blending every pass has with the existing contents of the scene, using individual factors for color and alpha channels |
---|
| 566 | @note |
---|
| 567 | This property has been moved to the Pass class, which is accessible via the |
---|
| 568 | Technique. For simplicity, this method allows you to set these properties for |
---|
| 569 | every current Technique, and for every current Pass within those Techniques. If |
---|
| 570 | you need more precision, retrieve the Technique and Pass instances and set the |
---|
| 571 | property there. |
---|
| 572 | @see Pass::setSeparateSceneBlending |
---|
| 573 | */ |
---|
| 574 | void setSeparateSceneBlending( const SceneBlendType sbt, const SceneBlendType sbta ); |
---|
| 575 | |
---|
| 576 | /** Allows very fine control of blending every Pass with the existing contents of the scene. |
---|
| 577 | @note |
---|
| 578 | This property has been moved to the Pass class, which is accessible via the |
---|
| 579 | Technique. For simplicity, this method allows you to set these properties for |
---|
| 580 | every current Technique, and for every current Pass within those Techniques. If |
---|
| 581 | you need more precision, retrieve the Technique and Pass instances and set the |
---|
| 582 | property there. |
---|
| 583 | @see Pass::setSceneBlending |
---|
| 584 | */ |
---|
| 585 | void setSceneBlending( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor); |
---|
| 586 | |
---|
| 587 | /** Allows very fine control of blending every Pass with the existing contents of the scene, using individual factors for color and alpha channels |
---|
| 588 | @note |
---|
| 589 | This property has been moved to the Pass class, which is accessible via the |
---|
| 590 | Technique. For simplicity, this method allows you to set these properties for |
---|
| 591 | every current Technique, and for every current Pass within those Techniques. If |
---|
| 592 | you need more precision, retrieve the Technique and Pass instances and set the |
---|
| 593 | property there. |
---|
| 594 | @see Pass::setSeparateSceneBlending |
---|
| 595 | */ |
---|
| 596 | void setSeparateSceneBlending( const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor, const SceneBlendFactor sourceFactorAlpha, const SceneBlendFactor destFactorAlpha); |
---|
| 597 | |
---|
| 598 | /** Tells the material that it needs recompilation. */ |
---|
| 599 | void _notifyNeedsRecompile(void); |
---|
| 600 | |
---|
| 601 | /** Sets the distance at which level-of-detail (LOD) levels come into effect. |
---|
| 602 | @remarks |
---|
| 603 | You should only use this if you have assigned LOD indexes to the Technique |
---|
| 604 | instances attached to this Material. If you have done so, you should call this |
---|
| 605 | method to determine the distance at which the lowe levels of detail kick in. |
---|
| 606 | The decision about what distance is actually used is a combination of this |
---|
| 607 | and the LOD bias applied to both the current Camera and the current Entity. |
---|
| 608 | @param lodValues A vector of Reals which indicate the LOD value at which to |
---|
| 609 | switch to lower details. They are listed in LOD index order, starting at index |
---|
| 610 | 1 (ie the first level down from the highest level 0, which automatically applies |
---|
| 611 | from a value of 0). These are 'user values', before being potentially |
---|
| 612 | transformed by the strategy, so for the distance strategy this is an |
---|
| 613 | unsquared distance for example. |
---|
| 614 | */ |
---|
| 615 | void setLodLevels(const LodValueList& lodValues); |
---|
| 616 | |
---|
| 617 | /** Gets an iterator over the list of values transformed by the LodStrategy at which each LOD comes into effect. |
---|
| 618 | @remarks |
---|
| 619 | Note that the iterator returned from this method is not totally analogous to |
---|
| 620 | the one passed in by calling setLodLevels - the list includes a zero |
---|
| 621 | entry at the start (since the highest LOD starts at value 0). Also, the |
---|
| 622 | values returned are after being transformed by LodStrategy::transformUserValue. |
---|
| 623 | */ |
---|
| 624 | LodValueIterator getLodValueIterator(void) const; |
---|
| 625 | |
---|
| 626 | /** Gets an iterator over the user-defined list of values which are internally transfomed by the LodStrategy. |
---|
| 627 | @remarks |
---|
| 628 | Note that the iterator returned from this method is not totally analogous to |
---|
| 629 | the one passed in by calling setLodLevels - the list includes a zero |
---|
| 630 | entry at the start (since the highest LOD starts at value 0). Also, the |
---|
| 631 | values returned are after being transformed by LodStrategy::transformUserValue. |
---|
| 632 | */ |
---|
| 633 | LodValueIterator getUserLodValueIterator(void) const; |
---|
| 634 | |
---|
| 635 | /** Gets the LOD index to use at the given value. |
---|
| 636 | @note The value passed in is the 'transformed' value. If you are dealing with |
---|
| 637 | an original source value (e.g. distance), use LodStrategy::transformUserValue |
---|
| 638 | to turn this into a lookup value. |
---|
| 639 | */ |
---|
| 640 | ushort getLodIndex(Real value) const; |
---|
| 641 | |
---|
| 642 | /** Get LOD strategy used by this material. */ |
---|
| 643 | const LodStrategy *getLodStrategy() const; |
---|
| 644 | /** Set the LOD strategy used by this material. */ |
---|
| 645 | void setLodStrategy(LodStrategy *lodStrategy); |
---|
| 646 | |
---|
| 647 | /** @copydoc Resource::touch |
---|
| 648 | */ |
---|
| 649 | void touch(void) |
---|
| 650 | { |
---|
| 651 | if (mCompilationRequired) |
---|
| 652 | compile(); |
---|
| 653 | // call superclass |
---|
| 654 | Resource::touch(); |
---|
| 655 | } |
---|
| 656 | |
---|
| 657 | /** Applies texture names to Texture Unit State with matching texture name aliases. |
---|
| 658 | All techniques, passes, and Texture Unit States within the material are checked. |
---|
| 659 | If matching texture aliases are found then true is returned. |
---|
| 660 | |
---|
| 661 | @param |
---|
| 662 | aliasList is a map container of texture alias, texture name pairs |
---|
| 663 | @param |
---|
| 664 | apply set true to apply the texture aliases else just test to see if texture alias matches are found. |
---|
| 665 | @return |
---|
| 666 | True if matching texture aliases were found in the material. |
---|
| 667 | */ |
---|
| 668 | bool applyTextureAliases(const AliasTextureNamePairList& aliasList, const bool apply = true) const; |
---|
| 669 | |
---|
| 670 | /** Gets the compilation status of the material. |
---|
| 671 | @return True if the material needs recompilation. |
---|
| 672 | */ |
---|
| 673 | bool getCompilationRequired() const |
---|
| 674 | { |
---|
| 675 | return mCompilationRequired; |
---|
| 676 | } |
---|
| 677 | |
---|
| 678 | |
---|
| 679 | }; |
---|
| 680 | /** @} */ |
---|
| 681 | /** @} */ |
---|
| 682 | |
---|
| 683 | } //namespace |
---|
| 684 | |
---|
| 685 | #include "OgreHeaderSuffix.h" |
---|
| 686 | |
---|
| 687 | #endif |
---|