diff options
| author | git perforce import user <a@b> | 2016-10-25 12:29:14 -0600 |
|---|---|---|
| committer | Sheikh Dawood Abdul Ajees <Sheikh Dawood Abdul Ajees> | 2016-10-25 18:56:37 -0500 |
| commit | 3dfe2108cfab31ba3ee5527e217d0d8e99a51162 (patch) | |
| tree | fa6485c169e50d7415a651bf838f5bcd0fd3bfbd /APEX_1.4/include/iofx | |
| download | physx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.tar.xz physx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.zip | |
Initial commit:
PhysX 3.4.0 Update @ 21294896
APEX 1.4.0 Update @ 21275617
[CL 21300167]
Diffstat (limited to 'APEX_1.4/include/iofx')
| -rw-r--r-- | APEX_1.4/include/iofx/IofxActor.h | 61 | ||||
| -rw-r--r-- | APEX_1.4/include/iofx/IofxAsset.h | 79 | ||||
| -rw-r--r-- | APEX_1.4/include/iofx/IofxRenderCallback.h | 459 | ||||
| -rw-r--r-- | APEX_1.4/include/iofx/IofxRenderable.h | 135 | ||||
| -rw-r--r-- | APEX_1.4/include/iofx/Modifier.h | 592 | ||||
| -rw-r--r-- | APEX_1.4/include/iofx/ModifierDefs.h | 129 | ||||
| -rw-r--r-- | APEX_1.4/include/iofx/ModuleIofx.h | 121 | ||||
| -rw-r--r-- | APEX_1.4/include/iofx/RenderVolume.h | 110 |
8 files changed, 1686 insertions, 0 deletions
diff --git a/APEX_1.4/include/iofx/IofxActor.h b/APEX_1.4/include/iofx/IofxActor.h new file mode 100644 index 00000000..c40fa910 --- /dev/null +++ b/APEX_1.4/include/iofx/IofxActor.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2008-2015, 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 IOFX_ACTOR_H +#define IOFX_ACTOR_H + +#include "Apex.h" +#include "IofxAsset.h" +#include "IofxRenderable.h" + +namespace nvidia +{ +namespace apex +{ + +PX_PUSH_PACK_DEFAULT + +/** +\brief IOFX actor public interface +*/ +class IofxActor : public Actor +{ +public: + ///get the radius of the partice + virtual float getObjectRadius() const = 0; + + ///get the number of particles + virtual uint32_t getObjectCount() const = 0; + + ///get the number of visible particles (if sprite depth sorting is enabled, returns only number of particles in front of camera) + virtual uint32_t getVisibleCount() const = 0; + + ///get the name of the IOS asset used to feed partices to the IOFX + virtual const char* getIosAssetName() const = 0; + + ///returns AABB covering all objects in this actor, it's updated each frame during Scene::fetchResults(). + virtual physx::PxBounds3 getBounds() const = 0; + + /** + \brief Acquire a pointer to the iofx's renderable proxy and increment its reference count. + + The IofxRenderable will only be deleted when its reference count is zero. + Calls to IofxRenderable::release decrement the reference count, as does a call to IofxActor::release(). + */ + virtual IofxRenderable* acquireRenderableReference() = 0; +}; + +PX_POP_PACK + +} +} // namespace nvidia + +#endif // IOFX_ACTOR_H diff --git a/APEX_1.4/include/iofx/IofxAsset.h b/APEX_1.4/include/iofx/IofxAsset.h new file mode 100644 index 00000000..a9ba3479 --- /dev/null +++ b/APEX_1.4/include/iofx/IofxAsset.h @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2008-2015, 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 IOFX_ASSET_H +#define IOFX_ASSET_H + +#include "Apex.h" +#include "ModifierDefs.h" + +namespace nvidia +{ +namespace apex +{ + +PX_PUSH_PACK_DEFAULT + +#define IOFX_AUTHORING_TYPE_NAME "IOFX" + +class Modifier; +class ApexActor; + +/** + \brief IOFX Asset public interface. Used to define the way the visual parameters are created + from physical parameters of a particle +*/ +class IofxAsset : public Asset, public Context +{ +public: + ///get the name of the material used for sprite-based particles visualization + virtual const char* getSpriteMaterialName() const = 0; + + ///get the number of different mesh assets used for mesh-based particles visualization + virtual uint32_t getMeshAssetCount() const = 0; + + ///get the name of one of the mesh assets used for mesh-based particles visualization + /// \param index mesh asset internal index + virtual const char* getMeshAssetName(uint32_t index = 0) const = 0; + + ///get the weight of one of the mesh assets used for mesh-based particles visualization. Can be any value; not normalized. + /// \param index mesh asset internal index + virtual uint32_t getMeshAssetWeight(uint32_t index = 0) const = 0; + + ///get the list of spawn modifiers + virtual const Modifier* getSpawnModifiers(uint32_t& outCount) const = 0; + + ///get the list of continuous modifiers + virtual const Modifier* getContinuousModifiers(uint32_t& outCount) const = 0; + + ///get the biggest possible scale given the current spawn- and continuous modifiers + ///note that some modifiers depend on velocity, so the scale can get arbitrarily large. + /// \param maxVelocity this value defines what the highest expected velocity is to compute the upper bound + virtual float getScaleUpperBound(float maxVelocity) const = 0; + + ///the IOFX asset needs to inform other actors when it is released + /// \note only for internal use + virtual void addDependentActor(ApexActor* actor) = 0; +}; + +/** + \brief IOFX Asset Authoring public interface. + */ +class IofxAssetAuthoring : public AssetAuthoring +{ +}; + +PX_POP_PACK + +} +} // namespace nvidia + +#endif // IOFX_ASSET_H diff --git a/APEX_1.4/include/iofx/IofxRenderCallback.h b/APEX_1.4/include/iofx/IofxRenderCallback.h new file mode 100644 index 00000000..1b1cc026 --- /dev/null +++ b/APEX_1.4/include/iofx/IofxRenderCallback.h @@ -0,0 +1,459 @@ +/* + * Copyright (c) 2008-2015, 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 IOFX_RENDER_CALLBACK_H +#define IOFX_RENDER_CALLBACK_H + +#include "foundation/Px.h" +#include "UserRenderCallback.h" + +namespace nvidia +{ +namespace apex +{ + +PX_PUSH_PACK_DEFAULT + +class IofxRenderable; +class IofxSpriteRenderable; +class IofxMeshRenderable; + +/** +\brief Enumerates the potential IOFX render semantics +*/ +struct IofxRenderSemantic +{ + /** + \brief Enum of IOFX render semantics + */ + enum Enum + { + POSITION = 0, //!< Position of particle + COLOR, //!< Color of particle + VELOCITY, //!< Linear velocity of particle + SCALE, //!< Scale of particle + LIFE_REMAIN, //!< 1.0 (new) .. 0.0 (dead) + DENSITY, //!< Particle density + SUBTEXTURE, //!< Sub-texture index of particle + ORIENTATION, //!< 2D particle orientation (angle in radians, CCW in screen plane) + ROTATION, //!< 3D particle rotation + USER_DATA, //!< User data - 32 bits (passed from Emitter) + + NUM_SEMANTICS //!< Count of semantics, not a valid semantic. + }; +}; + + +/** +\brief Enumerates the potential IOFX mesh render layout elements +*/ +struct IofxSpriteRenderLayoutElement +{ + /** + \brief Enum of IOFX sprite render layout elements + */ + enum Enum + { + POSITION_FLOAT3, + COLOR_RGBA8, + COLOR_BGRA8, + COLOR_FLOAT4, + VELOCITY_FLOAT3, + SCALE_FLOAT2, + LIFE_REMAIN_FLOAT1, + DENSITY_FLOAT1, + SUBTEXTURE_FLOAT1, + ORIENTATION_FLOAT1, + USER_DATA_UINT1, + + MAX_COUNT + }; + + /** + \brief Get layout element format + */ + static PX_INLINE RenderDataFormat::Enum getFormat(Enum element) + { + switch (element) + { + case POSITION_FLOAT3: + return RenderDataFormat::FLOAT3; + case COLOR_RGBA8: + return RenderDataFormat::R8G8B8A8; + case COLOR_BGRA8: + return RenderDataFormat::B8G8R8A8; + case COLOR_FLOAT4: + return RenderDataFormat::FLOAT4; + case VELOCITY_FLOAT3: + return RenderDataFormat::FLOAT3; + case SCALE_FLOAT2: + return RenderDataFormat::FLOAT2; + case LIFE_REMAIN_FLOAT1: + return RenderDataFormat::FLOAT1; + case DENSITY_FLOAT1: + return RenderDataFormat::FLOAT1; + case SUBTEXTURE_FLOAT1: + return RenderDataFormat::FLOAT1; + case ORIENTATION_FLOAT1: + return RenderDataFormat::FLOAT1; + case USER_DATA_UINT1: + return RenderDataFormat::UINT1; + default: + PX_ALWAYS_ASSERT(); + return RenderDataFormat::NUM_FORMATS; + } + } +}; + +/** +\brief Enumerates the potential IOFX sprite render layout surface elements +*/ +struct IofxSpriteRenderLayoutSurfaceElement +{ + /** + \brief Enum of IOFX sprite render layout surface elements + */ + enum Enum + { + POSITION_FLOAT4, //!< float4(POSITION.x, POSITION.y, POSITION.z, 1) + SCALE_ORIENT_SUBTEX_FLOAT4, //!< float4(SCALE.x, SCALE.y, ORIENTATION, SUBTEXTURE) + COLOR_RGBA8, //<! COLOR in RGBA8 format + COLOR_BGRA8, //<! COLOR in BGRA8 format + COLOR_FLOAT4, //<! COLOR in FLOAT4 format + + MAX_COUNT + }; + + /** + \brief Get layout element format + */ + static PX_INLINE RenderDataFormat::Enum getFormat(Enum element) + { + switch (element) + { + case POSITION_FLOAT4: + return RenderDataFormat::FLOAT4; + case SCALE_ORIENT_SUBTEX_FLOAT4: + return RenderDataFormat::FLOAT4; + case COLOR_RGBA8: + return RenderDataFormat::R8G8B8A8; + case COLOR_BGRA8: + return RenderDataFormat::B8G8R8A8; + case COLOR_FLOAT4: + return RenderDataFormat::R32G32B32A32_FLOAT; + default: + PX_ALWAYS_ASSERT(); + return RenderDataFormat::NUM_FORMATS; + } + } +}; + +/** +\brief Describes the layout for sprite rendering +*/ +struct IofxSpriteRenderLayout +{ + IofxSpriteRenderLayout(void) + { + setDefaults(); + } + + /** + \brief Reset to default values + */ + void setDefaults() + { + bufferDesc.setDefaults(); + for (uint32_t i = 0; i < IofxSpriteRenderLayoutElement::MAX_COUNT; i++) + { + offsets[i] = uint32_t(-1); + } + stride = 0; + surfaceCount = 0; + for (uint32_t i = 0; i < MAX_SURFACE_COUNT; i++) + { + surfaceElements[i] = IofxSpriteRenderLayoutSurfaceElement::MAX_COUNT; + } + } + + /** + \brief Check if parameter's values are correct + */ + bool isValid(void) const + { + uint32_t numFailed = 0; + + numFailed += (surfaceCount == 0) && !bufferDesc.isValid(); + numFailed += (surfaceCount == 0) && (stride == 0); + numFailed += (surfaceCount == 0) && (offsets[IofxSpriteRenderLayoutElement::POSITION_FLOAT3] == uint32_t(-1)); + + numFailed += ((stride & 0x03) != 0); + for (uint32_t i = 0; i < IofxSpriteRenderLayoutElement::MAX_COUNT; i++) + { + if (offsets[i] != static_cast<uint32_t>(-1)) + { + numFailed += (offsets[i] >= stride); + numFailed += ((offsets[i] & 0x03) != 0); + } + } + for (uint32_t i= 0; i < surfaceCount; ++i) + { + numFailed += (surfaceElements[i] >= IofxSpriteRenderLayoutSurfaceElement::MAX_COUNT); + numFailed += !surfaceDescs[i].isValid(); + numFailed += (surfaceDescs[i].width == 0) || (surfaceDescs[i].height == 0); + numFailed += (IofxSpriteRenderLayoutSurfaceElement::getFormat(surfaceElements[i]) != surfaceDescs[i].format); + } + + return (numFailed == 0); + } + + /** + \brief Check if this object is the same as other + */ + bool isTheSameAs(const IofxSpriteRenderLayout& other) const + { + if (surfaceCount != other.surfaceCount) return false; + if (surfaceCount == 0) + { + if (!bufferDesc.isTheSameAs(other.bufferDesc)) return false; + if (stride != other.stride) return false; + for (uint32_t i = 0; i < IofxSpriteRenderLayoutElement::MAX_COUNT; i++) + { + if (offsets[i] != other.offsets[i]) return false; + } + } + else + { + for (uint32_t i = 0; i < surfaceCount; ++i) + { + if (surfaceElements[i] != other.surfaceElements[i]) return false; + if (!surfaceDescs[i].isTheSameAs(other.surfaceDescs[i])) return false; + } + } + return true; + } + +public: + UserRenderBufferDesc bufferDesc; //!< Render buffer desc. + + /** + \brief Array of the corresponding offsets (in bytes) for each layout element. + */ + uint32_t offsets[IofxSpriteRenderLayoutElement::MAX_COUNT]; + uint32_t stride; //!< The stride between objects in render buffer. + + uint32_t surfaceCount; //!< Number of render surfaces (if zero render buffer is used) + + /** + \brief Max number of supported render surfaces + */ + static const uint32_t MAX_SURFACE_COUNT = 4; + + /** + \brief Layout element for each render surface (should be valid for all indices < surfaceCount) + */ + IofxSpriteRenderLayoutSurfaceElement::Enum surfaceElements[MAX_SURFACE_COUNT]; + /** + \brief Description for each render surface (should be valid for all indices < surfaceCount) + */ + UserRenderSurfaceDesc surfaceDescs[MAX_SURFACE_COUNT]; +}; + + +/** +\brief Enumerates the potential IOFX mesh render layout elements +*/ +struct IofxMeshRenderLayoutElement +{ + /** + \brief Enum of IOFX mesh render layout elements + */ + enum Enum + { + POSITION_FLOAT3, + ROTATION_SCALE_FLOAT3x3, + POSE_FLOAT3x4, + VELOCITY_LIFE_FLOAT4, + DENSITY_FLOAT1, + COLOR_RGBA8, + COLOR_BGRA8, + COLOR_FLOAT4, + USER_DATA_UINT1, + + MAX_COUNT + }; + + /** + \brief Get layout element format + */ + static PX_INLINE RenderDataFormat::Enum getFormat(Enum element) + { + switch (element) + { + case POSITION_FLOAT3: + return RenderDataFormat::FLOAT3; + case ROTATION_SCALE_FLOAT3x3: + return RenderDataFormat::FLOAT3x3; + case POSE_FLOAT3x4: + return RenderDataFormat::FLOAT3x4; + case VELOCITY_LIFE_FLOAT4: + return RenderDataFormat::FLOAT4; + case DENSITY_FLOAT1: + return RenderDataFormat::FLOAT1; + case COLOR_RGBA8: + return RenderDataFormat::R8G8B8A8; + case COLOR_BGRA8: + return RenderDataFormat::B8G8R8A8; + case COLOR_FLOAT4: + return RenderDataFormat::FLOAT4; + case USER_DATA_UINT1: + return RenderDataFormat::UINT1; + default: + PX_ALWAYS_ASSERT(); + return RenderDataFormat::NUM_FORMATS; + } + } +}; + +/** +\brief Describes the layout for mesh rendering +*/ +struct IofxMeshRenderLayout +{ + IofxMeshRenderLayout(void) + { + setDefaults(); + } + + /** + \brief Reset to default values + */ + void setDefaults() + { + bufferDesc.setDefaults(); + for (uint32_t i = 0; i < IofxMeshRenderLayoutElement::MAX_COUNT; i++) + { + offsets[i] = uint32_t(-1); + } + stride = 0; + } + + /** + \brief Check if parameter's values are correct + */ + bool isValid(void) const + { + uint32_t numFailed = 0; + + numFailed += !bufferDesc.isValid(); + numFailed += (stride == 0); + numFailed += (offsets[IofxMeshRenderLayoutElement::POSITION_FLOAT3] == uint32_t(-1)) + && (offsets[IofxMeshRenderLayoutElement::POSE_FLOAT3x4] == uint32_t(-1)); + + numFailed += ((stride & 0x03) != 0); + for (uint32_t i = 0; i < IofxMeshRenderLayoutElement::MAX_COUNT; i++) + { + if (offsets[i] != static_cast<uint32_t>(-1)) + { + numFailed += (offsets[i] >= stride); + numFailed += ((offsets[i] & 0x03) != 0); + } + } + + return (numFailed == 0); + } + + /** + \brief Check if this object is the same as other + */ + bool isTheSameAs(const IofxMeshRenderLayout& other) const + { + if (!bufferDesc.isTheSameAs(other.bufferDesc)) return false; + if (stride != other.stride) return false; + for (uint32_t i = 0; i < IofxMeshRenderLayoutElement::MAX_COUNT; i++) + { + if (offsets[i] != other.offsets[i]) return false; + } + return true; + } + +public: + UserRenderBufferDesc bufferDesc; //!< Render buffer desc. + + /** + \brief Array of the corresponding offsets (in bytes) for each layout element. + */ + uint32_t offsets[IofxMeshRenderLayoutElement::MAX_COUNT]; + uint32_t stride; //!< The stride between objects in render buffer. +}; + + +/** +\brief User defined callback for IOFX rendering +*/ +class IofxRenderCallback : public UserRenderCallback +{ +public: + /** + \brief Called just after a new IOFX renderable was created + */ + virtual void onCreatedIofxRenderable(IofxRenderable& ) {} + + /** + \brief Called just after an IOFX renderable was updated + */ + virtual void onUpdatedIofxRenderable(IofxRenderable& ) {} + + /** + \brief Called just before an IOFX renderable is going to be released + */ + virtual void onReleasingIofxRenderable(IofxRenderable& ) {} + + /** \brief Called by the IOFX module to query layout for sprite rendering. + Should return true in case IofxSpriteRenderLayout is properly filled, + and then IOFX will pass this layout to createRender[Buffer|Surface] method(s) to create needed render resources. + In case this method is not implemented and returns false the IOFX module will create a layout to hold all input semantics. + Also in case this method is not implemented or/and createRender[Buffer|Surface] method is not implemented, + then the IOFX module will create its own render buffer/surfaces which user can map to access rendering content. + */ + virtual bool getIofxSpriteRenderLayout(IofxSpriteRenderLayout& spriteRenderLayout, uint32_t spriteCount, uint32_t spriteSemanticsBitmap, RenderInteropFlags::Enum interopFlags) + { + PX_UNUSED(spriteRenderLayout); + PX_UNUSED(spriteCount); + PX_UNUSED(spriteSemanticsBitmap); + PX_UNUSED(interopFlags); + return false; + } + + /** \brief Called by the IOFX module to query layout for mesh rendering. + Should return true in case IofxMeshRenderLayout is properly filled, + and then IOFX will pass this layout to createRenderBuffer method to create needed render resources. + In case this method is not implemented and returns false the IOFX module will create a layout to hold all input semantics. + Also in case this method is not implemented or/and createRenderBuffer method is not implemented, + then the IOFX module will create its own render buffer which user can map to access rendering content. + */ + virtual bool getIofxMeshRenderLayout(IofxMeshRenderLayout& meshRenderLayout, uint32_t meshCount, uint32_t meshSemanticsBitmap, RenderInteropFlags::Enum interopFlags) + { + PX_UNUSED(meshRenderLayout); + PX_UNUSED(meshCount); + PX_UNUSED(meshSemanticsBitmap); + PX_UNUSED(interopFlags); + return false; + } + +}; + +PX_POP_PACK + +} +} // end namespace nvidia + +#endif // IOFX_RENDER_CALLBACK_H diff --git a/APEX_1.4/include/iofx/IofxRenderable.h b/APEX_1.4/include/iofx/IofxRenderable.h new file mode 100644 index 00000000..8f1214c9 --- /dev/null +++ b/APEX_1.4/include/iofx/IofxRenderable.h @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2008-2015, 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 IOFX_RENDERABLE_H +#define IOFX_RENDERABLE_H + +#include "foundation/Px.h" +#include "ApexInterface.h" +#include "Renderable.h" +#include "IofxRenderCallback.h" + +namespace nvidia +{ +namespace apex +{ + +PX_PUSH_PACK_DEFAULT + +/** +\brief IofxSharedRenderData stores common render data shared by several IOFX Renderables. +*/ +struct IofxSharedRenderData +{ + uint32_t maxObjectCount; //!< maximum number of particles + uint32_t activeObjectCount; //!< currently active number of particles +}; + +/** +\brief IofxSpriteSharedRenderData stores sprite render data shared by several IOFX Renderables. +*/ +struct IofxSpriteSharedRenderData : IofxSharedRenderData +{ + IofxSpriteRenderLayout spriteRenderLayout; //!< sprite render layout + UserRenderBuffer* spriteRenderBuffer; //!< sprite render buffer + UserRenderSurface* spriteRenderSurfaces[IofxSpriteRenderLayout::MAX_SURFACE_COUNT]; //!< sprite render surfaces +}; + +/** +\brief IofxMeshSharedRenderData stores mesh render data shared by several IOFX Renderables. +*/ +struct IofxMeshSharedRenderData : IofxSharedRenderData +{ + IofxMeshRenderLayout meshRenderLayout; //!< mesh render layout + UserRenderBuffer* meshRenderBuffer; //!< mesh render buffer +}; + +/** +\brief IofxCommonRenderData stores common render data for one IOFX Renderable. +*/ +struct IofxCommonRenderData +{ + uint32_t startIndex; //!< index of the first particle in render buffer + uint32_t objectCount; //!< number of particles in render buffer + + const char* renderResourceNameSpace; //!< render resource name space + const char* renderResourceName; //!< render resource name + void* renderResource; //!< render resource +}; + +/** +\brief IofxSpriteRenderData stores sprite render data for one IOFX Renderable. +*/ +struct IofxSpriteRenderData : IofxCommonRenderData +{ + uint32_t visibleCount; //!< number of visible particles (if sprite depth sorting is enabled, includes only particles in front of the view frustrum) + + const IofxSpriteSharedRenderData* sharedRenderData; //!< reference to Sprite shared render data +}; + +/** +\brief IofxMeshRenderData stores mesh render data for one IOFX Renderable. +*/ +struct IofxMeshRenderData : IofxCommonRenderData +{ + const IofxMeshSharedRenderData* sharedRenderData; //!< reference to Mesh shared render data +}; + +class IofxSpriteRenderable; +class IofxMeshRenderable; + +/** + \brief The IOFX renderable represents a unit of rendering. + It contains complete information to render a batch of particles with the same material/mesh in the same render volume. +*/ +class IofxRenderable : public ApexInterface +{ +public: + /** + \brief Type of IOFX renderable + */ + enum Type + { + SPRITE, //!< Sprite particles type + MESH //!< Mesh particles type + }; + + /** + \brief Return Type of this renderable. + */ + virtual Type getType() const = 0; + + /** + \brief Return Sprite render data for Sprite renderable and NULL for other types. + */ + virtual const IofxSpriteRenderData* getSpriteRenderData() const = 0; + + /** + \brief Return Mesh render data for Mesh renderable and NULL for other types. + */ + virtual const IofxMeshRenderData* getMeshRenderData() const = 0; + + /** + \brief Return AABB of this renderable. + */ + virtual const physx::PxBounds3& getBounds() const = 0; + +protected: + virtual ~IofxRenderable() {} + +}; + +PX_POP_PACK + +} +} // end namespace nvidia + +#endif // IOFX_RENDERABLE_H diff --git a/APEX_1.4/include/iofx/Modifier.h b/APEX_1.4/include/iofx/Modifier.h new file mode 100644 index 00000000..4b3665ac --- /dev/null +++ b/APEX_1.4/include/iofx/Modifier.h @@ -0,0 +1,592 @@ +/* + * Copyright (c) 2008-2015, 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 MODIFIER_H +#define MODIFIER_H + +#include "Apex.h" +#include "Curve.h" +#include "IofxAsset.h" +#include "IofxRenderCallback.h" + +#include "ModifierDefs.h" + +namespace nvidia +{ +namespace apex +{ + +PX_PUSH_PACK_DEFAULT + +/// Converts ModifierStage to bitmap +inline uint32_t ModifierUsageFromStage(ModifierStage stage) +{ + return 1u << stage; +} + +// Disable the unused arguments warning for this header. +#pragma warning( disable: 4100 ) + +/** +\brief Modifier contains all of the data necessary to apply a single modifier type to a particle system. + +Generally this combines some physical transformation with parameters specified at authoring time +to modify the look of the final effect. +*/ +class Modifier +{ +public: + + /// getModifierType returns the enumerated type associated with this class. + virtual ModifierTypeEnum getModifierType() const = 0; + + /// getModifierUsage returns the usage scenarios allowed for a particular modifier. + virtual uint32_t getModifierUsage() const = 0; + + /// returns a bitmap that includes every sprite semantic that the modifier updates + virtual uint32_t getModifierSpriteSemantics() + { + return 0; + } + + /// returns a bitmap that includes every mesh(instance) semantic that the modifier updates + virtual uint32_t getModifierMeshSemantics() + { + return 0; + } + + virtual ~Modifier() { } + +}; + +/** +\brief ModifierT is a helper class to handle the mapping of Type->Enum and Enum->Type. + +This imposes some structure on the subclasses--they all now +expect to have a const static field called ModifierType. +*/ +template <typename T> +class ModifierT : public Modifier +{ +public: + + /// Returns ModifierType for typename T + virtual ModifierTypeEnum getModifierType() const + { + return T::ModifierType; + } + + /// Returns ModifierUsage for typename T + virtual uint32_t getModifierUsage() const + { + return T::ModifierUsage; + } +}; + + +/** +\brief RotationModifier applies rotation to the particles using one of several rotation models. +*/ +class RotationModifier : public ModifierT<RotationModifier> +{ +public: + + /// ModifierType + static const ModifierTypeEnum ModifierType = ModifierType_Rotation; + + /// ModifierUsage + static const uint32_t ModifierUsage = ModifierUsage_Spawn | ModifierUsage_Continuous + | ModifierUsage_Mesh; + + + /// get the roll model + virtual ApexMeshParticleRollType::Enum getRollType() const = 0; + + /// set the roll model + virtual void setRollType(ApexMeshParticleRollType::Enum rollType) = 0; + + /// get the maximum allowed settle rate per second + virtual float getMaxSettleRate() const = 0; + + /// set the maximum allowed settle rate per second + virtual void setMaxSettleRate(float settleRate) = 0; + + /// get the maximum allowed rotation rate per second + virtual float getMaxRotationRate() const = 0; + + /// set the maximum allowed rotation rate per second + virtual void setMaxRotationRate(float rotationRate) = 0; + +}; + +/** + \brief SimpleScaleModifier just applies a simple scale factor to each of the X, Y and Z aspects of the model. Each scalefactor can be + applied independently. +*/ +class SimpleScaleModifier : public ModifierT<SimpleScaleModifier> +{ +public: + + /// ModifierType + static const ModifierTypeEnum ModifierType = ModifierType_SimpleScale; + + /// ModifierUsage + static const uint32_t ModifierUsage = ModifierUsage_Spawn | ModifierUsage_Continuous + | ModifierUsage_Sprite | ModifierUsage_Mesh; + + + /// get the vector of scale factors along the three axes + virtual PxVec3 getScaleFactor() const = 0; + + /// set the vector of scale factors along the three axes + virtual void setScaleFactor(const PxVec3& s) = 0; +}; + +/** +\brief ScaleByMassModifier scales by mass of the particle. +*/ +class ScaleByMassModifier : public ModifierT<ScaleByMassModifier> +{ +public: + + /// ModifierType + static const ModifierTypeEnum ModifierType = ModifierType_ScaleByMass; + + /// ModifierUsage + static const uint32_t ModifierUsage = ModifierUsage_Spawn | ModifierUsage_Continuous + | ModifierUsage_Sprite | ModifierUsage_Mesh; +}; + +/** + \brief RandomScaleModifier applies a random scale uniformly to all three dimensions. Currently, the + scale is a uniform in the range specified. +*/ +class RandomScaleModifier : public ModifierT<RandomScaleModifier> +{ +public: + + /// ModifierType + static const ModifierTypeEnum ModifierType = ModifierType_RandomScale; + + /// ModifierUsage + static const uint32_t ModifierUsage = ModifierUsage_Spawn + | ModifierUsage_Sprite | ModifierUsage_Mesh; + + + /// get the range of scale factors along the three axes + virtual Range<float> getScaleFactor() const = 0; + + /// set the range of scale factors along the three axes + virtual void setScaleFactor(const Range<float>& s) = 0; +}; + +/** + \brief ColorVsLifeModifier modifies the color constants associated with a particle + depending on the life remaining of the particle. +*/ +class ColorVsLifeModifier : public ModifierT<ColorVsLifeModifier> +{ +public: + + /// ModifierType + static const ModifierTypeEnum ModifierType = ModifierType_ColorVsLife; + + /// ModifierUsage + static const uint32_t ModifierUsage = ModifierUsage_Spawn | ModifierUsage_Continuous + | ModifierUsage_Sprite | ModifierUsage_Mesh; + + + /// get the affected color channel + virtual ColorChannel getColorChannel() const = 0; + + /// set the affected color channel + virtual void setColorChannel(ColorChannel colorChannel) = 0; + + /// get the curve that sets the dependency between the lifetime and the color + virtual const Curve* getFunction() const = 0; + + /// set the curve that sets the dependency between the lifetime and the color + virtual void setFunction(const Curve* f) = 0; +}; + +/** + \brief ColorVsDensityModifier modifies the color constants associated with a particle + depending on the density of the particle. +*/ +class ColorVsDensityModifier : public ModifierT<ColorVsDensityModifier> +{ +public: + + /// ModifierType + static const ModifierTypeEnum ModifierType = ModifierType_ColorVsDensity; + + /// ModifierUsage + static const uint32_t ModifierUsage = ModifierUsage_Continuous + | ModifierUsage_Sprite | ModifierUsage_Mesh; + + + /// get the affected color channel + virtual ColorChannel getColorChannel() const = 0; + + /// set the affected color channel + virtual void setColorChannel(ColorChannel colorChannel) = 0; + + /// get the curve that sets the dependency between the density and the color + virtual const Curve* getFunction() const = 0; + + /// set the curve that sets the dependency between the density and the color + virtual void setFunction(const Curve* f) = 0; +}; + +/** + \brief SubtextureVsLifeModifier is a modifier to adjust the subtexture id versus the life remaining of a particular particle. + + Interpretation of the subtexture id over time is up to the application. + */ +class SubtextureVsLifeModifier : public ModifierT<SubtextureVsLifeModifier> +{ +public: + + /// ModifierType + static const ModifierTypeEnum ModifierType = ModifierType_SubtextureVsLife; + + /// ModifierUsage + static const uint32_t ModifierUsage = ModifierUsage_Continuous + | ModifierUsage_Sprite; + + + /// get the curve that sets the dependency between the life remaining and the subtexture id + virtual const Curve* getFunction() const = 0; + + /// set the curve that sets the dependency between the life remaining and the subtexture id + virtual void setFunction(const Curve* f) = 0; +}; + +/** + \brief OrientAlongVelocity is a modifier to orient a mesh so that a particular axis coincides with the velocity vector. + */ +class OrientAlongVelocityModifier : public ModifierT<OrientAlongVelocityModifier> +{ +public: + + /// ModifierType + static const ModifierTypeEnum ModifierType = ModifierType_OrientAlongVelocity; + + /// ModifierUsage + static const uint32_t ModifierUsage = ModifierUsage_Continuous + | ModifierUsage_Mesh; + + + /// get the object-space vector that will coincide with the velocity vector + virtual PxVec3 getModelForward() const = 0; + + /// set the object-space vector that will coincide with the velocity vector + virtual void setModelForward(const PxVec3& s) = 0; +}; + + +/** + \brief ScaleAlongVelocityModifier is a modifier to apply a scale factor along the current velocity vector. + + Note that without applying an OrientAlongVelocity modifier first, the results for this will be 'odd.' + */ +class ScaleAlongVelocityModifier : public ModifierT<ScaleAlongVelocityModifier> +{ +public: + + /// ModifierType + static const ModifierTypeEnum ModifierType = ModifierType_ScaleAlongVelocity; + + /// ModifierUsage + static const uint32_t ModifierUsage = ModifierUsage_Continuous + | ModifierUsage_Mesh; + + + /// get the scale factor + virtual float getScaleFactor() const = 0; + + /// set the scale factor + virtual void setScaleFactor(const float& s) = 0; +}; + +/** + \brief RandomSubtextureModifier generates a random subtexture ID and places it in the subTextureId field. + */ +class RandomSubtextureModifier : public ModifierT<RandomSubtextureModifier> +{ +public: + + /// ModifierType + static const ModifierTypeEnum ModifierType = ModifierType_RandomSubtexture; + + /// ModifierUsage + static const uint32_t ModifierUsage = ModifierUsage_Spawn + | ModifierUsage_Sprite; + + + ///get the range for subtexture values + virtual Range<float> getSubtextureRange() const = 0; + + ///set the range for subtexture values + virtual void setSubtextureRange(const Range<float>& s) = 0; +}; + +/** + \brief RandomRotationModifier will choose a random orientation for a sprite particle within the range as specified below. + + The values in the range are interpreted as radians. Please keep in mind that all the sprites are coplanar to the screen. + */ +class RandomRotationModifier : public ModifierT<RandomRotationModifier> +{ +public: + + /// ModifierType + static const ModifierTypeEnum ModifierType = ModifierType_RandomRotation; + + /// ModifierUsage + static const uint32_t ModifierUsage = ModifierUsage_Spawn + | ModifierUsage_Sprite; + + + ///get the range of orientations, in radians. + virtual Range<float> getRotationRange() const = 0; + + ///set the range of orientations, in radians. + virtual void setRotationRange(const Range<float>& s) = 0; +}; + +/** + \brief ScaleVsLifeModifier applies a scale factor function against a single axis versus the life remaining. + */ +class ScaleVsLifeModifier : public ModifierT<ScaleVsLifeModifier> +{ +public: + + /// ModifierType + static const ModifierTypeEnum ModifierType = ModifierType_ScaleVsLife; + + /// ModifierUsage + static const uint32_t ModifierUsage = ModifierUsage_Continuous + | ModifierUsage_Sprite | ModifierUsage_Mesh; + + + /// get the axis along which the scale factor will be applied + virtual ScaleAxis getScaleAxis() const = 0; + + /// set the axis along which the scale factor will be applied + virtual void setScaleAxis(ScaleAxis a) = 0; + + /// get the the curve that defines the dependency between the life remaining and the scale factor + virtual const Curve* getFunction() const = 0; + + /// set the the curve that defines the dependency between the life remaining and the scale factor + virtual void setFunction(const Curve* f) = 0; +}; + +/** + \brief ScaleVsDensityModifier applies a scale factor function against a single axis versus the density of the particle. + */ +class ScaleVsDensityModifier : public ModifierT<ScaleVsDensityModifier> +{ +public: + + /// ModifierType + static const ModifierTypeEnum ModifierType = ModifierType_ScaleVsDensity; + + /// ModifierUsage + static const uint32_t ModifierUsage = ModifierUsage_Continuous + | ModifierUsage_Sprite | ModifierUsage_Mesh; + + + /// get the axis along which the scale factor will be applied + virtual ScaleAxis getScaleAxis() const = 0; + + /// set the axis along which the scale factor will be applied + virtual void setScaleAxis(ScaleAxis a) = 0; + + /// get the the curve that defines the dependency between the density and the scale factor + virtual const Curve* getFunction() const = 0; + + /// set the the curve that defines the dependency between the density and the scale factor + virtual void setFunction(const Curve* f) = 0; +}; + +/** + \brief ScaleVsCameraDistance applies a scale factor against a specific axis based on distance from the camera to the particle. + */ +class ScaleVsCameraDistanceModifier : public ModifierT<ScaleVsCameraDistanceModifier> +{ +public: + + /// ModifierType + static const ModifierTypeEnum ModifierType = ModifierType_ScaleVsCameraDistance; + + /// ModifierUsage + static const uint32_t ModifierUsage = ModifierUsage_Continuous + | ModifierUsage_Sprite | ModifierUsage_Mesh; + + + /// get the axis along which the scale factor will be applied + virtual ScaleAxis getScaleAxis() const = 0; + + /// set the axis along which the scale factor will be applied + virtual void setScaleAxis(ScaleAxis a) = 0; + + /// get the the curve that defines the dependency between the camera distance and the scale factor + virtual const Curve* getFunction() const = 0; + + /// set the the curve that defines the dependency between the camera distance and the scale factor + virtual void setFunction(const Curve* f) = 0; +}; + +/** + \brief ViewDirectionSortingModifier sorts sprite particles along view direction back to front. + */ +class ViewDirectionSortingModifier : public ModifierT<ViewDirectionSortingModifier> +{ +public: + + /// ModifierType + static const ModifierTypeEnum ModifierType = ModifierType_ViewDirectionSorting; + + /// ModifierUsage + static const uint32_t ModifierUsage = ModifierUsage_Continuous + | ModifierUsage_Sprite; + +}; + +/** + \brief RotationRateModifier is a modifier to apply a continuous rotation for sprites. + */ +class RotationRateModifier : public ModifierT<RotationRateModifier> +{ +public: + + /// ModifierType + static const ModifierTypeEnum ModifierType = ModifierType_RotationRate; + + /// ModifierUsage + static const uint32_t ModifierUsage = ModifierUsage_Continuous + | ModifierUsage_Sprite; + + + /// set the rotation rate + virtual float getRotationRate() const = 0; + + /// get the rotation rate + virtual void setRotationRate(const float& rate) = 0; +}; + +/** + \brief RotationRateVsLifeModifier is a modifier to adjust the rotation rate versus the life remaining of a particular particle. + */ +class RotationRateVsLifeModifier : public ModifierT<RotationRateVsLifeModifier> +{ +public: + + /// ModifierType + static const ModifierTypeEnum ModifierType = ModifierType_RotationRateVsLife; + + /// ModifierUsage + static const uint32_t ModifierUsage = ModifierUsage_Continuous + | ModifierUsage_Sprite; + + + /// get the curve that sets the dependency between the life remaining and the rotation rate + virtual const Curve* getFunction() const = 0; + + /// set the curve that sets the dependency between the life remaining and the rotation rate + virtual void setFunction(const Curve* f) = 0; +}; + +/** + \brief OrientScaleAlongScreenVelocityModifier is a modifier to orient & scale sprites along the current screen velocity vector. + */ +class OrientScaleAlongScreenVelocityModifier : public ModifierT<OrientScaleAlongScreenVelocityModifier> +{ +public: + + /// ModifierType + static const ModifierTypeEnum ModifierType = ModifierType_OrientScaleAlongScreenVelocity; + + /// ModifierUsage + static const uint32_t ModifierUsage = ModifierUsage_Continuous + | ModifierUsage_Sprite; + + + /// get the scale per velocity + virtual float getScalePerVelocity() const = 0; + + /// set the scale per velocity + virtual void setScalePerVelocity(const float& s) = 0; + + /// get the scale change limit + virtual float getScaleChangeLimit() const = 0; + + /// set the scale change limit + virtual void setScaleChangeLimit(const float& s) = 0; + + /// get the scale change delay + virtual float getScaleChangeDelay() const = 0; + + /// set the scale change delay + virtual void setScaleChangeDelay(const float& s) = 0; +}; + +/** + \brief ColorVsVelocityModifier modifies the color constants associated with a particle + depending on the velocity of the particle. +*/ +class ColorVsVelocityModifier : public ModifierT<ColorVsVelocityModifier> +{ +public: + + /// ModifierType + static const ModifierTypeEnum ModifierType = ModifierType_ColorVsVelocity; + + /// ModifierUsage + static const uint32_t ModifierUsage = ModifierUsage_Spawn | ModifierUsage_Continuous + | ModifierUsage_Sprite | ModifierUsage_Mesh; + + + /// get the affected color channel + virtual ColorChannel getColorChannel() const = 0; + + /// set the affected color channel + virtual void setColorChannel(ColorChannel colorChannel) = 0; + + /// get the curve that sets the dependency between the lifetime and the color + virtual const Curve* getFunction() const = 0; + + /// set the curve that sets the dependency between the lifetime and the color + virtual void setFunction(const Curve* f) = 0; + + /// get velocity0 + virtual float getVelocity0() const = 0; + + /// set velocity0 + virtual void setVelocity0(float value) = 0; + + /// get velocity1 + virtual float getVelocity1() const = 0; + + /// set velocity1 + virtual void setVelocity1(float value) = 0; +}; + +#pragma warning( default: 4100 ) + +PX_POP_PACK + +} +} // namespace nvidia + +#endif // MODIFIER_H diff --git a/APEX_1.4/include/iofx/ModifierDefs.h b/APEX_1.4/include/iofx/ModifierDefs.h new file mode 100644 index 00000000..2d39ad6e --- /dev/null +++ b/APEX_1.4/include/iofx/ModifierDefs.h @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2008-2015, 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 MODIFIER_DEFS_H +#define MODIFIER_DEFS_H + +#include "ApexUsingNamespace.h" + +namespace nvidia +{ +namespace apex +{ + +PX_PUSH_PACK_DEFAULT + +/** + \brief Roll type of a particle + */ +struct ApexMeshParticleRollType +{ + /** + \brief Enum of roll type of a particle + */ + enum Enum + { + SPHERICAL = 0, ///< roll as a sphere + CUBIC, ///< as a cubical object + FLAT_X, ///< as a flat object (shortest axis is x) + FLAT_Y, ///< as a flat object (shortest axis is y) + FLAT_Z, ///< as a flat object (shortest axis is z) + LONG_X, ///< as a long object (longest axis is x) + LONG_Y, ///< as a long object (longest axis is y) + LONG_Z, ///< as a long object (longest axis is z) + SPRITE, ///< as a sprite + + COUNT + }; +}; + +/** + \brief Modifiers list + \note These are serialized to disk, so if you reorder them or change existing modifier types, you + will need to version the stream and map the old values to the new values. + If new values are just appended, no other special care needs to be handled. + */ +enum ModifierTypeEnum +{ + ModifierType_Invalid = 0, + ModifierType_Rotation = 1, + ModifierType_SimpleScale = 2, + ModifierType_RandomScale = 3, + ModifierType_ColorVsLife = 4, + ModifierType_ColorVsDensity = 5, + ModifierType_SubtextureVsLife = 6, + ModifierType_OrientAlongVelocity = 7, + ModifierType_ScaleAlongVelocity = 8, + ModifierType_RandomSubtexture = 9, + ModifierType_RandomRotation = 10, + ModifierType_ScaleVsLife = 11, + ModifierType_ScaleVsDensity = 12, + ModifierType_ScaleVsCameraDistance = 13, + ModifierType_ViewDirectionSorting = 14, + ModifierType_RotationRate = 15, + ModifierType_RotationRateVsLife = 16, + ModifierType_OrientScaleAlongScreenVelocity = 17, + ModifierType_ScaleByMass = 18, + ModifierType_ColorVsVelocity = 19, + + ModifierType_Count +}; + +/** + \brief Stage at which the modifier is applied + */ +enum ModifierStage +{ + ModifierStage_Spawn = 0, ///< at the spawn + ModifierStage_Continuous = 1, ///< on every frame + + ModifierStage_Count +}; + +/** + \brief Color channel + */ +enum ColorChannel +{ + ColorChannel_Red = 0, + ColorChannel_Green = 1, + ColorChannel_Blue = 2, + ColorChannel_Alpha = 3 +}; + +/** + \brief Scale axis + */ +enum ScaleAxis +{ + ScaleAxis_X = 0, + ScaleAxis_Y = 1, + ScaleAxis_Z = 2 +}; + +/** + \brief Modifier usage + */ +enum ModifierUsage +{ + ModifierUsage_Spawn = 0x01, + ModifierUsage_Continuous = 0x02, + + ModifierUsage_Sprite = 0x04, + ModifierUsage_Mesh = 0x08, +}; + +PX_POP_PACK + +} +} // namespace nvidia + +#endif // MODIFIER_DEFS_H diff --git a/APEX_1.4/include/iofx/ModuleIofx.h b/APEX_1.4/include/iofx/ModuleIofx.h new file mode 100644 index 00000000..4057ff4f --- /dev/null +++ b/APEX_1.4/include/iofx/ModuleIofx.h @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2008-2015, 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 MODULE_IOFX_H +#define MODULE_IOFX_H + +#include "Apex.h" +#include "TestBase.h" + +namespace nvidia +{ +namespace apex +{ + +PX_PUSH_PACK_DEFAULT + +class IofxAsset; +class IofxAssetAuthoring; +class RenderVolume; +class IofxRenderCallback; +class IofxRenderable; + + +/** +\brief Iterate over all renderables in IOFX module. IMPORTANT: release() should be called for each returned not-NULL renderable! +*/ +class IofxRenderableIterator : public ApexInterface +{ +public: + + /// Return the first renderable in IOFX module + virtual IofxRenderable* getFirst() = 0; + + /// Return the next renderable IOFX module + virtual IofxRenderable* getNext() = 0; +}; + + +/** + \brief IOFX Module. + + This module is used to convert physical parameters of particles into visual parameters + that can be used to render particles. ApexRenderVolume provide the ability to partition world space + into separate renderables. + */ +class ModuleIofx : public Module +{ +protected: + virtual ~ModuleIofx() {} + +public: + /// Disable use of OGL/D3D Interop. Must be called before emitters are created to have any effect + virtual void disableCudaInterop() = 0; + + /// Disable use of CUDA IOFX modifiers. Must be called before emitters are created to have any effect + virtual void disableCudaModifiers() = 0; + + /** \brief Disables deferred allocation of IOFX actors + * + * By default, IOFX actors and their render resources will not be + * created until it has objects to render. + */ + virtual void disableDeferredRenderableAllocation() = 0; + + /** \brief Create a new render volume + * + * Render volumes may be created at any time, unlike most other APEX + * asset and actor types. Their insertion into the scene is + * deferred if the simulation is active. + */ + virtual RenderVolume* createRenderVolume(const Scene& apexScene, const PxBounds3& b, uint32_t priority, bool allIofx) = 0; + + /** \brief Release a render volume + * + * Render volumes may be released at any time, unlike most other APEX + * asset and actor types. If the simulation is active, their + * resources are released at the end of the simulation step. + */ + virtual void releaseRenderVolume(RenderVolume& volume) = 0; + + /// Get TestBase implementation of Iofx scene + virtual const TestBase* getTestBase(Scene* apexScene) const = 0; + + /** + \brief Set IofxRenderCallback + \see IofxRenderCallback + */ + virtual bool setIofxRenderCallback(const Scene& apexScene, IofxRenderCallback* ) = 0; + + /** + \brief Get IofxRenderCallback + \see IofxRenderCallback + */ + virtual IofxRenderCallback* getIofxRenderCallback(const Scene& apexScene) const = 0; + + /** + \brief Create an iterator for all renderables in IOFX module + */ + virtual IofxRenderableIterator* createIofxRenderableIterator(const Scene&) = 0; + + /** + \brief Prepare renderables for rendering, should be called each frame before using renderables to update them with the most recent data + */ + virtual void prepareRenderables(const Scene&) = 0; +}; + + +PX_POP_PACK + +} +} // namespace nvidia + +#endif // MODULE_IOFX_H diff --git a/APEX_1.4/include/iofx/RenderVolume.h b/APEX_1.4/include/iofx/RenderVolume.h new file mode 100644 index 00000000..c44eeb4f --- /dev/null +++ b/APEX_1.4/include/iofx/RenderVolume.h @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2008-2015, 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 RENDER_VOLUME_H +#define RENDER_VOLUME_H + +#include "Apex.h" + +namespace nvidia +{ +namespace apex +{ + +PX_PUSH_PACK_DEFAULT + +class IofxAsset; +class IofxActor; + +/** + \brief An object which "owns" a volume of world space. + + Any particles which enter the + owned volume will be migrated to an IOFX actor owned by this object (if the + particle's IOFX asset is affected by this volume). + + When volumes overlap, their relative priorities break the tie. If multiple volumes + have the same priority, the tie breaker goes to the volume that owns the particle. + */ +class RenderVolume : public ApexInterface +{ +public: + /// Returns AABB covering all objects in this render volume, it's updated each frame during Scene::fetchResults(). + virtual physx::PxBounds3 getBounds() const = 0; + + /// Returns true if the volume affects all IOFX assets + virtual bool getAffectsAllIofx() const = 0; + + /// Adds IOFX asset to volume's list of affected IOFX assets, returns false on failure + virtual bool addIofxAsset(IofxAsset& iofx) = 0; + + /// Moves the render volume while maintaining its dimensions + virtual void setPosition(const PxVec3& pos) = 0; + + /// Directly assigns a new AABB ownership volume + virtual void setOwnershipBounds(const PxBounds3& b) = 0; + + /// Retrieves the configured AABB bounds of the volume. Call getBounds() for the "live" bounds. + virtual PxBounds3 getOwnershipBounds() const = 0; + + /** \brief Retrieve list of IOFX actors owned by this volume (one per IOFX Asset per IOS actor) + * + * Returns count of 0 if empty. Returned pointer is undefined when count is 0. + * + * The bounds of each of these IOFX is guaranteed to be within the bounds of the volume itself. + * Calling the updateRenderResources and dispatchRenderResources() methods of the volume will + * implicitly call the same methods of each of these IOFX actors, so there is no need to iterate + * over them for rendering purposes, unless you require special logic per IOFX. + * + * It is not necessary to release these actors, they will be released automatically when their + * volume, their IOFX Asset, or their host IOS actor are released. + * + * This call is not thread-safe. The returned buffer is only valid until the next APEX API + * call that steps the simulation or modifies the number of IOFX actors in a scene. + */ + virtual IofxActor* const* lockIofxActorList(uint32_t& count) = 0; + + /** + \brief Unlock IOFX actors which where locked by calling lockIofxActorList + \see RenderVolume::lockIofxActorList + */ + virtual void unlockIofxActorList() = 0; + + /** \brief Retrieve list of volume's affected IOFX assets. + * + * Returns count of 0 if empty or volume affects all IOFX assets. Returned pointer is + * undefined when count is 0. + * + * The returned buffer not thread-safe, and is only valid until the next APEX API + * call that steps the simulation or modifies the number of IOFX assets in a scene. + */ + virtual IofxAsset* const* getIofxAssetList(uint32_t& count) const = 0; + + virtual PxVec3 getPosition() const = 0; ///< Returns center of ownership bounds + virtual uint32_t getPriority() const = 0; ///< Returns priority of volume + + /** \brief Returns true if this volume affects the specified IOFX asset + * + * Callers must acquire render lock of the volume before calling + * this function, for thread safety. + */ + virtual bool affectsIofxAsset(const IofxAsset& iofx) const = 0; + +protected: + virtual ~RenderVolume() {} +}; + +PX_POP_PACK + +} +} // namespace nvidia + +#endif // RENDER_VOLUME_H |