7 #include "FastQuadrics.h"
10 #include "VoxelLayer.h"
11 #include "MaterialLibrary.h"
12 #include "ExternalMutex.h"
13 #include "CellSeams.h"
69 unsigned int timeStamp;
70 BillboardCacheList* list;
97 TMap<CellId, BillboardCellCache*>
cache;
269 bool seamCreated[3][2];
270 bool seamBaked[3][2];
271 bool seamDisplay[3][2];
286 unsigned int* computedSeamMaterials[
MEDIUM_MAX][2][3];
287 unsigned int* computedSeamLightColor[
MEDIUM_MAX][2][3];
288 unsigned char* computedSeamMaterialChannels[
MEDIUM_MAX][2][3][3];
296 bool* billboardsCached;
298 CellId* billboardCacheCells;
301 bool** billboardOccupancy0;
302 bool** billboardOccupancy1;
314 int medium = materialDefinition.
medium;
321 static int cellCount;
CVert * faceNormals[MEDIUM_MAX]
List of face normals.
int instanceFaceCount
Number of faces for material instances in the cell.
Algebra::Vector billboardPos
Billboard's position within the cell (ranges from 0 to 1)
CVert reference
Origin point within the mesh. This point will be used to anchor the mesh.
static const int MEDIUM_FOLIAGE
This medium is used for foliage.
CFastQuadrics seamMesh[MEDIUM_MAX][2][3]
A mesh containing the polygons in the Cell seam before simplification.
int vertexCount[MEDIUM_MAX]
Number of vertices in cell.
int faceCount
Number of faces in the mesh.
static const int MEDIUM_PREVIEW
This medium is use for a placement preview.
int faceCount[MEDIUM_MAX]
Number of triangles in cell.
int timeStamp
Current time vector for the cache system.
Stores all LOD meshes for one instance.
UV * billboardSizes
List of billboard dimensions.
const int BILLBOARD_MAX
Maximum billboard and material instances in one cell.
Contains all classes and functions for the VoxelFarm engine.
void setBillboards(CellId cell, BillboardCellCache *list)
Sets the list of billboards for the specified cell.
const int BILLBOARD_OCCUPANCY_GRID_1
Billboard cache density for type 1 billboards (foliage)
CVert * billboardVertices
List of billboard vertices.
Contains all materials available in the system.
const int BILLBOARD_MAX_LEVEL_TYPE0
Maximum LOD to include type 0 billboards (grass)
static const int MEDIUM_WATER
This medium is use for glass and transparent solids.
Pair of texture coordinates.
CVert * vertices
Array of vertices in the mesh.
int lodMap[INSTANCE_LOD]
Specifies which mesh should be each for each LOD.
int mapwidth
Width in pixels of the diffuse map for the Cell.
ExternalMutex::Mutex lock
A critical section to protect the cache.
int * faces
Array of faces as indices to vertices.
CFastQuadrics mesh[MEDIUM_MAX]
A mesh containing the polygons that appear in the Cell.
TMap< CellId, BillboardCellCache * > cache
This map links each cell to its cache.
static const int MEDIUM_MAX
Number of different mediums in the world. Each medium may be subject to a different rendering logic...
An entry in the billboard cache.
String sliceName
Identifier for the texture map used by the mesh.
int medium
Indentifies to which medium the material belongs to.
int instanceVertCount
Number of vertices for material instances in the cell.
unsigned int * billboardLightColor
List of billboard light colors.
double distanceToViewer
Distance to the viewer when the billboard or material instance was created.
Structure used to cache billboards and material instances.
const int BILLBOARD_OCCUPANCY_GRID_0
Billboard cache density for type 0 billboards (grass and ground instances)
unsigned __int64 CellId
A 64bit integer that identifies a single world octree Cell.
CVert * vertNormals[MEDIUM_MAX]
List of smoothed vertex normals.
int billboardCount
Number of billboard objects found in the Cell.
int normalMapWidth
Width in pixels of the normal map for the Cell.
TMap< String, int > instanceSliceMap
A map that links the string form ID for texture map in material instance meshes to the numeric ID tha...
Stores the information for a Cell that has already been converted to a polygonal mesh.
static int getMaterialMedium(CMaterial &materialDefinition, int level)
Returns medium identifier based on a material definition.
CVert * instanceUV
Array containing material instance UV coordinates.
double snowHeight
Height of the snow layer for this cell.
void deleteCache(CellId cell)
Deletes the cached billboards for the specified cell.
CVert * billboardLightDir
List of billboard light directions.
virtual void processMesh(CMaterialLibrary *materialLibrary, CBillboardCache *billboardCache, ThreadContext *tc, LODStats stats)
Computes normals, materials and billboards for the Cell.
void loadFromBuffer()
Loads the cell contents from a buffer. This is used by the offline mode of VoxelFarm.
Defines a mesh that can be instanced relative to a face in the mesh.
unsigned int * materials[MEDIUM_MAX]
List of materials to be sent to the GPU.
void moveToGarbage(CellId cell)
Declares the cell billboards can be disposed in any time.
int vertexCount
Number of vertices in the mesh.
const int BILLBOARD_MAX_LEVEL_TYPE1
Maximum LOD to include type 1 billboards (foliage)
StatTracker LODStats[LEVELS][STAT_NULL]
Used to track stats across all LOD.
CVert * vertices[MEDIUM_MAX]
List of vertices in the Cell.
int billboardType
Billboard type (0 - grass, 1 - foliage, 3 - material instance)
CVert * lightDir[MEDIUM_MAX]
Light directions for vertices in the Cell.
bool enabled
Specified whether this occurence should be actually used.
CVert * instanceVertices
Array containing material instance vertices.
CVert * instanceNormals
Array containing material instance normals.
TMap< int, CCellData::CInstanceMeshLOD * > instanceMeshes
A map containing all the material instance meshes.
int generation
Age of the Cell. This is used by the Cell garbage collection system.
const int BILLBOARD_CACHE_LEVELS
Maximum LOD that will have its billboards and material instances cached.
void collectGarbage()
Disposes information for cells that are not any longer needed.
static const int INSTANCE_LOD
Number of LOD stored for each instance type.
float billboardHeight
Specifies billboard size.
TSet< CellId > garbage
Set of cells to be soon disposed.
TVector< BillboardPackData > BillboardCacheList
An array of billboard information.
unsigned int * lightColor[MEDIUM_MAX]
Light color for vertices in the Cell.
const int MAX_VERTICES
Maximum vertices in one cell.
unsigned char * materialChannels[MEDIUM_MAX][3]
List of materials to be sent to the GPU.
CVert * normals
Array of normals in the mesh.
int textureSlice
Index of the texture map used by the mesh.
unsigned int billboardLight
Light collected by the billboard.
CellId cell
Cell identifier.
void releaseData()
Releases core memory used to feed GPU data.
int billboardId
Identifies which billboard or material instance it is.
Algebra::Vector lastEyePos
Records the viewer position when the cell was created.
bool BillboardSort(const BillboardPackData *a, const BillboardPackData *b)
Sort criteria for billboards.
UV * billboardUV
List of billboard texture coordinates.
int instanceCount
Number of material instances in the cell.
int mapheight
Height in pixels of the normal map for the Cell.
CVert * billboardNormals
List of billboard normals.
unsigned short * instanceFaces
Array containing material instance face indices.
An efficient mesh representation that features Quadratic Error function simplification using a Multip...
TList< BillboardCellCache * > deadCells
List of cells to be disposed.
float rotation
Billboard's rotation around its normal.
bool * uvSet
Specifies whether the Cell vertex has UV mapping.
Algebra::Vector billboardNormal
Billboard's normal vector.
CInstanceMesh meshes[INSTANCE_LOD]
Array of meshes, one per LOD.
static const int MEDIUM_SOLID
This medium is used for solid world geometry.
A material definition for the VoxelFarm.com engine.
unsigned int * normals[MEDIUM_MAX]
List of normals to be sent to the GPU.
int normalMapHeight
Height in pixels of the normal map for the Cell.
int UVFacesCount[MEDIUM_MAX]
Number of faces that received UV coordinates.
BillboardCellCache * getBillboards(CellId cell)
Retrieves the list of billboards for teh specified cell.
Keeps an billboard cache entry for each cell that had its billboards and material instances generated...
CCellData::CInstanceMeshLOD * loadInstanceMesh(char *filename)
Loads all LOD for an instance mesh.
void updateTimeStamp()
Moves forward the time vector used to compue cache TTLs.
int materialId
Identifies on which material the billboard or material instance appears.