sdk/extensions/authoring/include/NvBlastExtAuthoringFractureTool.h

Go to the documentation of this file.
00001 // This code contains NVIDIA Confidential Information and is disclosed to you
00002 // under a form of NVIDIA software license agreement provided separately to you.
00003 //
00004 // Notice
00005 // NVIDIA Corporation and its licensors retain all intellectual property and
00006 // proprietary rights in and to this software and related documentation and
00007 // any modifications thereto. Any use, reproduction, disclosure, or
00008 // distribution of this software and related documentation without an express
00009 // license agreement from NVIDIA Corporation is strictly prohibited.
00010 //
00011 // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
00012 // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
00013 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
00014 // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
00015 //
00016 // Information and code furnished is believed to be accurate and reliable.
00017 // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
00018 // information or for any infringement of patents or other rights of third parties that may
00019 // result from its use. No license is granted by implication or otherwise under any patent
00020 // or patent rights of NVIDIA Corporation. Details are subject to change without notice.
00021 // This code supersedes and replaces all information previously supplied.
00022 // NVIDIA Corporation products are not authorized for use as critical
00023 // components in life support devices or systems without express written approval of
00024 // NVIDIA Corporation.
00025 //
00026 // Copyright (c) 2016-2020 NVIDIA Corporation. All rights reserved.
00027 
00028 
00029 #ifndef NVBLASTAUTHORINGFRACTURETOOL_H
00030 #define NVBLASTAUTHORINGFRACTURETOOL_H
00031 
00032 #include "NvBlastExtAuthoringTypes.h"
00033 
00034 namespace Nv
00035 {
00036 namespace Blast
00037 {
00038 
00039 class SpatialAccelerator;
00040 class Triangulator;
00041 class Mesh;
00042 class CutoutSet;
00043 
00044 /*
00045     Chunk data, chunk with chunkId == 0 is always source mesh.
00046 */
00047 struct ChunkInfo
00048 {
00049     enum ChunkFlags
00050     {
00051         NO_FLAGS            = 0,
00052         APPROXIMATE_BONDING = 1 // Created by island splitting or chunk merge, etc. and should check for inexact bonds
00053     };
00054 
00055     Mesh* meshData;
00056     int32_t parent;
00057     int32_t chunkId;
00058     uint32_t flags;
00059     bool isLeaf;
00060     bool isChanged;
00061 };
00062 
00066 class RandomGeneratorBase
00067 {
00068   public:
00069     // Generates uniformly distributed value in [0, 1] range.
00070     virtual float getRandomValue() = 0;
00071     // Seeds random value generator
00072     virtual void seed(int32_t seed) = 0;
00073     virtual ~RandomGeneratorBase(){};
00074 };
00075 
00076 /*
00077     Noise fracturing configuration for chunks's faces
00078 */
00079 struct NoiseConfiguration
00080 {
00086     float amplitude = 0.f;
00087 
00091     float frequency = 1.f;
00092 
00096     uint32_t octaveNumber = 1;
00097 
00101     NvcVec3 samplingInterval = { 1, 1, 1 };
00102 };
00103 
00104 /*
00105     Slicing fracturing configuration
00106 */
00107 struct SlicingConfiguration
00108 {
00112     int32_t x_slices = 1, y_slices = 1, z_slices = 1;
00113 
00117     float offset_variations = 0.f;
00118 
00122     float angle_variations = 0.f;
00123 
00124     /*
00125         Noise parameters for faces between sliced chunks
00126     */
00127     NoiseConfiguration noise;
00128 };
00129 
00133 struct CutoutConfiguration
00134 {
00139     CutoutSet* cutoutSet = nullptr;
00140 
00145     NvcTransform transform = {{0, 0, 0, 1}, {0, 0, 0}};
00146 
00152     NvcVec2 scale = { -1, -1 };
00153 
00157     float aperture = 0.f;
00158 
00163     bool isRelativeTransform = true;
00164 
00168     bool useSmoothing = false;
00169 
00173     NoiseConfiguration noise;
00174 };
00175 
00179 class VoronoiSitesGenerator
00180 {
00181   public:
00182     virtual ~VoronoiSitesGenerator() {}
00183 
00187     virtual void release() = 0;
00188 
00192     virtual void setBaseMesh(const Mesh* mesh) = 0;
00193 
00199     virtual uint32_t getVoronoiSites(const NvcVec3*& sites) = 0;
00200 
00205     virtual void addSite(const NvcVec3& site) = 0;
00210     virtual void uniformlyGenerateSitesInMesh(uint32_t numberOfSites) = 0;
00211 
00218     virtual void clusteredSitesGeneration(uint32_t numberOfClusters, uint32_t sitesPerCluster, float clusterRadius) = 0;
00219 
00230     virtual void radialPattern(const NvcVec3& center, const NvcVec3& normal, float radius, int32_t angularSteps,
00231                                int32_t radialSteps, float angleOffset = 0.0f, float variability = 0.0f) = 0;
00232 
00239     virtual void generateInSphere(const uint32_t count, const float radius, const NvcVec3& center) = 0;
00240 
00245     virtual void setStencil(const Mesh* stencil) = 0;
00246 
00250     virtual void clearStencil() = 0;
00251 
00258     virtual void deleteInSphere(const float radius, const NvcVec3& center, const float eraserProbability = 1) = 0;
00259 };
00260 
00264 class FractureTool
00265 {
00266 
00267   public:
00268     virtual ~FractureTool() {}
00269 
00273     virtual void release() = 0;
00274 
00278     virtual void reset() = 0;
00279 
00280 
00284     virtual void setSourceMesh(const Mesh* mesh) = 0;
00285 
00289     virtual int32_t setChunkMesh(const Mesh* mesh, int32_t parentId) = 0;
00290 
00294     virtual void setInteriorMaterialId(int32_t materialId) = 0;
00295 
00299     virtual int32_t getInteriorMaterialId() const = 0;
00300 
00304     virtual void replaceMaterialId(int32_t oldMaterialId, int32_t newMaterialId) = 0;
00305 
00309     virtual Mesh* createChunkMesh(int32_t chunkId) = 0;
00310 
00315     virtual void getTransformation(NvcVec3& offset, float& scale) = 0;
00316 
00317 
00326     virtual int32_t
00327     voronoiFracturing(uint32_t chunkId, uint32_t cellCount, const NvcVec3* cellPoints, bool replaceChunk) = 0;
00328 
00340     virtual int32_t voronoiFracturing(uint32_t chunkId, uint32_t cellCount, const NvcVec3* cellPoints,
00341                                       const NvcVec3& scale, const NvcQuat& rotation, bool replaceChunk) = 0;
00342 
00343 
00355     virtual int32_t
00356     slicing(uint32_t chunkId, const SlicingConfiguration& conf, bool replaceChunk, RandomGeneratorBase* rnd) = 0;
00357 
00371     virtual int32_t cut(uint32_t chunkId, const NvcVec3& normal, const NvcVec3& position,
00372                         const NoiseConfiguration& noise, bool replaceChunk, RandomGeneratorBase* rnd) = 0;
00373 
00385     virtual int32_t cutout(uint32_t chunkId, CutoutConfiguration conf, bool replaceChunk, RandomGeneratorBase* rnd) = 0;
00386 
00387 
00391     virtual void finalizeFracturing() = 0;
00392 
00396     virtual uint32_t getChunkCount() const = 0;
00397 
00401     virtual const ChunkInfo& getChunkInfo(int32_t chunkIndex) = 0;
00402 
00410     virtual float getMeshOverlap(const Mesh& meshA, const Mesh& meshB) = 0;
00411 
00418     virtual uint32_t getBaseMesh(int32_t chunkIndex, Triangle*& output) = 0;
00419 
00427     virtual uint32_t updateBaseMesh(int32_t chunkIndex, Triangle* output) = 0;
00428 
00434     virtual int32_t getChunkIndex(int32_t chunkId) = 0;
00435 
00441     virtual int32_t getChunkId(int32_t chunkIndex) = 0;
00442 
00448     virtual int32_t getChunkDepth(int32_t chunkId) = 0;
00449 
00456     virtual uint32_t getChunksIdAtDepth(uint32_t depth, int32_t*& chunkIds) = 0;
00457 
00467     virtual uint32_t
00468     getBufferedBaseMeshes(Vertex*& vertexBuffer, uint32_t*& indexBuffer, uint32_t*& indexBufferOffsets) = 0;
00469 
00474     virtual void setRemoveIslands(bool isRemoveIslands) = 0;
00475 
00481     virtual int32_t islandDetectionAndRemoving(int32_t chunkId, bool createAtNewDepth = false) = 0;
00482 
00487     virtual bool isMeshContainOpenEdges(const Mesh* input) = 0;
00488 
00495     virtual bool deleteChunkSubhierarchy(int32_t chunkId, bool deleteRoot = false) = 0;
00496 
00510     virtual void uniteChunks(uint32_t threshold, uint32_t targetClusterSize,
00511                              const uint32_t* chunksToMerge, uint32_t mergeChunkCount,
00512                              const NvcVec2i* adjChunks, uint32_t adjChunksSize,
00513                              bool removeOriginalChunks = false) = 0;
00514 
00521     virtual bool setApproximateBonding(uint32_t chunkIndex, bool useApproximateBonding) = 0;
00522 
00528     virtual void fitUvToRect(float side, uint32_t chunkId) = 0;
00529 
00534     virtual void fitAllUvToRect(float side) = 0;
00535 };
00536 
00537 }  // namespace Blast
00538 }  // namespace Nv
00539 
00540 #endif  // ifndef NVBLASTAUTHORINGFRACTURETOOL_H