StampMesh.h
1 #pragma once
2 
3 #include "mapindex.h"
4 #include "VoxelLayer.h"
5 #include "BlockData.h"
6 #include "Vector.h"
7 #include "MatrixAlg.h"
8 #include "FastQuadrics.h"
9 
10 #include "PhysicsMaterials.h"
11 #include "PhysicsData.h"
12 #include "MaterialLibrary.h"
13 
14 namespace VoxelFarm
15 {
16 
18  typedef uint32_t ShortVoxel;
19 
22  {
23  float x;
24  float y;
25  float z;
26  bool ready;
27  bool mat;
28  };
29 
32  {
33  public:
35  virtual int getSolidCount() = 0;
37  virtual MaterialId getSolidMaterial(int solid) = 0;
39  virtual int getFaceCount(int solid) = 0;
41  virtual void getFace(int solid,
42  int index,
43  Algebra::Vector& v0,
44  Algebra::Vector& v1,
45  Algebra::Vector& v2) = 0;
46  };
47 
50  {
51  public:
52  virtual MaterialId translateMaterial(const double worldPos[3], MaterialId meshMaterial) = 0;
53  };
54 
56  void stampMesh(
58  IBlockData* blockData,
60  IMeshStampSource* mesh,
62  IMeshStamMaterialSource* materials,
64  const double worldPos[3],
66  const Algebra::Matrix& transform,
68  TSet<CellId>* changedCells
69  );
70 
72  void stampMeshQEF(
74  IBlockData* blockData,
76  IMeshStampSource* mesh,
78  IMeshStamMaterialSource* materials,
80  const double worldPos[3],
82  const Algebra::Matrix& transform,
84  TSet<CellId>* changedCells,
85 
87  Physics::CNoiseBrush* noise = NULL,
88  Physics::CVoxelBuffer* nVoxBuffer = NULL,
89  const TMap<CellId, unsigned char*>* voxelCache = NULL,
90  const int hitMaterial = 0
91  );
92 
94  void stampVoxels(
96  IBlockData* blockData,
98  ShortVoxel* source,
100  int xsize, int ysize, int zsize,
102  IMeshStamMaterialSource* materials,
104  const double worldPos[3],
106  TSet<CellId>* changedCells
107  );
108 
110  void stampVoxelsQEF(
112  IBlockData* blockData,
114  ShortVoxel* source,
116  int xsize, int ysize, int zsize,
118  IMeshStamMaterialSource* materials,
120  const double worldPos[3],
122  TSet<CellId>* changedCells
123  );
124 
126  void voxelizeMesh(
128  ShortVoxel* voxelData,
130  IMeshStampSource* mesh,
132  int lod,
134  const float meshOrigin[3],
136  const float meshRotation[3],
138  int xsize, int ysize, int zsize,
139  Algebra::Vector& voxelMin,
140  Algebra::Vector& voxelMax
141  );
142 
144  void deleteMeshVoxels(
146  CBlockData* blockData,
148  IMeshStampSource* mesh,
150  const double worldPos[3],
152  const int deletionLOD,
154  CMaterialLibrary* materialLibrary,
156  Physics::CMassInfo* mass,
158  std::set<CellId>* changedCells
159  );
160 
162  void voxelizeTriangles(
164  ShortVoxel* voxelData,
166  VoxelFarm::Algebra::Vector* vertexes,
168  int vertexCount,
170  double kernelX, double kernelY, double kernelZ,
171  int kernelMargin,
172  int kernelSizeX, int kernelSizeY, int kernelSizeZ,
174  double& minDistance,
176  double& maxDistance,
178  bool& lostData
179  );
180 
182  void voxelizeSmoothMesh(
184  StampSmoothData* voxelData,
186  CFastQuadrics* mesh,
188  double kernelX, double kernelY, double kernelZ,
190  int kernelSizeX, int kernelSizeY, int kernelSizeZ
191  );
192 
194  void voxelMeshMask(
196  VoxelMaskData* voxelMask,
198  IMeshStampSource* mesh,
200  int xsize, int ysize, int zsize
201  );
202 
203  void voxelRLECompress(ShortVoxel* data, int sizeX, int sizeY, int sizeZ, ShortVoxel* compIndex, unsigned char* compData, int& compSize);
204 
205 }
void deleteMeshVoxels(CBlockData *blockData, IMeshStampSource *mesh, const double worldPos[3], const int deletionLOD, CMaterialLibrary *materialLibrary, Physics::CMassInfo *mass, std::set< CellId > *changedCells)
It deletes voxels associated with physics meshes.
Used for partially voxelization operations.
Definition: StampMesh.h:21
Contains all classes and functions for the VoxelFarm engine.
virtual int getFaceCount(int solid)=0
Returns the number of faces in a solid.
Contains all materials available in the system.
A 3D Vector.
Definition: Vector.h:34
void voxelMeshMask(VoxelMaskData *voxelMask, IMeshStampSource *mesh, int xsize, int ysize, int zsize)
Returns a mask of voxels from a mesh.
A default implementation of IBlockData that also acts as a VoxelLayer.
Definition: BlockData.h:182
It allows to access to the faces and materials of a list of solids.
Definition: StampMesh.h:31
void voxelizeMesh(ShortVoxel *voxelData, IMeshStampSource *mesh, int lod, const float meshOrigin[3], const float meshRotation[3], int xsize, int ysize, int zsize, Algebra::Vector &voxelMin, Algebra::Vector &voxelMax)
It voxelizes a mesh and returns a block of voxels.
void stampMesh(IBlockData *blockData, IMeshStampSource *mesh, IMeshStamMaterialSource *materials, const double worldPos[3], const Algebra::Matrix &transform, TSet< CellId > *changedCells)
It voxelizes a mesh and stamps it into a block layer.
A Matrix for 3D operations.
Definition: MatrixAlg.h:38
void voxelizeTriangles(ShortVoxel *voxelData, VoxelFarm::Algebra::Vector *vertexes, int vertexCount, double kernelX, double kernelY, double kernelZ, int kernelMargin, int kernelSizeX, int kernelSizeY, int kernelSizeZ, double &minDistance, double &maxDistance, bool &lostData)
It voxelizes a list of triangles.
void stampVoxelsQEF(IBlockData *blockData, ShortVoxel *source, int xsize, int ysize, int zsize, IMeshStamMaterialSource *materials, const double worldPos[3], TSet< CellId > *changedCells)
It stamps a block of voxels into a block layer and minimizes the error with the existing data...
void voxelizeSmoothMesh(StampSmoothData *voxelData, CFastQuadrics *mesh, double kernelX, double kernelY, double kernelZ, int kernelSizeX, int kernelSizeY, int kernelSizeZ)
Voxelizes partially a mesh based on precomputed data.
void stampVoxels(IBlockData *blockData, ShortVoxel *source, int xsize, int ysize, int zsize, IMeshStamMaterialSource *materials, const double worldPos[3], TSet< CellId > *changedCells)
It stamps a block of voxels into a block layer.
virtual MaterialId getSolidMaterial(int solid)=0
Returns the material of a solid.
virtual int getSolidCount()=0
Returns the number of solids.
virtual void getFace(int solid, int index, Algebra::Vector &v0, Algebra::Vector &v1, Algebra::Vector &v2)=0
Get the vertices of a face of a solid.
A structure for storing voxel information when we generate a mask from a mesh.
Definition: BlockData.h:20
An efficient mesh representation that features Quadratic Error function simplification using a Multip...
Definition: FastQuadrics.h:44
uint32_t ShortVoxel
A compact 32 bit representation for a voxel.
Definition: StampMesh.h:18
void stampMeshQEF(IBlockData *blockData, IMeshStampSource *mesh, IMeshStamMaterialSource *materials, const double worldPos[3], const Algebra::Matrix &transform, TSet< CellId > *changedCells, Physics::CNoiseBrush *noise=NULL, Physics::CVoxelBuffer *nVoxBuffer=NULL, const TMap< CellId, unsigned char * > *voxelCache=NULL, const int hitMaterial=0)
It voxelizes a mesh and stamps it into a block layer and minimizes the error with the existing data...
It translates a given material depending of the position in the world.
Definition: StampMesh.h:49