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#include "T3D/assets/ImageAsset.h" 32 33/// The TerrainMaterial class orginizes the material settings 34/// for a single terrain material layer. 35class TerrainMaterial : public SimObject 36{ 37 typedef SimObject Parent; 38 39protected: 40 41 /// 42 //FileName mDiffuseMap; 43 44 //AssetPtr<ImageAsset> mDiffuseAsset; 45 46 DECLARE_TEXTUREMAP(TerrainMaterial, DiffuseMap); 47 48 /// The size of the diffuse base map in meters 49 /// used to generate its texture coordinates. 50 F32 mDiffuseSize; 51 52 /// 53 DECLARE_TEXTUREMAP(TerrainMaterial, NormalMap); 54 55 /// 56 DECLARE_TEXTUREMAP(TerrainMaterial, DetailMap); 57 58 /// The size of the detail map in meters used 59 /// to generate the texture coordinates for the 60 /// detail and normal maps. 61 F32 mDetailSize; 62 63 /// 64 F32 mDetailStrength; 65 66 /// 67 F32 mDetailDistance; 68 69 /// 70 DECLARE_TEXTUREMAP(TerrainMaterial, ORMConfigMap); 71 72 bool mIsSRGB; 73 bool mInvertRoughness; 74 75 /// Normally the detail is projected on to the xy 76 /// coordinates of the terrain. If this flag is true 77 /// then this detail is projected along the xz and yz 78 /// planes. 79 bool mSideProjection; 80 81 DECLARE_TEXTUREMAP(TerrainMaterial, MacroMap); 82 F32 mMacroSize; 83 F32 mMacroStrength; 84 F32 mMacroDistance; 85 86 /// 87 F32 mParallaxScale; 88 89 /// Depth for blending the textures using the new 90 /// blending method. Higher numbers = larger blend 91 /// radius. 92 F32 mBlendDepth; 93 94 F32 mBlendContrast; 95 96public: 97 98 TerrainMaterial(); 99 virtual ~TerrainMaterial(); 100 101 bool onAdd(); 102 static void initPersistFields(); 103 104 DECLARE_CONOBJECT( TerrainMaterial ); 105 106 /// This method locates the TerrainMaterial if it exists, tries 107 /// to create a new one if a valid texture path was passed, or 108 /// returns a debug material if all else fails. 109 static TerrainMaterial* findOrCreate( const char *nameOrPath ); 110 111 /// Returns the default warning terrain material used when 112 /// a material is not found or defined. 113 static TerrainMaterial* getWarningMaterial(); 114 115 F32 getDiffuseSize() const { return mDiffuseSize; } 116 117 F32 getDetailSize() const { return mDetailSize; } 118 119 F32 getDetailStrength() const { return mDetailStrength; } 120 121 F32 getDetailDistance() const { return mDetailDistance; } 122 123 F32 getMacroSize() const { return mMacroSize; } 124 125 F32 getMacroDistance() const { return mMacroDistance; } 126 127 F32 getMacroStrength() const { return mMacroStrength; } 128 129 bool useSideProjection() const { return mSideProjection; } 130 131 F32 getParallaxScale() const { return mParallaxScale; } 132 133 F32 getBlendDepth() const { return mBlendDepth; } 134 135 F32 getBlendContrast() const { return mBlendContrast; } 136 137 bool getIsSRGB() const { return mIsSRGB; } 138 139 bool getInvertRoughness() const { return mInvertRoughness; } 140 141}; 142 143#endif // _TERRMATERIAL_H_ 144