terrMaterial.h
Engine/source/terrain/terrMaterial.h
Classes:
class
The TerrainMaterial class orginizes the material settings for a single terrain material layer.
Detailed Description
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23 24#ifndef _TERRMATERIAL_H_ 25#define _TERRMATERIAL_H_ 26 27#ifndef _SIMBASE_H_ 28#include "console/simBase.h" 29#endif 30 31 32/// The TerrainMaterial class orginizes the material settings 33/// for a single terrain material layer. 34class TerrainMaterial : public SimObject 35{ 36 typedef SimObject Parent; 37 38protected: 39 40 /// 41 FileName mDiffuseMap; 42 43 /// The size of the diffuse base map in meters 44 /// used to generate its texture coordinates. 45 F32 mDiffuseSize; 46 47 /// 48 FileName mNormalMap; 49 50 /// 51 FileName mDetailMap; 52 53 /// The size of the detail map in meters used 54 /// to generate the texture coordinates for the 55 /// detail and normal maps. 56 F32 mDetailSize; 57 58 /// 59 F32 mDetailStrength; 60 61 /// 62 F32 mDetailDistance; 63 64 /// Normally the detail is projected on to the xy 65 /// coordinates of the terrain. If this flag is true 66 /// then this detail is projected along the xz and yz 67 /// planes. 68 bool mSideProjection; 69 70 FileName mMacroMap; 71 F32 mMacroSize; 72 F32 mMacroStrength; 73 F32 mMacroDistance; 74 75 /// 76 F32 mParallaxScale; 77 78public: 79 80 TerrainMaterial(); 81 virtual ~TerrainMaterial(); 82 83 bool onAdd(); 84 static void initPersistFields(); 85 86 DECLARE_CONOBJECT( TerrainMaterial ); 87 88 /// This method locates the TerrainMaterial if it exists, tries 89 /// to create a new one if a valid texture path was passed, or 90 /// returns a debug material if all else fails. 91 static TerrainMaterial* findOrCreate( const char *nameOrPath ); 92 93 /// Returns the default warning terrain material used when 94 /// a material is not found or defined. 95 static TerrainMaterial* getWarningMaterial(); 96 97 const String& getDiffuseMap() const { return mDiffuseMap; } 98 99 F32 getDiffuseSize() const { return mDiffuseSize; } 100 101 const String& getNormalMap() const { return mNormalMap; } 102 103 const String& getDetailMap() const { return mDetailMap; } 104 105 const String& getMacroMap() const { return mMacroMap; } 106 107 F32 getDetailSize() const { return mDetailSize; } 108 109 F32 getDetailStrength() const { return mDetailStrength; } 110 111 F32 getDetailDistance() const { return mDetailDistance; } 112 113 F32 getMacroSize() const { return mMacroSize; } 114 115 F32 getMacroDistance() const { return mMacroDistance; } 116 117 F32 getMacroStrength() const { return mMacroStrength; } 118 119 bool useSideProjection() const { return mSideProjection; } 120 121 F32 getParallaxScale() const { return mParallaxScale; } 122 123}; 124 125#endif // _TERRMATERIAL_H_ 126
