MaterialLibrary.h
1 /************************************************************
2 * (C) Voxel Farm Inc. 2015
3 */
4 
5 #pragma once
6 
7 // 260 was taken from windef.h
8 #ifndef MAX_PATH
9  #define MAX_PATH 260
10 #endif
11 
12 #include "VoxelFarmConfig.h"
13 
14 namespace VoxelFarm
15 {
18 
21  {
23  int id;
25  double density;
27  double minAngle;
29  double maxAngle;
31  double minSize;
33  double maxSize;
35  double noiseFreq;
37  double noiseShift;
38  };
39 
41  {
42  public:
43  virtual void getColor(double x, double y, double z, unsigned char& r, unsigned char& g, unsigned char& b) = 0;
44  };
45 
47  struct CMaterial
48  {
50  int id;
52  int medium;
54  char diffuse[MAX_PATH];
58  char normal[MAX_PATH];
68  int maxlevel;
72  int carved;
74  double angleMin;
76  double angleMax;
82  double nearFreq;
84  double farFreq;
86  double macroFreq;
88  unsigned int applyColor;
90  double snowLine;
92  double maxEdgeLength;
93 
94  bool homogeneous;
95  bool blend;
96 
97  int wearMaterial;
98  int layeredMaterial;
99  double layeredMaterialAngle;
100  bool transparent;
101 
116 
117  bool useMacroColor;
118  IMacroColorSource* macroColor;
119 
121  char displacement[MAX_PATH];
123  char displacementNormal[MAX_PATH];
131  unsigned char* displacementMap;
132 
159 
162 
164  double heightMin;
166  double heightMax;
167 
169  double colorH;
171  double colorS;
173  double colorV;
175  double colorFreqX;
177  double colorFreqY;
179  double colorFreqZ;
181  double colorDeltaH;
183  double colorDeltaS;
185  double colorDeltaV;
186 
187  TVector<int>* subMaterials;
188 
190  static const int MAX_INSTANCES = 20;
195 
196  // sound
197  char stepSoundId[MAX_PATH];
198  int stepSoundCount;
199  char digSoundId[MAX_PATH];
200  int digSoundCount;
201 
202  /************************************
203  * Permitted Material Types: *
204  * (see PhysicsMaterials.h) *
205  * *
206  * MATERIAL_CORK = 0 *
207  * MATERIAL_WOOD = 1 *
208  * MATERIAL_ICE = 2 *
209  * MATERIAL_WATER = 3 *
210  * MATERIAL_PLASTIC = 4 *
211  * MATERIAL_CONCRETE = 5 *
212  * MATERIAL_ROCK = 6 *
213  * MATERIAL_METAL = 7 *
214  * MATERIAL_HELIUM = 8 *
215  * MATERIAL_DEFAULT = 9 *
216  ************************************/
217  int materialType;
218  };
219 
222  {
223  float LOD0 [6][4][2];
224  float LOD1 [3][4][2];
225  float LOD1B[8][4][2]; // for type2 billboards
226  float LOD2 [2][4][2];
227  float rowHeight;
228  };
229 
232  {
233  public:
235  virtual ~CMaterialLibrary();
236 
237  void init(int mapSize, int materialCount);
238  CMaterial& getMaterial( int index ) { return materialIndex[index]; }
239  virtual int getMaterialMapping(int material) const { return material; }
240 
241  public:
243  int mapSize;
250  };
251 }
int displacementMapIndex
Index in the texture array for displacement map intensity.
int instanceMaskMode
Used to mask the material by using the instance map.
double snowLine
Altitude at which the material begins to show snow.
CBillboardLODPacking billboardPack
Billboard atlas packing data.
int placementType
Type of placement mask. Only one type is currently supported, zero, which is a Perlin noise...
unsigned int applyColor
Tints the material using the blue channel as a mask and the red channel as an intensity.
InstanceDescriptor instances[MAX_INSTANCES]
Material instance definition.
Contains all classes and functions for the VoxelFarm engine.
double placementStep
Amplitude multiplier of the placement noise.
Contains all materials available in the system.
int billboardType
Billboard type. Zero is standing up, like grass. One is around the object, like foliage.
int carved
Which material will be set when this material is carved.
double billboardSize
Scale of the billboard. Default is one.
char displacement[MAX_PATH]
Path to a displacement map.
double farFreq
Texture tiling frequency for the mid range of the material.
double placementPhaseY
Phase along Y axis of placement noise.
double placementClampMax
Placement noise clamp maximum.
double billboardDensity
Controls billboard density. Smaller values will produce higher density;.
double billboardAngleMax
Maximum slope angle for the billboards to be applied.
int medium
Indentifies to which medium the material belongs to.
int instanceCount
Number of material instance types.
double billboardAngleMin
Minimum slope angle for the billboards to be applied.
double colorS
Used for material HSV colorization, determines the S (saturation) component for the base color...
double colorDeltaH
Used for material HSV colorization, determines the range of variation for the H (hue) component...
Describes a material instance.
int maxlevel
Maximum level at which the material will be displayed.
double colorV
Used for material HSV colorization, determines the V (value) component for the base color...
double colorFreqX
Used for material HSV colorization, determines the frequency at which components change over the X ax...
int normalMapIndex
Index in the texture array for diffuse map.
double placementClampMin
Placement noise clamp minimum.
char normal[MAX_PATH]
Path to a BMP image for the normal map.
double angleMin
Minimum slope angle for the material to be applied.
double displacementSize
Size of the displacement effect.
double simplificationError
Maximum simplification error allowed for the material.
int materialCount
Number of materials.
double angleMax
Maximum slope angle for the material to be applied.
unsigned char * displacementMap
Contains the values read from the displacement map.
double colorFreqY
Used for material HSV colorization, determines the frequency at which components change over the Y ax...
int id
Identifies the material family.
double placementPhaseX
Phase along X axis of placement noise.
double heightMax
Maximum world height at which the material could appear.
int diffuseMapIndex
Index in the texture array for diffuse map.
double minAngle
Minimum angle at which the instance appears.
double colorH
Used for material HSV colorization, determines the H (hue) component for the base color...
double colorFreqZ
Used for material HSV colorization, determines the frequency at which components change over the Z ax...
int billboard
Identifier for the billboard texture to be placed on top of the material.
double placementPhaseZ
Phase along Z axis of placement noise.
char displacementNormal[MAX_PATH]
Path to a normal map for the material displacement.
int displacementNormalMapIndex
Index in the texture array for displacement map normal.
double placementScaleZ
Scale along Z axis of placement noise.
double selfIllumination
A value from zero to one specifying how much lightign conditions affect the appearance of the materia...
double placementScaleX
Scale along X axis of placement noise.
double displacementShift
Additional value for the displacement map.
double noiseFreq
Frequency for the instance distribution noise.
double colorDeltaS
Used for material HSV colorization, determines the range of variation for the S (saturation) componen...
static const int MAX_INSTANCES
Maximum amount of different material instance types.
double macroFreq
Texture tiling frequency for the far range of the material.
double maxEdgeLength
Maximum edge length.
double displacementFreq
Frequency of the displacement tiling.
double billboardRigidity
Controls how much the billboard is affected by wind.
double minSize
Minimum size for the instance.
int placementOctaves
Number of octaves in placement noise.
double noiseShift
Amplitude shift for the instance distribution noise.
double nearFreq
Texture tiling frequency for the near range of the material.
const int ERROR_MATERIAL_FILE_NOT_FOUND
A file needed for a material was not found.
CMaterial * materialIndex
An index to all materials.
char diffuse[MAX_PATH]
Path to a BMP image for the diffuse map.
int id
ID for the mesh to be used.
Texture coordinate packing for billboard atlases.
double heightMin
Minimum world height at which the material could appear.
A material definition for the VoxelFarm.com engine.
double placementScaleY
Scale along Y axis of placement noise.
double maxAngle
Maximum angle at which the instance appears.
double placementLacunarity
Frequency multiplier of the placement noise.
int mapSize
Defines the map size shared by all the bitmaps in the library. Must be a power of 2...
int resolution
Controls how many polygons the material takes on screen. Zero has the highest polygon density possibl...
double density
Controls how dense the instance distribution over the material is.
double faceSmoothAngle
Neighboring faces will have their normals smoothen if they are below this separation angle...
double placementFreq
Frequency of the placement noise.
double maxSize
Maximum size for the instance.
double colorDeltaV
Used for material HSV colorization, determines the range of variation for the V (value) component...