FractureToolsStructs.h
Go to the documentation of this file.
00001 //
00002 // Redistribution and use in source and binary forms, with or without
00003 // modification, are permitted provided that the following conditions
00004 // are met:
00005 //  * Redistributions of source code must retain the above copyright
00006 //    notice, this list of conditions and the following disclaimer.
00007 //  * Redistributions in binary form must reproduce the above copyright
00008 //    notice, this list of conditions and the following disclaimer in the
00009 //    documentation and/or other materials provided with the distribution.
00010 //  * Neither the name of NVIDIA CORPORATION nor the names of its
00011 //    contributors may be used to endorse or promote products derived
00012 //    from this software without specific prior written permission.
00013 //
00014 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
00015 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00016 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00017 // PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
00018 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00019 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00020 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00021 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00022 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00023 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00024 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00025 //
00026 // Copyright (c) 2018 NVIDIA Corporation. All rights reserved.
00027 
00028 
00029 #ifndef FRACTURE_TOOLS_STRUCTS_H
00030 #define FRACTURE_TOOLS_STRUCTS_H
00031 
00032 #include "foundation/Px.h"
00033 #include "ExplicitHierarchicalMesh.h"
00034 
00035 PX_PUSH_PACK_DEFAULT
00036 
00037 namespace FractureTools
00038 {
00039 
00043 struct MeshProcessingParameters
00044 {
00049     bool islandGeneration;
00050 
00055     bool removeTJunctions;
00056 
00063     unsigned microgridSize;
00064 
00073     nvidia::BSPOpenMode::Enum meshMode;
00074 
00079     int verbosity;
00080 
00082     MeshProcessingParameters()
00083     {
00084         setToDefault();
00085     }
00086 
00088     void    setToDefault()
00089     {
00090         islandGeneration = false;
00091         removeTJunctions = false;
00092         microgridSize = 65536;
00093         meshMode = nvidia::BSPOpenMode::Automatic;
00094         verbosity = 0;
00095     }
00096 };
00097 
00098 
00108 class CutoutSet
00109 {
00110 public:
00112     virtual uint32_t                getCutoutCount() const = 0;
00113 
00118     virtual uint32_t                getCutoutVertexCount(uint32_t cutoutIndex) const = 0;
00119 
00124     virtual uint32_t                getCutoutLoopCount(uint32_t cutoutIndex) const = 0;
00125 
00130     virtual const physx::PxVec3&    getCutoutVertex(uint32_t cutoutIndex, uint32_t vertexIndex) const = 0;
00131 
00136     virtual uint32_t                getCutoutLoopSize(uint32_t coutoutIndex, uint32_t loopIndex) const = 0;
00137 
00143     virtual uint32_t                getCutoutLoopVertexIndex(uint32_t cutoutIndex, uint32_t loopIndex, uint32_t vertexNum) const = 0;
00144 
00150     virtual uint32_t                getCutoutLoopVertexFlags(uint32_t cutoutIndex, uint32_t loopIndex, uint32_t vertexNum) const = 0;
00151 
00155     virtual bool                    isPeriodic() const = 0;
00156 
00160     virtual const physx::PxVec2&    getDimensions() const = 0;
00161 
00163     //virtual void          serialize(physx::PxFileBuf& stream) const = 0;
00164     //virtual void          deserialize(physx::PxFileBuf& stream) = 0;
00165 
00167     virtual void                    release() = 0;
00168 
00169 protected:
00171     virtual                         ~CutoutSet() {}
00172 };
00173 
00174 
00179 struct NoiseParameters
00180 {
00184     float   amplitude;
00185 
00190     float   frequency;
00191 
00196     int     gridSize;
00197 
00203     int     type;
00204 
00206     NoiseParameters()
00207     {
00208         setToDefault();
00209     }
00210 
00219     void    setToDefault()
00220     {
00221         amplitude = 0.0f;
00222         frequency = 0.25f;
00223         gridSize = 10;
00224         type = 0;
00225     }
00226 };
00227 
00228 
00234 struct SliceParameters
00235 {
00240     enum Order
00241     {
00242         XYZ,
00243         YZX,
00244         ZXY,
00245         ZYX,
00246         YXZ,
00247         XZY,
00248         Through
00249     };
00250 
00252     unsigned order;
00253 
00255     unsigned splitsPerPass[3];
00256 
00263     float linearVariation[3];
00264 
00270     float angularVariation[3];
00271 
00273     NoiseParameters noise[3];
00274 
00276     SliceParameters()
00277     {
00278         setToDefault();
00279     }
00280 
00290     void    setToDefault()
00291     {
00292         order = XYZ;
00293         splitsPerPass[0] = splitsPerPass[1] = splitsPerPass[2] = 1;
00294         linearVariation[0] = linearVariation[1] = linearVariation[2] = 0.1f;
00295         angularVariation[0] = angularVariation[1] = angularVariation[2] = 20.0f * 3.1415927f / 180.0f;
00296         noise[0].setToDefault();
00297         noise[1].setToDefault();
00298         noise[2].setToDefault();
00299     }
00300 };
00301 
00302 
00308 struct FractureSliceDesc
00309 {
00311     unsigned                        maxDepth;
00312 
00314     SliceParameters*                sliceParameters;
00315 
00319     bool                            useTargetProportions;
00320 
00328     float                           targetProportions[3];
00329 
00336     float                           minimumChunkSize[3];
00337 
00341     nvidia::FractureMaterialDesc    materialDesc[3];
00342 
00346     bool                            instanceChunks;
00347 
00351     bool                            useDisplacementMaps;
00352 
00354     enum NoiseMode
00355     {
00356         NoiseWavePlane = 0,
00357         NoisePerlin2D,
00358         NoisePerlin3D,
00359 
00360         NoiseModeCount
00361     };
00362 
00366     unsigned            noiseMode;
00367 
00369     FractureSliceDesc()
00370     {
00371         setToDefault();
00372     }
00373 
00387     void    setToDefault()
00388     {
00389         maxDepth             = 0;
00390         sliceParameters      = NULL;
00391         useTargetProportions = false;
00392         for (int i = 0; i < 3; ++i)
00393         {
00394             targetProportions[i] = 1.0f;
00395             minimumChunkSize[i] = 0.0f;
00396             materialDesc[i].setToDefault();
00397         }
00398         instanceChunks       = false;
00399         useDisplacementMaps  = false;
00400         noiseMode            = NoiseWavePlane;
00401     }
00402 };
00403 
00404 
00410 struct CutoutParameters
00411 {
00416     float depth;
00417 
00423     nvidia::FractureMaterialDesc materialDesc;
00424 
00430     NoiseParameters backfaceNoise;
00431 
00440     NoiseParameters edgeNoise;
00441 
00443     CutoutParameters()
00444     {
00445         setToDefault();
00446     }
00447 
00456     void    setToDefault()
00457     {
00458         depth = 1.0f;
00459         backfaceNoise.setToDefault();
00460         materialDesc.setToDefault();
00461         edgeNoise.setToDefault();
00462     }
00463 };
00464 
00465 
00471 struct FractureCutoutDesc
00472 {
00474     enum Directions
00475     {
00476         UserDefined = 0,    // If no flags are set, the cutout direction is taken from userDefinedDirection
00477 
00478         NegativeX = 1 << 0,
00479         PositiveX = 1 << 1,
00480         NegativeY = 1 << 2,
00481         PositiveY = 1 << 3,
00482         NegativeZ = 1 << 4,
00483         PositiveZ = 1 << 5,
00484 
00485         DirectionCount = 6
00486     };
00487 
00489     unsigned directions;
00490 
00495     unsigned directionOrder[DirectionCount];
00496 
00498     CutoutParameters cutoutParameters[DirectionCount];
00499 
00504     physx::PxVec3 userDefinedDirection;
00505 
00507     physx::PxMat33 userUVMapping;
00508 
00510     CutoutParameters userDefinedCutoutParameters;
00511 
00513     enum InstancingMode
00514     {
00515         DoNotInstance,
00516         InstanceCongruentChunks,
00517         InstanceAllChunks,
00518 
00519         InstanceModeCount
00520     };
00521 
00525     unsigned instancingMode;
00526 
00530     bool tileFractureMap;
00531 
00535     physx::PxVec2 uvTileSize;
00536 
00540     bool splitNonconvexRegions;
00541 
00546     enum CutoutChunkFracturingMethod
00547     {
00548         DoNotFractureCutoutChunks,
00549         SliceFractureCutoutChunks,
00550         VoronoiFractureCutoutChunks,
00551 
00552         CutoutChunkFracturingMethodCount
00553     };
00554 
00563     unsigned chunkFracturingMethod;
00564 
00572     bool trimFaceCollisionHulls;
00573 
00575     float cutoutWidthScale[DirectionCount];
00576 
00578     float cutoutHeightScale[DirectionCount];
00579 
00581     float cutoutWidthOffset[DirectionCount];
00582 
00584     float cutoutHeightOffset[DirectionCount];
00585 
00587     bool cutoutWidthInvert[DirectionCount];
00588 
00590     bool cutoutHeightInvert[DirectionCount];
00591 
00593     float cutoutSizeX;
00594 
00596     float cutoutSizeY;
00597 
00604     float facetNormalMergeThresholdAngle;
00605 
00607     FractureCutoutDesc()
00608     {
00609         setToDefault();
00610     }
00611 
00638     void    setToDefault()
00639     {
00640         directions          = 0;
00641         userDefinedDirection= physx::PxVec3(0.0f);
00642         userUVMapping       = physx::PxMat33(physx::PxIdentity);
00643         userDefinedCutoutParameters.setToDefault();
00644         instancingMode      = DoNotInstance;
00645         tileFractureMap     = false;
00646         uvTileSize          = physx::PxVec2(0.0f);
00647         for (uint32_t i = 0; i < DirectionCount; ++i)
00648         {
00649             directionOrder[i]     = 1u << i;
00650             cutoutParameters[i].setToDefault();
00651             cutoutWidthScale[i]   = 1.0f;
00652             cutoutHeightScale[i]  = 1.0f;
00653             cutoutWidthOffset[i]  = 0.0f;
00654             cutoutHeightOffset[i] = 0.0f;
00655             cutoutWidthInvert[i]  = false;
00656             cutoutHeightInvert[i] = false;
00657         }
00658         cutoutSizeX                    = 1.0f;
00659         cutoutSizeY                    = 1.0f;
00660         facetNormalMergeThresholdAngle = 60.0f;
00661         splitNonconvexRegions          = false;
00662         chunkFracturingMethod          = DoNotFractureCutoutChunks;
00663         trimFaceCollisionHulls         = true;
00664     }
00665 };
00666 
00667 
00673 struct FractureVoronoiDesc
00674 {
00678     unsigned                siteCount;
00679 
00683     const physx::PxVec3*    sites;
00684 
00689     const uint32_t*         chunkIndices;
00690 
00698     NoiseParameters         faceNoise;
00699 
00703     bool                    instanceChunks;
00704 
00708     bool                    useDisplacementMaps;
00709 
00711     enum NoiseMode
00712     {
00713         NoiseWavePlane = 0,
00714         NoisePerlin2D,
00715         NoisePerlin3D,
00716 
00717         NoiseModeCount
00718     };
00719 
00723     unsigned                noiseMode;
00724 
00731     float                   minimumChunkSize;
00732 
00737     nvidia::FractureMaterialDesc    materialDesc;
00738 
00739 
00741     FractureVoronoiDesc()
00742     {
00743         setToDefault();
00744     }
00745 
00759     void    setToDefault()
00760     {
00761         siteCount = 0;
00762         sites = NULL;
00763         chunkIndices = NULL;
00764         faceNoise.setToDefault();
00765         instanceChunks = false;
00766         useDisplacementMaps = false;
00767         noiseMode = NoiseWavePlane;
00768         minimumChunkSize = 0.0f;
00769         materialDesc.setToDefault();
00770     }
00771 };
00772 
00773 
00774 } // namespace FractureTools
00775 
00776 
00777 PX_POP_PACK
00778 
00779 #endif // FRACTURE_TOOLS_H

Generated on Sat Dec 1 2018 15:51:53

Copyright © 2012-2018 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved.