Main Page Class List Class Members

NvBlastExtAuthoringFractureTool.h
Go to the documentation of this file.
1 // This code contains NVIDIA Confidential Information and is disclosed to you
2 // under a form of NVIDIA software license agreement provided separately to you.
3 //
4 // Notice
5 // NVIDIA Corporation and its licensors retain all intellectual property and
6 // proprietary rights in and to this software and related documentation and
7 // any modifications thereto. Any use, reproduction, disclosure, or
8 // distribution of this software and related documentation without an express
9 // license agreement from NVIDIA Corporation is strictly prohibited.
10 //
11 // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
12 // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
13 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
14 // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
15 //
16 // Information and code furnished is believed to be accurate and reliable.
17 // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
18 // information or for any infringement of patents or other rights of third parties that may
19 // result from its use. No license is granted by implication or otherwise under any patent
20 // or patent rights of NVIDIA Corporation. Details are subject to change without notice.
21 // This code supersedes and replaces all information previously supplied.
22 // NVIDIA Corporation products are not authorized for use as critical
23 // components in life support devices or systems without express written approval of
24 // NVIDIA Corporation.
25 //
26 // Copyright (c) 2016-2020 NVIDIA Corporation. All rights reserved.
27
28
29 #ifndef NVBLASTAUTHORINGFRACTURETOOL_H
30 #define NVBLASTAUTHORINGFRACTURETOOL_H
31
32 #include "NvBlastExtAuthoringTypes.h"
33
34 namespace Nv
35 {
36 namespace Blast
37 {
38
39 class SpatialAccelerator;
40 class Triangulator;
41 class Mesh;
42 class CutoutSet;
43
44 /*
45 Chunk data, chunk with chunkId == 0 is always source mesh.
46 */
47 struct ChunkInfo
48 {
49 enum ChunkFlags
50 {
51 NO_FLAGS = 0,
52 APPROXIMATE_BONDING = 1 // Created by island splitting or chunk merge, etc. and should check for inexact bonds
53 };
54
55 Mesh* meshData;
56 int32_t parent;
57 int32_t chunkId;
58 uint32_t flags;
59 bool isLeaf;
60 bool isChanged;
61 };
62
66 class RandomGeneratorBase
67 {
68 public:
69 // Generates uniformly distributed value in [0, 1] range.
70 virtual float getRandomValue() = 0;
71 // Seeds random value generator
72 virtual void seed(int32_t seed) = 0;
73 virtual ~RandomGeneratorBase(){};
74 };
75
76 /*
77 Noise fracturing configuration for chunks's faces
78 */
79 struct NoiseConfiguration
80 {
86 float amplitude = 0.f;
87
91 float frequency = 1.f;
92
96 uint32_t octaveNumber = 1;
97
101 NvcVec3 samplingInterval = { 1, 1, 1 };
102 };
103
104 /*
105 Slicing fracturing configuration
106 */
107 struct SlicingConfiguration
108 {
112 int32_t x_slices = 1, y_slices = 1, z_slices = 1;
113
117 float offset_variations = 0.f;
118
122 float angle_variations = 0.f;
123
124 /*
125 Noise parameters for faces between sliced chunks
126 */
127 NoiseConfiguration noise;
128 };
129
133 struct CutoutConfiguration
134 {
139 CutoutSet* cutoutSet = nullptr;
140
145 NvcTransform transform = {{0, 0, 0, 1}, {0, 0, 0}};
146
152 NvcVec2 scale = { -1, -1 };
153
157 float aperture = 0.f;
158
163 bool isRelativeTransform = true;
164
168 bool useSmoothing = false;
169
173 NoiseConfiguration noise;
174 };
175
179 class VoronoiSitesGenerator
180 {
181 public:
182 virtual ~VoronoiSitesGenerator() {}
183
187 virtual void release() = 0;
188
192 virtual void setBaseMesh(const Mesh* mesh) = 0;
193
199 virtual uint32_t getVoronoiSites(const NvcVec3*& sites) = 0;
200
205 virtual void addSite(const NvcVec3& site) = 0;
210 virtual void uniformlyGenerateSitesInMesh(uint32_t numberOfSites) = 0;
211
218 virtual void clusteredSitesGeneration(uint32_t numberOfClusters, uint32_t sitesPerCluster, float clusterRadius) = 0;
219
230 virtual void radialPattern(const NvcVec3& center, const NvcVec3& normal, float radius, int32_t angularSteps,
231 int32_t radialSteps, float angleOffset = 0.0f, float variability = 0.0f) = 0;
232
239 virtual void generateInSphere(const uint32_t count, const float radius, const NvcVec3& center) = 0;
240
245 virtual void setStencil(const Mesh* stencil) = 0;
246
250 virtual void clearStencil() = 0;
251
258 virtual void deleteInSphere(const float radius, const NvcVec3& center, const float eraserProbability = 1) = 0;
259 };
260
264 class FractureTool
265 {
266
267 public:
268 virtual ~FractureTool() {}
269
273 virtual void release() = 0;
274
278 virtual void reset() = 0;
279
280
284 virtual void setSourceMesh(const Mesh* mesh) = 0;
285
289 virtual int32_t setChunkMesh(const Mesh* mesh, int32_t parentId) = 0;
290
294 virtual void setInteriorMaterialId(int32_t materialId) = 0;
295
299 virtual int32_t getInteriorMaterialId() const = 0;
300
304 virtual void replaceMaterialId(int32_t oldMaterialId, int32_t newMaterialId) = 0;
305
309 virtual Mesh* createChunkMesh(int32_t chunkId) = 0;
310
315 virtual void getTransformation(NvcVec3& offset, float& scale) = 0;
316
317
326 virtual int32_t
327 voronoiFracturing(uint32_t chunkId, uint32_t cellCount, const NvcVec3* cellPoints, bool replaceChunk) = 0;
328
340 virtual int32_t voronoiFracturing(uint32_t chunkId, uint32_t cellCount, const NvcVec3* cellPoints,
341 const NvcVec3& scale, const NvcQuat& rotation, bool replaceChunk) = 0;
342
343
355 virtual int32_t
356 slicing(uint32_t chunkId, const SlicingConfiguration& conf, bool replaceChunk, RandomGeneratorBase* rnd) = 0;
357
371 virtual int32_t cut(uint32_t chunkId, const NvcVec3& normal, const NvcVec3& position,
372 const NoiseConfiguration& noise, bool replaceChunk, RandomGeneratorBase* rnd) = 0;
373
385 virtual int32_t cutout(uint32_t chunkId, CutoutConfiguration conf, bool replaceChunk, RandomGeneratorBase* rnd) = 0;
386
387
391 virtual void finalizeFracturing() = 0;
392
396 virtual uint32_t getChunkCount() const = 0;
397
401 virtual const ChunkInfo& getChunkInfo(int32_t chunkIndex) = 0;
402
410 virtual float getMeshOverlap(const Mesh& meshA, const Mesh& meshB) = 0;
411
418 virtual uint32_t getBaseMesh(int32_t chunkIndex, Triangle*& output) = 0;
419
427 virtual uint32_t updateBaseMesh(int32_t chunkIndex, Triangle* output) = 0;
428
434 virtual int32_t getChunkIndex(int32_t chunkId) = 0;
435
441 virtual int32_t getChunkId(int32_t chunkIndex) = 0;
442
448 virtual int32_t getChunkDepth(int32_t chunkId) = 0;
449
456 virtual uint32_t getChunksIdAtDepth(uint32_t depth, int32_t*& chunkIds) = 0;
457
467 virtual uint32_t
468 getBufferedBaseMeshes(Vertex*& vertexBuffer, uint32_t*& indexBuffer, uint32_t*& indexBufferOffsets) = 0;
469
474 virtual void setRemoveIslands(bool isRemoveIslands) = 0;
475
481 virtual int32_t islandDetectionAndRemoving(int32_t chunkId, bool createAtNewDepth = false) = 0;
482
487 virtual bool isMeshContainOpenEdges(const Mesh* input) = 0;
488
495 virtual bool deleteChunkSubhierarchy(int32_t chunkId, bool deleteRoot = false) = 0;
496
510 virtual void uniteChunks(uint32_t threshold, uint32_t targetClusterSize,
511 const uint32_t* chunksToMerge, uint32_t mergeChunkCount,
512 const NvcVec2i* adjChunks, uint32_t adjChunksSize,
513 bool removeOriginalChunks = false) = 0;
514
521 virtual bool setApproximateBonding(uint32_t chunkIndex, bool useApproximateBonding) = 0;
522
528 virtual void fitUvToRect(float side, uint32_t chunkId) = 0;
529
534 virtual void fitAllUvToRect(float side) = 0;
535 };
536
537 } // namespace Blast
538 } // namespace Nv
539
540 #endif // ifndef NVBLASTAUTHORINGFRACTURETOOL_H
Nv::Blast::SlicingConfiguration
Definition: NvBlastExtAuthoringFractureTool.h:107
Nv::Blast::ChunkInfo
Definition: NvBlastExtAuthoringFractureTool.h:47
Nv::Blast::VoronoiSitesGenerator
Definition: NvBlastExtAuthoringFractureTool.h:179
Nv::Blast::CutoutSet
Definition: NvBlastExtAuthoringCutout.h:36
Nv::Blast::ChunkInfo::APPROXIMATE_BONDING
Definition: NvBlastExtAuthoringFractureTool.h:52
NvBlastExtAuthoringTypes.h
Nv::Blast::NoiseConfiguration
Definition: NvBlastExtAuthoringFractureTool.h:79
Nv::Blast::Mesh
Definition: NvBlastExtAuthoringMesh.h:42
Nv::Blast::FractureTool
Definition: NvBlastExtAuthoringFractureTool.h:264
NvcVec2
Definition: NvCTypes.h:43
Nv::Blast::RandomGeneratorBase
Definition: NvBlastExtAuthoringFractureTool.h:66
Nv::Blast::VoronoiSitesGenerator::~VoronoiSitesGenerator
virtual ~VoronoiSitesGenerator()
Definition: NvBlastExtAuthoringFractureTool.h:182
Nv::Blast::ChunkInfo::isLeaf
bool isLeaf
Definition: NvBlastExtAuthoringFractureTool.h:59
Nv::Blast::SlicingConfiguration::noise
NoiseConfiguration noise
Definition: NvBlastExtAuthoringFractureTool.h:127
Nv::Blast::ChunkInfo::ChunkFlags
ChunkFlags
Definition: NvBlastExtAuthoringFractureTool.h:49
NvcTransform
Definition: NvCTypes.h:67
NvcVec2i
Definition: NvCTypes.h:106
Nv::Blast::CutoutConfiguration::noise
NoiseConfiguration noise
Definition: NvBlastExtAuthoringFractureTool.h:173
Nv::Blast::ChunkInfo::meshData
Mesh * meshData
Definition: NvBlastExtAuthoringFractureTool.h:55
Nv::Blast::ChunkInfo::flags
uint32_t flags
Definition: NvBlastExtAuthoringFractureTool.h:58
Nv::Blast::CutoutConfiguration
Definition: NvBlastExtAuthoringFractureTool.h:133
Nv::Blast::Triangle
Definition: NvBlastExtAuthoringTypes.h:79
Nv::Blast::FractureTool::~FractureTool
virtual ~FractureTool()
Definition: NvBlastExtAuthoringFractureTool.h:268
Nv::Blast::ChunkInfo::parent
int32_t parent
Definition: NvBlastExtAuthoringFractureTool.h:56
Nv::Blast::RandomGeneratorBase::~RandomGeneratorBase
virtual ~RandomGeneratorBase()
Definition: NvBlastExtAuthoringFractureTool.h:73
Nv::Blast::ChunkInfo::NO_FLAGS
Definition: NvBlastExtAuthoringFractureTool.h:51
Nv::Blast::ChunkInfo::chunkId
int32_t chunkId
Definition: NvBlastExtAuthoringFractureTool.h:57
Nv::Blast::ChunkInfo::isChanged
bool isChanged
Definition: NvBlastExtAuthoringFractureTool.h:60
Nv::Blast::Vertex
Definition: NvBlastExtAuthoringTypes.h:67
Nv
Definition: NvBlastExtAuthoring.h:34
NvcVec3
Definition: NvCTypes.h:49
NvcQuat
Definition: NvCTypes.h:61