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-2018 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     Mesh*   meshData;
00050     int32_t parent;
00051     int32_t chunkId;
00052     bool    isLeaf;
00053     bool    isChanged;
00054 };
00055 
00056 /*
00057     Noise fracturing configuration for chunks's faces
00058 */
00059 struct NoiseConfiguration
00060 {
00066     float   amplitude = 0.f;
00067 
00071     float   frequency = 1.f;
00072 
00076     uint32_t octaveNumber = 1;
00077 
00081     uint32_t surfaceResolution = 1;
00082 };
00083 
00084 /*
00085     Slicing fracturing configuration
00086 */
00087 struct SlicingConfiguration
00088 {
00092     int32_t x_slices = 1, y_slices = 1, z_slices = 1;
00093 
00097     float   offset_variations = 0.f;
00098 
00102     float   angle_variations = 0.f;
00103 
00104     /*
00105         Noise parameters for faces between sliced chunks
00106     */
00107     NoiseConfiguration noise;
00108 };
00109 
00113 struct CutoutConfiguration
00114 {
00119     CutoutSet* cutoutSet = nullptr;
00120 
00125     physx::PxTransform transform = physx::PxTransform(physx::PxIdentity);
00126 
00131     physx::PxVec2 scale = physx::PxVec2(-1, -1);
00132 
00136     bool isRelativeTransform = true;
00137 
00141     NoiseConfiguration noise;
00142 };
00143 
00147 class VoronoiSitesGenerator
00148 {
00149 public:
00150     virtual ~VoronoiSitesGenerator() {}
00151 
00155     virtual void                        release() = 0;
00156 
00160     virtual void                        setBaseMesh(const Mesh* mesh) = 0;
00161 
00167     virtual uint32_t                    getVoronoiSites(const physx::PxVec3*& sites) = 0;
00168     
00173     virtual void                        addSite(const physx::PxVec3& site) = 0;
00178     virtual void                        uniformlyGenerateSitesInMesh(uint32_t numberOfSites) = 0;
00179 
00186     virtual void                        clusteredSitesGeneration(uint32_t numberOfClusters, uint32_t sitesPerCluster, float clusterRadius) = 0;
00187 
00198     virtual void                        radialPattern(const physx::PxVec3& center, const physx::PxVec3& normal, float radius, int32_t angularSteps, int32_t radialSteps, float angleOffset = 0.0f, float variability = 0.0f) = 0;
00199 
00206     virtual void                        generateInSphere(const uint32_t count, const float radius, const physx::PxVec3& center) = 0;
00207 
00212     virtual void                        setStencil(const Mesh* stencil) = 0;
00213 
00217     virtual void                        clearStencil() = 0;
00218 
00225     virtual void                        deleteInSphere(const float radius, const physx::PxVec3& center, const float eraserProbability = 1) = 0;
00226 };
00227 
00231 class FractureTool
00232 {
00233 
00234 public:
00235     virtual ~FractureTool() {}
00236 
00240     virtual void                                    release() = 0;
00241 
00245     virtual void                                    reset() = 0;
00246     
00247     
00251     virtual void                                    setSourceMesh(const Mesh* mesh) = 0;
00252 
00256     virtual int32_t                                 setChunkMesh(const Mesh* mesh, int32_t parentId) = 0;
00257 
00261     virtual void                                    setInteriorMaterialId(int32_t materialId) = 0;
00262 
00266     virtual int32_t                                 getInteriorMaterialId() const = 0;
00267 
00271     virtual void                                    replaceMaterialId(int32_t oldMaterialId, int32_t newMaterialId) = 0;
00272 
00276     virtual Mesh*                                   createChunkMesh(int32_t chunkId) = 0;
00277 
00282     virtual void                                    getTransformation(physx::PxVec3& offset, float& scale) = 0;
00283 
00284 
00293     virtual int32_t                                 voronoiFracturing(uint32_t chunkId, uint32_t cellCount, const physx::PxVec3* cellPoints, bool replaceChunk) = 0;
00294 
00306     virtual int32_t                                 voronoiFracturing(uint32_t chunkId, uint32_t cellCount, const physx::PxVec3* cellPoints, const physx::PxVec3& scale, const physx::PxQuat& rotation, bool replaceChunk) = 0;
00307 
00308 
00319     virtual int32_t                                 slicing(uint32_t chunkId, const SlicingConfiguration& conf, bool replaceChunk, RandomGeneratorBase* rnd) = 0;
00320 
00333     virtual int32_t                                 cut(uint32_t chunkId, const physx::PxVec3& normal, const physx::PxVec3& position, const NoiseConfiguration& noise, bool replaceChunk, RandomGeneratorBase* rnd) = 0;
00334 
00345     virtual int32_t                                 cutout(uint32_t chunkId, CutoutConfiguration conf, bool replaceChunk, RandomGeneratorBase* rnd) = 0;
00346 
00347 
00351     virtual void                                    finalizeFracturing() = 0;
00352     
00356     virtual uint32_t                                getChunkCount() const = 0;
00357 
00361     virtual const ChunkInfo&                        getChunkInfo(int32_t chunkIndex) = 0;
00362 
00370     virtual float                                   getMeshOverlap(const Mesh& meshA, const Mesh& meshB) = 0;
00371 
00378     virtual uint32_t                                getBaseMesh(int32_t chunkIndex, Triangle*& output) = 0;
00379 
00387     virtual uint32_t                                updateBaseMesh(int32_t chunkIndex, Triangle* output) = 0;
00388 
00394     virtual int32_t                                 getChunkIndex(int32_t chunkId) = 0;
00395 
00401     virtual int32_t                                 getChunkId(int32_t chunkIndex) = 0;
00402 
00408     virtual int32_t                                 getChunkDepth(int32_t chunkId) = 0;
00409 
00416     virtual uint32_t                                getChunksIdAtDepth(uint32_t depth, int32_t*& chunkIds) = 0;
00417 
00427     virtual uint32_t                                getBufferedBaseMeshes(Vertex*& vertexBuffer, uint32_t*& indexBuffer, uint32_t*& indexBufferOffsets) = 0;
00428 
00433     virtual void                                    setRemoveIslands(bool isRemoveIslands) = 0;
00434 
00440     virtual int32_t                                 islandDetectionAndRemoving(int32_t chunkId) = 0;
00441 
00446     virtual bool                                    isMeshContainOpenEdges(const Mesh* input) = 0;
00447 
00453     virtual bool                                    deleteAllChildrenOfChunk(int32_t chunkId) = 0;
00454 
00462     virtual void                                    uniteChunks(uint32_t maxAtLevel, uint32_t maxGroupSize) = 0;
00463 
00469     virtual void                                    fitUvToRect(float side, uint32_t chunkId) = 0;
00470 
00475     virtual void                                    fitAllUvToRect(float side) = 0;
00476 
00477 };
00478 
00479 } // namespace Blast
00480 } // namespace Nv
00481 
00482 #endif // ifndef NVBLASTAUTHORINGFRACTURETOOL_H