APEX Framework: DestructibleActor.h Source File

NVIDIA APEX

DestructibleActor.h
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 
00012 #ifndef DESTRUCTIBLE_ACTOR_H
00013 #define DESTRUCTIBLE_ACTOR_H
00014 
00015 #include "foundation/Px.h"
00016 #include "Actor.h"
00017 #include "Renderable.h"
00018 #include "ModuleDestructible.h"
00019 #include "PxForceMode.h"
00020 
00021 namespace physx
00022 {
00023     class PxRigidDynamic;
00024 };
00025 
00026 #define DESTRUCTIBLE_ACTOR_TYPE_NAME "DestructibleActor"
00027 
00028 namespace nvidia
00029 {
00030 namespace apex
00031 {
00032 
00033 PX_PUSH_PACK_DEFAULT
00034 
00035 struct DestructibleParameters;
00036 class RenderVolume;
00037 class EmitterActor;
00038 class DestructibleRenderable;
00039 class DestructibleBehaviorGroupDesc;
00040 
00041 
00045 struct DestructibleEmitterType
00046 {
00050     enum Enum
00051     {
00052         Crumble,
00053         Dust,   // Note: this is a placeholder.  Its implementation has been removed in 1.2.0, and will be restored in later versions.
00054         Count
00055     };
00056 };
00057 
00061 struct DestructibleParameterizedType
00062 {
00066     enum Enum
00067     {
00068         State,  // The full state of the actor (including params, chunk data, etc...)
00069         Params, // The parameters used to initialize the actor
00070     };
00071 };
00072 
00076 struct DestructibleHitChunk
00077 {
00078     uint32_t chunkIndex;    
00079     uint32_t hitChunkFlags; 
00080 };
00081 
00085 struct DestructibleActorSyncFlags
00086 {
00090     enum Enum
00091     {
00092         None                = 0,
00093         CopyDamageEvents    = (1 << 0),
00094         ReadDamageEvents    = (1 << 1),
00095         CopyFractureEvents  = (1 << 2),
00096         ReadFractureEvents  = (1 << 3),
00097         CopyChunkTransform  = (1 << 4),
00098         ReadChunkTransform  = (1 << 5),
00099         Last                = (1 << 6),
00100     };
00101 };
00102 
00106 struct DestructiblePhysXActorQueryFlags
00107 {
00111     enum Enum
00112     {
00113         None = 0,
00114 
00115         // Actor states
00116         Static = (1 << 0),  
00117         Dynamic = (1 << 1), 
00118         Dormant = (1 << 2), 
00119 
00120         AllStates = Static | Dynamic | Dormant,
00121 
00122         // Other filters
00129         AllowRedundancy = (1 << 3),
00130 
00134         AllowActorsNotInScenes = (1 << 4)
00135     };
00136 };
00137 
00141 struct DestructibleActorSyncState
00142 {
00143     uint32_t    damageEventFilterDepth;     
00144     uint32_t    fractureEventFilterDepth;   
00145 };
00146 
00150 struct DestructibleChunkSyncState
00151 {
00152     bool        disableTransformBuffering;  
00153     bool        excludeSleepingChunks;      
00154     uint32_t    chunkTransformCopyDepth;    
00155 };
00156 
00161 struct DestructibleActorChunkFlags
00162 {
00166     enum Enum
00167     {
00172         ChunkIsWorldSupported   =   (1<<0),
00173     };
00174 };
00175 
00179 class DestructibleActor : public Actor, public Renderable
00180 #if PX_PHYSICS_VERSION_MAJOR == 3
00181     , public ActorSource
00182 #endif
00183 {
00184 public:
00188     virtual const RenderMeshActor*  getRenderMeshActor(DestructibleActorMeshType::Enum type = DestructibleActorMeshType::Skinned) const = 0;
00189 
00193     virtual const DestructibleParameters& getDestructibleParameters() const = 0;
00194 
00198     virtual void                    setDestructibleParameters(const DestructibleParameters& destructibleParameters) = 0;
00199 
00203     virtual PxMat44                 getInitialGlobalPose() const = 0;
00204 
00208     virtual void                    setInitialGlobalPose(const PxMat44& pose) = 0;
00209 
00213     virtual PxVec3                  getScale() const = 0;
00214 
00218     virtual bool                    isInitiallyDynamic() const = 0;
00219 
00227     virtual void                    getChunkVisibilities(uint8_t* visibilityArray, uint32_t visibilityArraySize) const = 0;
00228 
00232     virtual uint32_t                getNumVisibleChunks() const = 0;
00233 
00237     virtual const uint16_t*         getVisibleChunks() const = 0;
00238 
00249     virtual bool                    acquireChunkEventBuffer(const nvidia::DestructibleChunkEvent*& buffer, uint32_t& bufferSize) = 0;
00250 
00257     virtual bool                    releaseChunkEventBuffer(bool clearBuffer = true) = 0;
00258 
00271     virtual bool                    acquirePhysXActorBuffer(physx::PxRigidDynamic**& buffer, uint32_t& bufferSize, uint32_t flags = DestructiblePhysXActorQueryFlags::AllStates) = 0;
00272 
00279     virtual bool                    releasePhysXActorBuffer() = 0;
00280 
00289     virtual physx::PxRigidDynamic*  getChunkPhysXActor(uint32_t chunkIndex) = 0;
00290 
00301     virtual uint32_t                getChunkPhysXShapes(physx::PxShape**& shapes, uint32_t chunkIndex) const = 0;
00302 
00312     virtual PxTransform             getChunkPose(uint32_t chunkIndex) const = 0;
00313 
00323     virtual PxTransform             getChunkTransform(uint32_t chunkIndex) const = 0;
00324 
00330     virtual PxVec3                  getChunkLinearVelocity(uint32_t chunkIndex) const = 0;
00331 
00337     virtual PxVec3                  getChunkAngularVelocity(uint32_t chunkIndex) const = 0;
00338 
00345     virtual const PxMat44           getChunkTM(uint32_t chunkIndex) const = 0;
00346 
00354     virtual int32_t                 getChunkBehaviorGroupIndex(uint32_t chunkIndex) const = 0;
00355 
00362     virtual uint32_t                getChunkActorFlags(uint32_t chunkIndex) const = 0;
00363 
00370     virtual void                    setGlobalPose(const PxMat44& pose) = 0;
00371 
00378     virtual bool                    getGlobalPose(PxMat44& pose) = 0;
00379 
00383     virtual void                    setLinearVelocity(const PxVec3& linearVelocity) = 0;
00384 
00388     virtual void                    setAngularVelocity(const PxVec3& angularVelocity) = 0;
00389 
00395     virtual void                    setDynamic(int32_t chunkIndex = ModuleDestructibleConst::INVALID_CHUNK_INDEX) = 0;
00396 
00400     virtual bool                    isDynamic(uint32_t chunkIndex) const = 0;
00401 
00407     virtual void                    enableHardSleeping() = 0;
00408 
00413     virtual void                    disableHardSleeping(bool wake = false)= 0;
00414 
00418     virtual bool                    isHardSleepingEnabled() const = 0;
00419 
00428     virtual bool                    setChunkPhysXActorAwakeState(uint32_t chunkIndex, bool awake) = 0;
00429 
00441     virtual bool                    addForce(uint32_t chunkIndex, const PxVec3& force, physx::PxForceMode::Enum mode, const PxVec3* position = NULL, bool wakeup = true) = 0;
00442 
00446     virtual void                    setSkinnedOverrideMaterial(uint32_t submeshIndex, const char* overrideMaterialName) = 0;
00447 
00451     virtual void                    setStaticOverrideMaterial(uint32_t submeshIndex, const char* overrideMaterialName) = 0;
00452 
00456     virtual void                    setRuntimeFractureOverridePattern(const char* overridePatternName) = 0;
00457 
00474     virtual void                    applyDamage(float damage, float momentum, const PxVec3& position, const PxVec3& direction, int32_t chunkIndex = ModuleDestructibleConst::INVALID_CHUNK_INDEX, void* damageUserData = NULL) = 0;
00475 
00489     virtual void                    applyRadiusDamage(float damage, float momentum, const PxVec3& position, float radius, bool falloff, void* damageUserData = NULL) = 0;
00490 
00495     virtual void                    takeImpact(const PxVec3& force, const PxVec3& position, uint16_t chunkIndex, PxActor const* damageImpactActor) = 0;
00496 
00512     virtual int32_t                 rayCast(float& time, PxVec3& normal, const PxVec3& worldRayOrig, const PxVec3& worldRayDir, DestructibleActorRaycastFlags::Enum flags, int32_t parentChunkIndex = ModuleDestructibleConst::INVALID_CHUNK_INDEX) const = 0;
00513 
00528     virtual int32_t                 obbSweep(float& time, PxVec3& normal, const PxVec3& worldBoxCenter, const PxVec3& worldBoxExtents, const PxMat33& worldBoxRot, const PxVec3& worldDisplacement, DestructibleActorRaycastFlags::Enum flags) const = 0;
00529 
00533     virtual void                    setCrumbleEmitterState(bool enable) = 0;
00534 
00539     virtual void                    setDustEmitterState(bool enable) = 0;
00540 
00545     virtual void                    setPreferredRenderVolume(RenderVolume* volume, DestructibleEmitterType::Enum type) = 0;
00546 
00547 
00552     virtual EmitterActor*           getApexEmitter(DestructibleEmitterType::Enum type) = 0;
00553 
00558     virtual bool                    recreateApexEmitter(DestructibleEmitterType::Enum type) = 0;
00559 
00565     virtual const ::NvParameterized::Interface* getNvParameterized(DestructibleParameterizedType::Enum type = DestructibleParameterizedType::State) const = 0;
00566 
00572     virtual void                    setNvParameterized(::NvParameterized::Interface*) = 0;
00573 
00593     virtual bool                    setSyncParams(uint32_t userActorID, uint32_t actorSyncFlags = 0, const DestructibleActorSyncState * actorSyncState = NULL, const DestructibleChunkSyncState * chunkSyncState = NULL) = 0;
00594 
00607     virtual bool                    setHitChunkTrackingParams(bool flushHistory, bool startTracking, uint32_t trackingDepth, bool trackAllChunks = true) = 0;
00608 
00614     virtual bool                    getHitChunkHistory(const DestructibleHitChunk *& hitChunkContainer, uint32_t & hitChunkCount) const = 0;
00615 
00626     virtual bool                    forceChunkHits(const DestructibleHitChunk * hitChunkContainer, uint32_t hitChunkCount, bool removeChunks = true, bool deferredEvent = false, PxVec3 damagePosition = PxVec3(0.0f), PxVec3 damageDirection = PxVec3(0.0f)) = 0;
00627 
00633     virtual bool                    getDamageColoringHistory(const DamageEventCoreData *& damageEventCoreDataContainer, uint32_t & damageEventCoreDataCount) const = 0;
00634 
00643     virtual bool                    forceDamageColoring(const DamageEventCoreData * damageEventCoreDataContainer, uint32_t damageEventCoreDataCount) = 0;
00644 
00648     virtual PxBounds3               getLocalBounds() const = 0;
00649 
00653     virtual PxBounds3               getOriginalBounds() const = 0;
00654 
00658     virtual bool                    isChunkSolitary(int32_t chunkIndex) const = 0;
00659 
00663     virtual PxBounds3               getChunkBounds(uint32_t chunkIndex) const = 0;
00664 
00668     virtual PxBounds3               getChunkLocalBounds(uint32_t chunkIndex) const = 0;
00669 
00673     virtual bool                    isChunkDestroyed(int32_t chunkIndex) const = 0;
00674 
00678     virtual uint32_t                getSupportDepthChunkIndices(uint32_t* const OutChunkIndices, uint32_t MaxOutIndices) const = 0;
00679 
00683     virtual uint32_t                getSupportDepth() const = 0;
00684 
00688     virtual void                    setDeleteFracturedChunks(bool inDeleteChunkMode) = 0;
00689 
00695     virtual DestructibleRenderable* acquireRenderableReference() = 0;
00696 
00702     virtual uint32_t                getCustomBehaviorGroupCount() const = 0;
00703 
00710     virtual bool                    getBehaviorGroup(nvidia::DestructibleBehaviorGroupDesc& behaviorGroupDesc, int32_t index = -1) const = 0;
00711 
00712 protected:
00713     virtual                         ~DestructibleActor() {}
00714 };
00715 
00716 PX_POP_PACK
00717 
00718 }
00719 } // end namespace nvidia
00720 
00721 #endif // DESTRUCTIBLE_ACTOR_H

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