APEX Destructible Module: FractureToolsStructs.h Source File

NVIDIA APEX

FractureToolsStructs.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008-2017, NVIDIA CORPORATION.  All rights reserved.
00003  *
00004  * NVIDIA CORPORATION and its licensors retain all intellectual property
00005  * and proprietary rights in and to this software, related documentation
00006  * and any modifications thereto.  Any use, reproduction, disclosure or
00007  * distribution of this software and related documentation without an express
00008  * license agreement from NVIDIA CORPORATION is strictly prohibited.
00009  */
00010 
00011 #ifndef FRACTURE_TOOLS_STRUCTS_H
00012 #define FRACTURE_TOOLS_STRUCTS_H
00013 
00014 #include "foundation/Px.h"
00015 #include "ExplicitHierarchicalMesh.h"
00016 
00017 PX_PUSH_PACK_DEFAULT
00018 
00019 namespace FractureTools
00020 {
00021 
00025 struct MeshProcessingParameters
00026 {
00031     bool islandGeneration;
00032 
00037     bool removeTJunctions;
00038 
00045     unsigned microgridSize;
00046 
00055     nvidia::BSPOpenMode::Enum meshMode;
00056 
00061     int verbosity;
00062 
00064     MeshProcessingParameters()
00065     {
00066         setToDefault();
00067     }
00068 
00070     void    setToDefault()
00071     {
00072         islandGeneration = false;
00073         removeTJunctions = false;
00074         microgridSize = 65536;
00075         meshMode = nvidia::BSPOpenMode::Automatic;
00076         verbosity = 0;
00077     }
00078 };
00079 
00080 
00090 class CutoutSet
00091 {
00092 public:
00094     virtual uint32_t                getCutoutCount() const = 0;
00095 
00100     virtual uint32_t                getCutoutVertexCount(uint32_t cutoutIndex) const = 0;
00101 
00106     virtual uint32_t                getCutoutLoopCount(uint32_t cutoutIndex) const = 0;
00107 
00112     virtual const physx::PxVec3&    getCutoutVertex(uint32_t cutoutIndex, uint32_t vertexIndex) const = 0;
00113 
00118     virtual uint32_t                getCutoutLoopSize(uint32_t coutoutIndex, uint32_t loopIndex) const = 0;
00119 
00125     virtual uint32_t                getCutoutLoopVertexIndex(uint32_t cutoutIndex, uint32_t loopIndex, uint32_t vertexNum) const = 0;
00126 
00132     virtual uint32_t                getCutoutLoopVertexFlags(uint32_t cutoutIndex, uint32_t loopIndex, uint32_t vertexNum) const = 0;
00133 
00137     virtual bool                    isPeriodic() const = 0;
00138 
00142     virtual const physx::PxVec2&    getDimensions() const = 0;
00143 
00145     //virtual void          serialize(physx::PxFileBuf& stream) const = 0;
00146     //virtual void          deserialize(physx::PxFileBuf& stream) = 0;
00147 
00149     virtual void                    release() = 0;
00150 
00151 protected:
00153     virtual                         ~CutoutSet() {}
00154 };
00155 
00156 
00161 struct NoiseParameters
00162 {
00166     float   amplitude;
00167 
00172     float   frequency;
00173 
00178     int     gridSize;
00179 
00185     int     type;
00186 
00188     NoiseParameters()
00189     {
00190         setToDefault();
00191     }
00192 
00201     void    setToDefault()
00202     {
00203         amplitude = 0.0f;
00204         frequency = 0.25f;
00205         gridSize = 10;
00206         type = 0;
00207     }
00208 };
00209 
00210 
00216 struct SliceParameters
00217 {
00222     enum Order
00223     {
00224         XYZ,
00225         YZX,
00226         ZXY,
00227         ZYX,
00228         YXZ,
00229         XZY,
00230         Through
00231     };
00232 
00234     unsigned order;
00235 
00237     unsigned splitsPerPass[3];
00238 
00245     float linearVariation[3];
00246 
00252     float angularVariation[3];
00253 
00255     NoiseParameters noise[3];
00256 
00258     SliceParameters()
00259     {
00260         setToDefault();
00261     }
00262 
00272     void    setToDefault()
00273     {
00274         order = XYZ;
00275         splitsPerPass[0] = splitsPerPass[1] = splitsPerPass[2] = 1;
00276         linearVariation[0] = linearVariation[1] = linearVariation[2] = 0.1f;
00277         angularVariation[0] = angularVariation[1] = angularVariation[2] = 20.0f * 3.1415927f / 180.0f;
00278         noise[0].setToDefault();
00279         noise[1].setToDefault();
00280         noise[2].setToDefault();
00281     }
00282 };
00283 
00284 
00290 struct FractureSliceDesc
00291 {
00293     unsigned                        maxDepth;
00294 
00296     SliceParameters*                sliceParameters;
00297 
00301     bool                            useTargetProportions;
00302 
00310     float                           targetProportions[3];
00311 
00318     float                           minimumChunkSize[3];
00319 
00323     nvidia::FractureMaterialDesc    materialDesc[3];
00324 
00328     bool                            instanceChunks;
00329 
00333     bool                            useDisplacementMaps;
00334 
00336     enum NoiseMode
00337     {
00338         NoiseWavePlane = 0,
00339         NoisePerlin2D,
00340         NoisePerlin3D,
00341 
00342         NoiseModeCount
00343     };
00344 
00348     unsigned            noiseMode;
00349 
00351     FractureSliceDesc()
00352     {
00353         setToDefault();
00354     }
00355 
00369     void    setToDefault()
00370     {
00371         maxDepth             = 0;
00372         sliceParameters      = NULL;
00373         useTargetProportions = false;
00374         for (int i = 0; i < 3; ++i)
00375         {
00376             targetProportions[i] = 1.0f;
00377             minimumChunkSize[i] = 0.0f;
00378             materialDesc[i].setToDefault();
00379         }
00380         instanceChunks       = false;
00381         useDisplacementMaps  = false;
00382         noiseMode            = NoiseWavePlane;
00383     }
00384 };
00385 
00386 
00392 struct CutoutParameters
00393 {
00398     float depth;
00399 
00405     nvidia::FractureMaterialDesc materialDesc;
00406 
00412     NoiseParameters backfaceNoise;
00413 
00422     NoiseParameters edgeNoise;
00423 
00425     CutoutParameters()
00426     {
00427         setToDefault();
00428     }
00429 
00438     void    setToDefault()
00439     {
00440         depth = 1.0f;
00441         backfaceNoise.setToDefault();
00442         materialDesc.setToDefault();
00443         edgeNoise.setToDefault();
00444     }
00445 };
00446 
00447 
00453 struct FractureCutoutDesc
00454 {
00456     enum Directions
00457     {
00458         UserDefined = 0,    // If no flags are set, the cutout direction is taken from userDefinedDirection
00459 
00460         NegativeX = 1 << 0,
00461         PositiveX = 1 << 1,
00462         NegativeY = 1 << 2,
00463         PositiveY = 1 << 3,
00464         NegativeZ = 1 << 4,
00465         PositiveZ = 1 << 5,
00466 
00467         DirectionCount = 6
00468     };
00469 
00471     unsigned directions;
00472 
00477     unsigned directionOrder[DirectionCount];
00478 
00480     CutoutParameters cutoutParameters[DirectionCount];
00481 
00486     physx::PxVec3 userDefinedDirection;
00487 
00489     physx::PxMat33 userUVMapping;
00490 
00492     CutoutParameters userDefinedCutoutParameters;
00493 
00495     enum InstancingMode
00496     {
00497         DoNotInstance,
00498         InstanceCongruentChunks,
00499         InstanceAllChunks,
00500 
00501         InstanceModeCount
00502     };
00503 
00507     unsigned instancingMode;
00508 
00512     bool tileFractureMap;
00513 
00517     physx::PxVec2 uvTileSize;
00518 
00522     bool splitNonconvexRegions;
00523 
00528     enum CutoutChunkFracturingMethod
00529     {
00530         DoNotFractureCutoutChunks,
00531         SliceFractureCutoutChunks,
00532         VoronoiFractureCutoutChunks,
00533 
00534         CutoutChunkFracturingMethodCount
00535     };
00536 
00545     unsigned chunkFracturingMethod;
00546 
00554     bool trimFaceCollisionHulls;
00555 
00557     float cutoutWidthScale[DirectionCount];
00558 
00560     float cutoutHeightScale[DirectionCount];
00561 
00563     float cutoutWidthOffset[DirectionCount];
00564 
00566     float cutoutHeightOffset[DirectionCount];
00567 
00569     bool cutoutWidthInvert[DirectionCount];
00570 
00572     bool cutoutHeightInvert[DirectionCount];
00573 
00575     float cutoutSizeX;
00576 
00578     float cutoutSizeY;
00579 
00586     float facetNormalMergeThresholdAngle;
00587 
00589     FractureCutoutDesc()
00590     {
00591         setToDefault();
00592     }
00593 
00620     void    setToDefault()
00621     {
00622         directions          = 0;
00623         userDefinedDirection= physx::PxVec3(0.0f);
00624         userUVMapping       = physx::PxMat33(physx::PxIdentity);
00625         userDefinedCutoutParameters.setToDefault();
00626         instancingMode      = DoNotInstance;
00627         tileFractureMap     = false;
00628         uvTileSize          = physx::PxVec2(0.0f);
00629         for (uint32_t i = 0; i < DirectionCount; ++i)
00630         {
00631             directionOrder[i]     = 1u << i;
00632             cutoutParameters[i].setToDefault();
00633             cutoutWidthScale[i]   = 1.0f;
00634             cutoutHeightScale[i]  = 1.0f;
00635             cutoutWidthOffset[i]  = 0.0f;
00636             cutoutHeightOffset[i] = 0.0f;
00637             cutoutWidthInvert[i]  = false;
00638             cutoutHeightInvert[i] = false;
00639         }
00640         cutoutSizeX                    = 1.0f;
00641         cutoutSizeY                    = 1.0f;
00642         facetNormalMergeThresholdAngle = 60.0f;
00643         splitNonconvexRegions          = false;
00644         chunkFracturingMethod          = DoNotFractureCutoutChunks;
00645         trimFaceCollisionHulls         = true;
00646     }
00647 };
00648 
00649 
00655 struct FractureVoronoiDesc
00656 {
00660     unsigned                siteCount;
00661 
00665     const physx::PxVec3*    sites;
00666 
00671     const uint32_t*         chunkIndices;
00672 
00680     NoiseParameters         faceNoise;
00681 
00685     bool                    instanceChunks;
00686 
00690     bool                    useDisplacementMaps;
00691 
00693     enum NoiseMode
00694     {
00695         NoiseWavePlane = 0,
00696         NoisePerlin2D,
00697         NoisePerlin3D,
00698 
00699         NoiseModeCount
00700     };
00701 
00705     unsigned                noiseMode;
00706 
00713     float                   minimumChunkSize;
00714 
00719     nvidia::FractureMaterialDesc    materialDesc;
00720 
00721 
00723     FractureVoronoiDesc()
00724     {
00725         setToDefault();
00726     }
00727 
00741     void    setToDefault()
00742     {
00743         siteCount = 0;
00744         sites = NULL;
00745         chunkIndices = NULL;
00746         faceNoise.setToDefault();
00747         instanceChunks = false;
00748         useDisplacementMaps = false;
00749         noiseMode = NoiseWavePlane;
00750         minimumChunkSize = 0.0f;
00751         materialDesc.setToDefault();
00752     }
00753 };
00754 
00755 
00756 } // namespace FractureTools
00757 
00758 
00759 PX_POP_PACK
00760 
00761 #endif // FRACTURE_TOOLS_H

Generated on Fri Dec 15 2017 13:58:22
Copyright © 2012-2017 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved.