aboutsummaryrefslogtreecommitdiff
path: root/sdk/extensions/authoring/include
diff options
context:
space:
mode:
authorBryan Galdrikian <[email protected]>2017-02-24 09:32:20 -0800
committerBryan Galdrikian <[email protected]>2017-02-24 09:32:20 -0800
commite1bf674c16e3c8472b29574159c789cd3f0c64e0 (patch)
tree9f0cfce09c71a2c27ff19589fcad6cd83504477c /sdk/extensions/authoring/include
parentfirst commit (diff)
downloadblast-e1bf674c16e3c8472b29574159c789cd3f0c64e0.tar.xz
blast-e1bf674c16e3c8472b29574159c789cd3f0c64e0.zip
Updating to [email protected] and [email protected] with a new directory structure.
NvBlast folder is gone, files have been moved to top level directory. README is changed to reflect this.
Diffstat (limited to 'sdk/extensions/authoring/include')
-rw-r--r--sdk/extensions/authoring/include/NvBlastExtAuthoringBondGenerator.h136
-rw-r--r--sdk/extensions/authoring/include/NvBlastExtAuthoringCollisionBuilder.h123
-rw-r--r--sdk/extensions/authoring/include/NvBlastExtAuthoringFractureTool.h435
-rw-r--r--sdk/extensions/authoring/include/NvBlastExtAuthoringMesh.h174
-rw-r--r--sdk/extensions/authoring/include/NvBlastExtAuthoringTypes.h128
5 files changed, 996 insertions, 0 deletions
diff --git a/sdk/extensions/authoring/include/NvBlastExtAuthoringBondGenerator.h b/sdk/extensions/authoring/include/NvBlastExtAuthoringBondGenerator.h
new file mode 100644
index 0000000..68767eb
--- /dev/null
+++ b/sdk/extensions/authoring/include/NvBlastExtAuthoringBondGenerator.h
@@ -0,0 +1,136 @@
+/*
+* Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
+*
+* NVIDIA CORPORATION and its licensors retain all intellectual property
+* and proprietary rights in and to this software, related documentation
+* and any modifications thereto. Any use, reproduction, disclosure or
+* distribution of this software and related documentation without an express
+* license agreement from NVIDIA CORPORATION is strictly prohibited.
+*/
+
+#ifndef NVBLASTEXTAUTHORINGBONDGENERATOR_H
+#define NVBLASTEXTAUTHORINGBONDGENERATOR_H
+
+#include "NvBlastExtAuthoringTypes.h"
+#include "NvBlastExtAuthoringFractureTool.h"
+#include "NvBlastTypes.h"
+#include "../cooking/PxCooking.h"
+#include <PxPlane.h>
+#include <NvBlastExtAuthoringCollisionBuilder.h>
+struct NvBlastBondDesc;
+struct NvBlastChunkDesc;
+struct NvBlastBond;
+
+using namespace physx;
+
+
+namespace Nv
+{
+namespace Blast
+{
+
+// Forward declarations
+class TriangleProcessor;
+struct PlaneChunkIndexer;
+
+/**
+ Bond interface generation configuration
+ EXACT - common surface will be searched
+ AVERAGE - Inerface is approximated by projections or intersecitons with midplane
+*/
+struct BondGenerationConfig
+{
+ enum BondGenMode { EXACT, AVERAGE };
+ BondGenMode bondMode;
+};
+
+
+struct PlaneChunkIndexer
+{
+ PlaneChunkIndexer(int32_t chunkId, int32_t trId, physx::PxPlane pl) : chunkId(chunkId), trId(trId), plane(pl) {}
+ int32_t chunkId;
+ int32_t trId;
+ physx::PxPlane plane;
+};
+
+
+/**
+ Tool for gathering bond information from provided mesh geometry
+*/
+
+class BlastBondGenerator
+{
+public:
+
+ BlastBondGenerator(physx::PxCooking* cooking, physx::PxPhysicsInsertionCallback* insertionCallback) : mPxCooking(cooking), mPxInsertionCallback(insertionCallback){};
+
+ /**
+ This method based on marking triangles during fracture process, so can be used only with internally fractured meshes.
+ \param[in] tool FractureTool which contains chunks representation, tool->finalizeFracturing() should be called before.
+ \param[in] chunkIsSupport Array of flags, if true - chunk is support. Array size should be equal to chunk count in tool.
+ \param[out] resultBondDescs Array of created bond descriptors.
+ \param[out] resultChunkDescriptors Array of created chunk descriptors.
+ \return 0 if success
+ */
+ int32_t buildDescFromInternalFracture(FractureTool* tool, const std::vector<bool>& chunkIsSupport, std::vector<NvBlastBondDesc>& resultBondDescs, std::vector<NvBlastChunkDesc>& resultChunkDescriptors);
+
+
+ /**
+ Creates bond description between two meshes
+ \param[in] meshA Array of triangles of mesh A.
+ \param[in] meshB Array of triangles of mesh B.
+ \param[out] resultBond Result bond description.
+ \param[in] conf Bond creation mode.
+ \return 0 if success
+ */
+ int32_t createBondBetweenMeshes(const std::vector<Triangle>& meshA, const std::vector<Triangle>& meshB, NvBlastBond& resultBond, BondGenerationConfig conf = BondGenerationConfig());
+
+ /**
+ Creates bond description between number of meshes
+ \param[in] geometry Array of arrays of triangles for each chunk.
+ \param[out] resultBond Array of result bonds.
+ \param[in] overlaps Array of pairs - indexes of chunks, for which bond should be created.
+ \param[in] cfg Bond creation mode.
+ \return 0 if success
+ */
+ int32_t createBondBetweenMeshes(const std::vector<std::vector<Triangle> >& geometry, std::vector<NvBlastBondDesc>& resultBond, const std::vector<std::pair<uint32_t, uint32_t> >& overlaps, BondGenerationConfig cfg);
+
+
+ /**
+ Creates bond description for prefractured meshes, when there is no info about which chunks should be connected with bond.
+ \param[in] geometry Array of arrays of triangles for each chunk.
+ \param[in] chunkIsSupport Array of flags, if true - chunk is support. Array size should be equal to chunk count in tool.
+ \param[out] resultBondDescs Array of result bonds.
+ \param[in] conf Bond creation mode.
+ \return 0 if success
+ */
+ int32_t bondsFromPrefractured(const std::vector<std::vector<Triangle>>& geometry, const std::vector<bool>& chunkIsSupport, std::vector<NvBlastBondDesc>& resultBondDescs, BondGenerationConfig conf = BondGenerationConfig());
+
+private:
+ float processWithMidplanes(TriangleProcessor* trProcessor, const std::vector<physx::PxVec3>& chunk1Points, const std::vector<physx::PxVec3>& chunk2Points,
+ const std::vector<physx::PxVec3>& hull1p,const std::vector<physx::PxVec3>& hull2p, physx::PxVec3& normal, physx::PxVec3& centroid);
+
+ int32_t createFullBondListAveraged(const std::vector<std::vector<Triangle>>& chunksGeometry, const std::vector<bool>& supportFlags, std::vector<NvBlastBondDesc>& mResultBondDescs, BondGenerationConfig conf);
+ int32_t createFullBondListExact(const std::vector<std::vector<Triangle>>& chunksGeometry, const std::vector<bool>& supportFlags, std::vector<NvBlastBondDesc>& mResultBondDescs, BondGenerationConfig conf);
+ int32_t createFullBondListExactInternal(const std::vector<std::vector<Triangle>>& chunksGeometry, std::vector < PlaneChunkIndexer >& planeTriangleMapping , std::vector<NvBlastBondDesc>& mResultBondDescs);
+ int32_t createBondForcedInternal(const std::vector<PxVec3>& hull0, const std::vector<PxVec3>& hull1,const CollisionHull& cHull0, const CollisionHull& cHull1,PxBounds3 bound0, PxBounds3 bound1, NvBlastBond& resultBond, float overlapping);
+
+ void buildGeometryCache(const std::vector<std::vector<Triangle> >& geometry);
+ void resetGeometryCache();
+
+ physx::PxCooking* mPxCooking;
+ physx::PxPhysicsInsertionCallback* mPxInsertionCallback;
+
+
+ std::vector<std::vector<Triangle> > mGeometryCache;
+
+ std::vector<PlaneChunkIndexer> mPlaneCache;
+ std::vector<CollisionHull> mCHullCache;
+ std::vector<std::vector<physx::PxVec3> > mHullsPointsCache;
+ std::vector<physx::PxBounds3 > mBoundsCache;
+};
+
+} // namespace Blast
+} // namespace Nv
+
+#endif // NVBLASTEXTAUTHORINGBONDGENERATOR_H \ No newline at end of file
diff --git a/sdk/extensions/authoring/include/NvBlastExtAuthoringCollisionBuilder.h b/sdk/extensions/authoring/include/NvBlastExtAuthoringCollisionBuilder.h
new file mode 100644
index 0000000..b3e143a
--- /dev/null
+++ b/sdk/extensions/authoring/include/NvBlastExtAuthoringCollisionBuilder.h
@@ -0,0 +1,123 @@
+/*
+* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
+*
+* NVIDIA CORPORATION and its licensors retain all intellectual property
+* and proprietary rights in and to this software, related documentation
+* and any modifications thereto. Any use, reproduction, disclosure or
+* distribution of this software and related documentation without an express
+* license agreement from NVIDIA CORPORATION is strictly prohibited.
+*/
+
+#ifndef NVBLASTEXTAUTHORINGCOLLISIONBUILDER_H
+#define NVBLASTEXTAUTHORINGCOLLISIONBUILDER_H
+
+#include "NvBlastTypes.h"
+#include <vector>
+#include <PxVec3.h>
+
+namespace physx
+{
+ class PxCooking;
+ class PxPhysicsInsertionCallback;
+ class PxVec3;
+ class PxConvexMesh;
+}
+
+
+namespace Nv
+{
+namespace Blast
+{
+
+/**
+ Collision hull geometry format.
+*/
+struct CollisionHull
+{
+ /**
+ Collision hull polygon format.
+ */
+ struct HullPolygon
+ {
+ // Polygon base plane
+ float mPlane[4];
+ // Number vertices in polygon
+ uint16_t mNbVerts;
+ // First index in CollisionHull.indices array for this polygon
+ uint16_t mIndexBase;
+ };
+ ///**
+
+ CollisionHull(){};
+
+ std::vector<physx::PxVec3> points;
+ std::vector<uint32_t> indices;
+ std::vector<HullPolygon> polygonData;
+};
+
+
+/**
+ ConvexMeshBuilder provides routine to build collision hulls from array of vertices.
+ Collision hull is built as convex hull of provided point set.
+ If due to some reason building of convex hull is failed, collision hull is built as bounding box of vertex set.
+*/
+class ConvexMeshBuilder
+{
+public:
+
+ /**
+ Constructor should be provided with PxCoocking and PxPhysicsInsertionCallback objects.
+ */
+ ConvexMeshBuilder(physx::PxCooking* cooking, physx::PxPhysicsInsertionCallback* insertionCallback) : mInsertionCallback(insertionCallback), mCooking(cooking) {}
+
+ /**
+ Method creates CollisionHull from provided array of vertices.
+ \param[in] vertexData Vertex array of some object, for which collision geometry should be built
+ \param[out] output Reference on CollisionHull object in which generated geometry should be saved
+ */
+ void buildCollisionGeometry(const std::vector<physx::PxVec3>& vertexData, CollisionHull& output);
+
+ /**
+ Method creates PxConvexMesh from provided array of vertices.
+ \param[in] vertexData Vertex array of some object, for which collision geometry should be built
+
+ \return pointer to the PxConvexMesh object if it was built successfully, 'nullptr' otherwise.
+ */
+ physx::PxConvexMesh* buildConvexMesh(std::vector<physx::PxVec3>& vertexData);
+
+
+ /**
+ Method creates PxConvexMesh from provided ConvexHull geometry
+ \param[in] hull ConvexHull geometry
+
+ \return pointer to the PxConvexMesh object if it was built successfully, 'nullptr' otherwise.
+ */
+ physx::PxConvexMesh* buildConvexMesh(CollisionHull& hull);
+
+
+ /**
+ Convex geometry trimming.
+ Using slicing with noised slicing surface can result in intersecting collision geometry.
+ It leads to unstable behaviour of rigid body simulation.
+ This method trims all intersecting parts of collision geometry.
+ As a drawback, trimming collision geometry can lead to penetrating render meshes during simulation.
+
+
+ \param[in] in ConvexHull geometry which should be clipped.
+ \param[in] chunkDepth Array of depth levels of convex hulls corresponding chunks.
+
+ */
+
+ void trimCollisionGeometry(std::vector<CollisionHull>& in, const std::vector<uint32_t>& chunkDepth);
+
+
+private:
+ physx::PxPhysicsInsertionCallback* mInsertionCallback;
+ physx::PxCooking* mCooking;
+};
+
+} // namespace Blast
+} // namespace Nv
+
+
+#endif // ifndef NVBLASTEXTAUTHORINGCOLLISIONBUILDER_H
diff --git a/sdk/extensions/authoring/include/NvBlastExtAuthoringFractureTool.h b/sdk/extensions/authoring/include/NvBlastExtAuthoringFractureTool.h
new file mode 100644
index 0000000..528ffbc
--- /dev/null
+++ b/sdk/extensions/authoring/include/NvBlastExtAuthoringFractureTool.h
@@ -0,0 +1,435 @@
+/*
+* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
+*
+* NVIDIA CORPORATION and its licensors retain all intellectual property
+* and proprietary rights in and to this software, related documentation
+* and any modifications thereto. Any use, reproduction, disclosure or
+* distribution of this software and related documentation without an express
+* license agreement from NVIDIA CORPORATION is strictly prohibited.
+*/
+
+#ifndef NVBLASTAUTHORINGFRACTURETOOL_H
+#define NVBLASTAUTHORINGFRACTURETOOL_H
+
+#include "NvBlastExtAuthoringMesh.h"
+#include "NvBlastTypes.h"
+
+
+namespace Nv
+{
+namespace Blast
+{
+
+class SpatialAccelerator;
+class ChunkPostProcessor;
+
+
+/*
+ Chunk data, chunk with chunkId == 0 is always source mesh.
+*/
+struct ChunkInfo
+{
+ Mesh* meshData;
+ int32_t parent;
+ int32_t chunkId;
+ bool isLeaf;
+};
+
+
+/*
+ Slicing fracturing configuration
+
+
+ default:
+ x_slices = 1;
+ y_slices = 1;
+ z_slices = 1;
+
+ offset_variations = 0.f;
+ angle_variations = 0.f;
+ noiseAmplitude = 0.f;
+ noiseFrequency = 1.f;
+ noiseOctaveNumber = 1;
+ surfaceResolution = 1;
+*/
+struct SlicingConfiguration
+{
+ /**
+ Number of slices in each direction
+ */
+ int32_t x_slices, y_slices, z_slices;
+
+ /**
+ Offset variation, value in [0, 1]
+ */
+ float offset_variations;
+ /**
+ Angle variation, value in [0, 1]
+ */
+ float angle_variations;
+
+
+ /**
+ Noisy slicing configutaion:
+
+ Amplitude of cutting surface noise. If it is 0 - noise is disabled.
+ */
+ float noiseAmplitude;
+ /**
+ Frequencey of cutting surface noise.
+ */
+ float noiseFrequency;
+ /**
+ Octave number in slicing surface noise.
+ */
+ uint32_t noiseOctaveNumber;
+ /**
+ Cutting surface resolution.
+ */
+ int32_t surfaceResolution;
+
+
+ SlicingConfiguration()
+ {
+ reset();
+ }
+ /**
+ Set default params.
+ */
+ void reset()
+ {
+ x_slices = 1;
+ y_slices = 1;
+ z_slices = 1;
+
+ offset_variations = 0.f;
+ angle_variations = 0.f;
+ noiseAmplitude = 0.f;
+ noiseFrequency = 1.f;
+ noiseOctaveNumber = 1;
+ surfaceResolution = 1;
+ }
+
+};
+
+
+
+/**
+ Class for voronoi sites generation inside supplied mesh.
+*/
+class VoronoiSitesGenerator
+{
+public:
+
+ /**
+ Voronoi sites should not be generated outside of the fractured mesh, so VoronoiSitesGenerator
+ should be supplied with fracture mesh.
+ \param[in] mesh Fracture mesh
+ \param[in] rnd User supplied random value generator.
+ \return
+ */
+ VoronoiSitesGenerator(Mesh* mesh, RandomGeneratorBase* rnd);
+ ~VoronoiSitesGenerator();
+
+ /**
+ Set base fracture mesh
+ */
+ void setBaseMesh(Mesh* m);
+
+ /**
+ Returns reference on vector of generated voronoi sites.
+ */
+ std::vector<physx::PxVec3>& getVoronoiSites();
+
+ /**
+ Add site in particular point
+ \param[in] site Site coordinates
+ */
+ void addSite(const physx::PxVec3& site);
+ /**
+ Uniformly generate sites inside the mesh
+ \param[in] numberOfSites Number of generated sites
+ */
+ void uniformlyGenerateSitesInMesh(const uint32_t numberOfSites);
+
+ /**
+ Generate sites in clustered fashion
+ \param[in] numberOfClusters Number of generated clusters
+ \param[in] sitesPerCluster Number of sites in each cluster
+ \param[in] clusterRadius Voronoi cells cluster radius
+ */
+ void clusteredSitesGeneration(const uint32_t numberOfClusters, const uint32_t sitesPerCluster, float clusterRadius);
+
+ /**
+ Radial pattern of sites generation
+ \param[in] center Center of generated pattern
+ \param[in] normal Normal to plane in which sites are generated
+ \param[in] radius Pattern radius
+ \param[in] angularSteps Number of angular steps
+ \param[in] radialSteps Number of radial steps
+ \param[in] angleOffset Angle offset at each radial step
+ \param[in] variability Randomness of sites distribution
+ */
+ 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);
+
+ /**
+ Generate sites inside sphere
+ \param[in] count Count of generated sites
+ \param[in] radius Radius of sphere
+ \param[in] center Center of sphere
+ */
+ void generateInSphere(const uint32_t count, const float radius, const physx::PxVec3& center);
+ /**
+ Set stencil mesh. With stencil mesh sites are generated only inside both of fracture and stencil meshes.
+ \param[in] stencil Stencil mesh.
+ */
+ void setStencil(Mesh* stencil);
+ /**
+ Removes stencil mesh
+ */
+ void clearStencil();
+
+ /**
+ Deletes sites inside supplied sphere
+ \param[in] radius Radius of sphere
+ \param[in] center Center of sphere
+ \param[in] eraserProbability Probability of removing some particular site
+ */
+ void deleteInSphere(const float radius, const physx::PxVec3& center, const float eraserProbability = 1);
+
+private:
+ std::vector<physx::PxVec3> mGeneratedSites;
+ Mesh* mMesh;
+ Mesh* mStencil;
+ RandomGeneratorBase* mRnd;
+ SpatialAccelerator* mAccelerator;
+};
+
+
+
+/**
+ FractureTool class provides methods to fracture provided mesh and generate Blast asset data
+*/
+class FractureTool
+{
+
+public:
+
+ /**
+ FractureTool can log asset creation info if logCallback is provided.
+ */
+ FractureTool(NvBlastLog logCallback = nullptr)
+ {
+ mPlaneIndexerOffset = 1;
+ mChunkIdCounter = 0;
+ mRemoveIslands = false;
+ mLoggingCallback = logCallback;
+ }
+
+ ~FractureTool()
+ {
+ reset();
+ }
+
+ /**
+ Reset FractureTool state.
+ */
+ void reset();
+
+
+ /**
+ Set input mesh wich will be fractured, FractureTool will be reseted.
+ */
+ void setSourceMesh(Mesh* mesh);
+
+ /**
+ Get chunk mesh in polygonal representation
+ */
+ Mesh getChunkMesh(int32_t chunkId);
+
+ /**
+ Input mesh is scaled and transformed internally to fit unit cube centered in origin.
+ Method provides offset vector and scale parameter;
+ */
+ void getTransformation(physx::PxVec3& offset, float& scale);
+
+
+ /**
+ Fractures specified chunk with voronoi method.
+ \param[in] chunkId Chunk to fracture
+ \param[in] cellPoints Array of voronoi sites
+ \param[in] replaceChunk if 'true', newly generated chunks will replace source chunk, if 'false', newly generated chunks will be at next depth level, source chunk will be parent for them.
+ Case replaceChunk == true && chunkId == 0 considered as wrong input parameters
+ \return If 0, fracturing is successful.
+ */
+ int32_t voronoiFracturing(uint32_t chunkId, const std::vector<physx::PxVec3>& cellPoints, bool replaceChunk);
+
+ /**
+ Fractures specified chunk with voronoi method. Cells can be scaled along x,y,z axes.
+ \param[in] chunkId Chunk to fracture
+ \param[in] cellPoints Array of voronoi sites
+ \param[in] cellPoints Array of voronoi sites
+ \param[in] scale Voronoi cells scaling factor
+ \param[in] replaceChunk if 'true', newly generated chunks will replace source chunk, if 'false', newly generated chunks will be at next depth level, source chunk will be parent for them.
+ Case replaceChunk == true && chunkId == 0 considered as wrong input parameters
+ \return If 0, fracturing is successful.
+ */
+ int32_t voronoiFracturing(uint32_t chunkId, const std::vector<physx::PxVec3>& cellPoints, const physx::PxVec3& scale, bool replaceChunk);
+
+
+ /**
+ Fractures specified chunk with slicing method.
+ \param[in] chunkId Chunk to fracture
+ \param[in] conf Slicing parameters, see SlicingConfiguration.
+ \param[in] replaceChunk if 'true', newly generated chunks will replace source chunk, if 'false', newly generated chunks will be at next depth level, source chunk will be parent for them.
+ Case replaceChunk == true && chunkId == 0 considered as wrong input parameters
+ \param[in] rnd User supplied random number generator
+
+ \return If 0, fracturing is successful.
+ */
+ int32_t slicing(uint32_t chunkId, SlicingConfiguration conf, bool replaceChunk, RandomGeneratorBase* rnd);
+
+
+ /**
+ Creates resulting fractured mesh geometry from intermediate format
+ */
+ void finalizeFracturing();
+
+ /**
+ Get chunk information
+ */
+ const std::vector<ChunkInfo>& getChunkList();
+
+
+ /**
+ Tesselate interior surfaces
+ \param[in] averageEdgeLength - Average length of edge on internal surface.
+ */
+ void tesselate(float averageEdgeLength);
+
+ /**
+ Apply noise to interior surfaces. Must be called only after tesselation!
+ \param[in] amplitude Amplitude of noise
+ \param[in] frequency Frequency of noise
+ \param[in] octaves Number of noise octaves
+ \param[in] falloff - damping of noise around of external surface
+ \param[in] relaxIterations - number of smoothing iterations before applying noise
+ \param[in] relaxFactor - amount of smoothing before applying noise.
+ \param[in] seed Random seed value
+ */
+ void applyNoise(float amplitude, float frequency, int32_t octaves, float falloff, int32_t relaxIterations, float relaxFactor, int32_t seed = 0);
+
+ /**
+ Get percentage of mesh overlap.
+ percentage computed as volume(intersection(meshA , meshB)) / volume (meshA)
+ \param[in] meshA Mesh A
+ \param[in] meshB Mesh B
+ \return mesh overlap percentage
+ */
+ static float getMeshOverlap(Mesh& meshA, Mesh& meshB);
+
+ /**
+ Get chunk base mesh
+ \param[in] chunkIndex Chunk index
+ \param[out] output Array of triangles to be filled
+ */
+ void getBaseMesh(int32_t chunkIndex, std::vector<Triangle>& output);
+
+ /**
+ Get chunk mesh with noise
+ \param[in] chunkIndex Chunk index
+ \param[out] output Array of triangles to be filled
+ */
+ void getNoisedMesh(int32_t chunkIndex, std::vector<Triangle>& output);
+
+
+ /**
+ Return index of chunk with specified chunkId
+ \param[in] chunkId Chunk ID
+ \return Chunk index in internal buffer, if not exist -1 is returned.
+ */
+ int32_t getChunkIndex(int32_t chunkId);
+
+ /**
+ Return id of chunk with specified index.
+ \param[in] chunkIndex Chunk index
+ \return Chunk id or -1 if there is no such chunk.
+ */
+ int32_t getChunkId(int32_t chunkIndex);
+
+ /**
+ Return depth level of the given chunk
+ \param[in] chunkId Chunk ID
+ \return Chunk depth or -1 if there is no such chunk.
+ */
+ int32_t getChunkDepth(int32_t chunkId);
+
+ /**
+ Return array of chunks IDs with given depth.
+ \param[in] depth Chunk depth
+ \return Array of chunk IDs
+ */
+ std::vector<int32_t> getChunksIdAtDepth(uint32_t depth);
+
+
+ /**
+ Get result geometry without noise as vertex and index buffers, where index buffers contain series of triplets
+ which represent triangles.
+ \param[out] vertexBuffer Array of vertices to be filled
+ \param[out] indexBuffer Array of arrays of indices to be filled
+ */
+ void getBufferedBaseMeshes(std::vector<Vertex>& vertexBuffer, std::vector<std::vector<uint32_t> >& indexBuffer);
+
+ /**
+ Get result geometry after tesselation and application of noise as vertex and index buffers, where index buffers contain series of triplets
+ which represent triangles.
+ \param[out] vertexBuffer Array of vertices to be filled
+ \param[out] indexBuffer Array of arrays of indices to be filled
+ */
+ void getBufferedNoiseMeshes(std::vector<Vertex>& vertexBuffer, std::vector<std::vector<uint32_t> >& indexBuffer);
+
+ /**
+ Set automatic islands removing. May cause instabilities.
+ \param[in] isRemoveIslands Flag whether remove or not islands.
+ */
+ void setRemoveIslands(bool isRemoveIslands);
+
+ /**
+ Try find islands and remove them on some specifical chunk. If chunk has childs, island removing can lead to wrong results! Apply it before further chunk splitting.
+ \param[in] chunkId Chunk ID which should be checked for islands
+ \return Number of found islands is returned
+ */
+ int32_t islandDetectionAndRemoving(int32_t chunkId);
+
+private:
+ void eraseChunk(int32_t chunkId);
+ bool isAncestorForChunk(int32_t ancestorId, int32_t chunkId);
+ void deleteAllChildsOfChunk(int32_t chunkId);
+ int32_t slicingNoisy(uint32_t chunkId, SlicingConfiguration conf, bool replaceChunk, RandomGeneratorBase* rnd);
+
+protected:
+ /**
+ Mesh scaled to unite-cube and translated to the origin
+ */
+ float mScaleFactor;
+ physx::PxVec3 mOffset;
+
+ /* Chunk mesh wrappers */
+ std::vector<ChunkPostProcessor*> mChunkPostprocessors;
+
+
+
+ int32_t mPlaneIndexerOffset;
+ int32_t mChunkIdCounter;
+ std::vector<ChunkInfo> mChunkData;
+
+ bool mRemoveIslands;
+
+ NvBlastLog mLoggingCallback;
+};
+
+} // namespace Blast
+} // namespace Nv
+
+
+#endif // ifndef NVBLASTAUTHORINGFRACTURETOOL_H
diff --git a/sdk/extensions/authoring/include/NvBlastExtAuthoringMesh.h b/sdk/extensions/authoring/include/NvBlastExtAuthoringMesh.h
new file mode 100644
index 0000000..2b1806a
--- /dev/null
+++ b/sdk/extensions/authoring/include/NvBlastExtAuthoringMesh.h
@@ -0,0 +1,174 @@
+/*
+* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
+*
+* NVIDIA CORPORATION and its licensors retain all intellectual property
+* and proprietary rights in and to this software, related documentation
+* and any modifications thereto. Any use, reproduction, disclosure or
+* distribution of this software and related documentation without an express
+* license agreement from NVIDIA CORPORATION is strictly prohibited.
+*/
+
+#ifndef NVBLASTAUTHORINGMESH_H
+#define NVBLASTAUTHORINGMESH_H
+
+#include "NvBlastExtAuthoringTypes.h"
+#include <vector>
+
+
+namespace Nv
+{
+namespace Blast
+{
+
+/**
+ Class for internal mesh representation
+*/
+class Mesh
+{
+public:
+
+ /**
+ Constructs mesh object from array of triangles.
+ \param[in] position Array of vertex positions
+ \param[in] normals Array of vertex normals
+ \param[in] uv Array of vertex uv coordinates
+ \param[in] verticesCount Vertices count
+ \param[in] indices Array of vertex indices. Indices contain vertex index triplets which form a mesh triangle.
+ \param[in] indicesCount Indices count (should be equal to numberOfTriangles * 3)
+ */
+ Mesh(physx::PxVec3* position, physx::PxVec3* normals, physx::PxVec2* uv, uint32_t verticesCount, uint32_t* indices, uint32_t indicesCount);
+
+ /**
+ Constructs mesh object from array of facets.
+ \param[in] vertices Array of vertices
+ \param[in] edges Array of edges
+ \param[in] facets Array of facets
+ \param[in] posCount Vertices count
+ \param[in] edgesCount Edges count
+ \param[in] facetsCount Facets count
+ */
+ Mesh(Vertex* vertices, Edge* edges, Facet* facets, uint32_t posCount, uint32_t edgesCount, uint32_t facetsCount);
+
+ ~Mesh();
+
+ /**
+ Return true if mesh is valid
+ */
+ bool isValid();
+
+ /**
+ Return pointer on vertices array
+ */
+ Vertex* getVertices();
+
+ /**
+ Return pointer on edges array
+ */
+ Edge* getEdges();
+
+ /**
+ Return pointer on facets array
+ */
+ Facet* getFacetsBuffer();
+
+ /**
+ Return pointer on specified facet
+ */
+ Facet* getFacet(int32_t facet);
+
+ /**
+ Return edges count
+ */
+ uint32_t getEdgesCount();
+
+ /**
+ Return vertices count
+ */
+ uint32_t getVerticesCount();
+
+ /**
+ Return facet count
+ */
+ uint32_t getFacetCount();
+
+ /**
+ Return reference on mesh bounding box.
+ */
+ physx::PxBounds3& getBoundingBox();
+
+ /**
+ Recalculate bounding box
+ */
+ void recalculateBoundingBox();
+
+ /**
+ Compute mesh volume. Can be used only for triangulated meshes.
+ Return mesh volume. If mesh is not triangulated return 0.
+ */
+ float getMeshVolume();
+
+private:
+ std::vector<Vertex> mVertices;
+ std::vector<Edge> mEdges;
+ std::vector<Facet> mFacets;
+ physx::PxBounds3 mBounds;
+};
+
+
+/**
+ Helper functions
+*/
+
+/**
+ Set cutting box at some particular position.
+ \param[in] point Cutting face center
+ \param[in] normal Cutting face normal
+ \param[in] mesh Cutting box mesh
+ \param[in] size Cutting box size
+ \param[in] id Cutting box ID
+*/
+void setCuttingBox(const physx::PxVec3& point, const physx::PxVec3& normal, Mesh* mesh, float size, int32_t id);
+/**
+ Create cutting box at some particular position.
+ \param[in] point Cutting face center
+ \param[in] normal Cutting face normal
+ \param[in] size Cutting box size
+ \param[in] id Cutting box ID
+*/
+Mesh* getCuttingBox(const physx::PxVec3& point, const physx::PxVec3& normal, float size, int32_t id);
+
+/**
+ Create box at some particular position.
+ \param[in] point Cutting face center
+ \param[in] size Cutting box size
+*/
+Mesh* getBigBox(const physx::PxVec3& point, float size);
+
+/**
+ Create slicing box with noisy cutting surface.
+ \param[in] point Cutting face center
+ \param[in] normal Cutting face normal
+ \param[in] size Cutting box size
+ \param[in] jaggedPlaneSize Noisy surface size
+ \param[in] resolution Noisy surface resolution
+ \param[in] id Cutting box ID
+ \param[in] amplitude Noise amplitude
+ \param[in] frequency Noise frequency
+ \param[in] octaves Noise octaves
+ \param[in] seed Random generator seed, used for noise generation.
+*/
+Mesh* getNoisyCuttingBoxPair(const physx::PxVec3& point, const physx::PxVec3& normal, float size, float jaggedPlaneSize, uint32_t resolution, int32_t id, float amplitude, float frequency, int32_t octaves, int32_t seed);
+
+
+/**
+ Inverses normals of cutting box and sets indices.
+ \param[in] mesh Cutting box mesh
+ \param[in] id Cutting box ID
+*/
+void inverseNormalAndSetIndices(Mesh* mesh, int32_t id);
+
+} // namespace Blast
+} // namespace Nv
+
+
+#endif // ifndef NVBLASTAUTHORINGMESH_H
diff --git a/sdk/extensions/authoring/include/NvBlastExtAuthoringTypes.h b/sdk/extensions/authoring/include/NvBlastExtAuthoringTypes.h
new file mode 100644
index 0000000..de28866
--- /dev/null
+++ b/sdk/extensions/authoring/include/NvBlastExtAuthoringTypes.h
@@ -0,0 +1,128 @@
+/*
+* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
+*
+* NVIDIA CORPORATION and its licensors retain all intellectual property
+* and proprietary rights in and to this software, related documentation
+* and any modifications thereto. Any use, reproduction, disclosure or
+* distribution of this software and related documentation without an express
+* license agreement from NVIDIA CORPORATION is strictly prohibited.
+*/
+
+#ifndef NVBLASTAUTHORINGTYPES_H
+#define NVBLASTAUTHORINGTYPES_H
+
+#include <PxVec3.h>
+#include <PxVec2.h>
+#include <PxBounds3.h>
+#include <algorithm>
+#include "NvBlastTypes.h"
+
+#define NOT_VALID_VERTEX INT32_MAX
+
+namespace Nv
+{
+namespace Blast
+{
+
+/**
+ Edge representation
+*/
+struct Edge
+{
+ uint32_t s, e;
+ Edge() : s(NOT_VALID_VERTEX), e(NOT_VALID_VERTEX){}
+ Edge(int s, int e) : s(s), e(e) {}
+ bool operator<(const Edge& b) const
+ {
+ if (s == b.s)
+ return e < b.e;
+ else
+ return s < b.s;
+ }
+};
+
+/**
+ Mesh vertex representation
+*/
+struct Vertex
+{
+ physx::PxVec3 p; // Position
+ physx::PxVec3 n; // Normal
+ physx::PxVec2 uv[1]; // UV-coordinates array, currently supported only one UV coordinate.
+};
+
+/**
+ Mesh triangle representation
+*/
+struct Triangle
+{
+ Triangle() {};
+ Triangle(Vertex a, Vertex b, Vertex c) : a(a), b(b), c(c) {};
+ Vertex a, b, c;
+ int32_t userInfo;
+ physx::PxVec3 getNormal()
+ {
+ return ((b.p - a.p).cross(c.p - a.p));
+ }
+};
+
+
+/**
+ Index based triangle
+*/
+struct TriangleIndexed
+{
+ TriangleIndexed() {};
+ TriangleIndexed(uint32_t a, uint32_t b, uint32_t c) : ea(a), eb(b), ec(c) {};
+
+ uint32_t getOpposite(uint32_t a, uint32_t b)
+ {
+ if (ea != a && ea != b)
+ return ea;
+ if (eb != a && eb != b)
+ return eb;
+ if (ec != a && ec != b)
+ return ec;
+ return NOT_VALID_VERTEX;
+ }
+
+ bool isContainEdge(uint32_t a, uint32_t b)
+ {
+ return (a == ea || a == eb || a == ec) && (b == ea || b == eb || b == ec);
+ }
+
+ uint32_t ea, eb, ec;
+ int32_t userInfo;
+};
+
+/**
+ Mesh facet representation
+*/
+struct Facet
+{
+ int32_t firstEdgeNumber;
+ uint32_t edgesCount;
+ int32_t userData;
+ Facet(int32_t fEdge = 0, uint32_t eCount = 0, int32_t userData = 0) : firstEdgeNumber(fEdge), edgesCount(eCount), userData(userData) {}
+};
+
+/**
+Abstract base class for user-defined random value generator.
+*/
+class RandomGeneratorBase
+{
+public:
+ // Generates uniformly distributed value in [0, 1] range.
+ virtual float getRandomValue() = 0;
+ // Seeds random value generator
+ virtual void seed(int32_t seed) = 0;
+ virtual ~RandomGeneratorBase() {};
+};
+
+
+
+} // namespace Blast
+} // namespace Nv
+
+
+#endif // ifndef NVBLASTAUTHORINGTYPES_H