APEX Framework: Scene.h Source File

NVIDIA APEX

Scene.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 
00012 #ifndef SCENE_H
00013 #define SCENE_H
00014 
00020 #include "ApexDesc.h"
00021 #include "Renderable.h"
00022 #include "RenderDebugInterface.h"
00023 #include "Context.h"
00024 #include "foundation/PxVec3.h"
00025 #include <ApexDefs.h>
00026 
00027 #if PX_PHYSICS_VERSION_MAJOR == 3
00028 #include "PxFiltering.h"
00029 #endif
00030 #include "MirrorScene.h"
00031 
00032 namespace NvParameterized
00033 {
00034 class Interface;
00035 }
00036 
00037 namespace physx
00038 {
00039     class PxBaseTask;
00040     class PxTaskManager;
00041     class PxCpuDispatcher;
00042     class PxGpuDispatcher;
00043 }
00044 
00045 namespace nvidia
00046 {
00047 namespace apex
00048 {
00049 // Forward declaration for the PhysX3Interface::setContactReportFlags() callback
00050 class DestructibleActor;
00051 
00052 PX_PUSH_PACK_DEFAULT
00053 
00054 #if PX_PHYSICS_VERSION_MAJOR == 3
00055 
00058 class PhysX3Interface
00059 {
00060 public:
00066     virtual void setContactReportFlags(PxShape* shape, physx::PxPairFlags flags, DestructibleActor* actor, uint16_t actorChunkIndex) = 0;
00067 
00072     virtual physx::PxPairFlags getContactReportFlags(const physx::PxShape* shape) const = 0;
00073 };
00074 #endif
00075 
00079 class SceneDesc : public ApexDesc
00080 {
00081 public:
00082 
00083     PX_INLINE SceneDesc() : ApexDesc()
00084     {
00085         init();
00086     }
00087 
00088     PX_INLINE void setToDefault()
00089     {
00090         ApexDesc::setToDefault();
00091         init();
00092     }
00093 
00094 
00101     PxScene* scene;
00102 
00105     RenderDebugInterface* debugInterface;
00106 
00107 #if PX_PHYSICS_VERSION_MAJOR == 0
00108 
00115     PxCpuDispatcher* cpuDispatcher;
00116 
00123     PxGpuDispatcher* gpuDispatcher;
00124 
00125 #elif PX_PHYSICS_VERSION_MAJOR == 3
00126 
00129     PhysX3Interface* physX3Interface;
00130 
00131 #endif
00132 
00139     bool    useDebugRenderable;
00140 
00144     bool    debugVisualizeRemotely;
00145 
00149     bool    debugVisualizeLocally;
00150 
00154     bool    useCuda;
00155 
00156 private:
00157     PX_INLINE void init()
00158     {
00159 #if PX_PHYSICS_VERSION_MAJOR == 0
00160         cpuDispatcher = 0;
00161         gpuDispatcher = 0;
00162 #elif PX_PHYSICS_VERSION_MAJOR == 3
00163         physX3Interface = 0;
00164 #endif
00165         scene = 0;
00166         debugInterface = 0;
00167         useDebugRenderable = false;
00168         debugVisualizeRemotely = false;
00169         debugVisualizeLocally = true;
00170 #if APEX_CUDA_SUPPORT
00171         useCuda = true;
00172 #else
00173         useCuda = false;
00174 #endif
00175     }
00176 };
00177 
00178 
00182 struct StatDataType
00183 {
00187     enum Enum
00188     {
00189         INVALID = 0,
00190         STRING  = 1,
00191         INT     = 2,
00192         FLOAT   = 3,
00193         ENUM    = 4,
00194         BOOL    = 5,
00195     };
00196 };
00197 
00201 typedef struct oaValueStruct
00202 {
00203     union
00204     {
00205         char*           String;
00206         int32_t         Int;
00207         float           Float;
00208         char*           Enum;
00209         bool            Bool;
00210     };
00211 } StatValue;
00212 
00216 typedef struct
00217 {
00219     const char*         StatName;
00220 
00222     StatDataType::Enum  StatType;
00223 
00225     StatValue           StatCurrentValue;
00226 } StatsInfo;
00227 
00231 struct SceneStats
00232 {
00235     uint32_t            numApexStats;
00238     StatsInfo*          ApexStatsInfoPtr;
00239 };
00240 
00249 struct ViewMatrixType
00250 {
00254     enum Enum
00255     {
00256         USER_CUSTOMIZED = 0,
00257         LOOK_AT_RH,
00258         LOOK_AT_LH,
00259     };
00260 };
00261 
00268 struct ProjMatrixType
00269 {
00273     enum Enum
00274     {
00275         USER_CUSTOMIZED = 0,
00276     };
00277 };
00278 
00282 struct UserBoundingBoxFlags
00283 {
00287     enum Enum
00288     {
00289         NONE    = 1 << 0,
00290         ENTER   = 1 << 1,
00291         LEAVE   = 1 << 2
00292     };
00293 };
00294 
00298 class Scene : public Renderable, public Context, public ApexInterface
00299 {
00300 public:
00301 
00302 #if PX_PHYSICS_VERSION_MAJOR == 3
00303 
00311     virtual void setPhysXScene(PxScene* s) = 0;
00312 
00316     virtual PxScene* getPhysXScene() const = 0;
00317 
00318 #endif
00319 
00323     virtual const SceneStats* getStats(void) const = 0;
00324 
00351     virtual void simulate(float elapsedTime, 
00352                           bool finalStep = true, 
00353                           PxBaseTask *completionTask = NULL,
00354                           void* scratchMemBlock = 0, 
00355                           uint32_t scratchMemBlockSize = 0) = 0;
00356 
00366     virtual bool fetchResults(bool block, uint32_t* errorState) = 0;
00367 
00371     virtual const PxRenderBuffer* getRenderBuffer() const = 0;
00372 
00376     virtual const PxRenderBuffer* getRenderBufferScreenSpace() const = 0;
00377 
00384     virtual bool checkResults(bool block) const = 0;
00385 
00399     virtual uint32_t allocViewMatrix(ViewMatrixType::Enum) = 0;
00400 
00413     virtual uint32_t allocProjMatrix(ProjMatrixType::Enum) = 0;
00414 
00418     virtual uint32_t getNumViewMatrices() const = 0;
00419 
00423     virtual uint32_t getNumProjMatrices() const = 0;
00424 
00432     virtual void setViewMatrix(const PxMat44& viewTransform, const uint32_t viewID = 0) = 0;
00433 
00439     virtual PxMat44 getViewMatrix(const uint32_t viewID = 0) const = 0;
00440 
00447     virtual void setProjMatrix(const PxMat44& projTransform, const uint32_t projID = 0) = 0;
00448 
00454     virtual PxMat44 getProjMatrix(const uint32_t projID = 0) const = 0;
00455 
00459     virtual void setUseViewProjMatrix(const uint32_t viewID = 0, const uint32_t projID = 0) = 0;
00460 
00466     virtual void setViewParams(const PxVec3& eyePosition, const PxVec3& eyeDirection, const PxVec3& worldUpDirection = PxVec3(0, 1, 0), const uint32_t viewID = 0) = 0;
00467 
00473     virtual void setProjParams(float nearPlaneDistance, float farPlaneDistance, float fieldOfViewDegree, uint32_t viewportWidth, uint32_t viewportHeight, const uint32_t projID = 0) = 0;
00474 
00481     virtual PxVec3 getEyePosition(const uint32_t viewID = 0) const = 0;
00482 
00489     virtual PxVec3 getEyeDirection(const uint32_t viewID = 0) const = 0;
00490 
00494     virtual PxTaskManager* getTaskManager() const = 0;
00495 
00499     virtual void setUseDebugRenderable(bool state) = 0;
00500 
00504     virtual ::NvParameterized::Interface* getDebugRenderParams() const = 0;
00505 
00509     virtual ::NvParameterized::Interface* getModuleDebugRenderParams(const char* name) const = 0;
00510 
00514     virtual PxVec3 getGravity() const = 0;
00515 
00519     virtual void setGravity(const PxVec3& gravity) = 0;
00520 
00521 
00522 #if PX_PHYSICS_VERSION_MAJOR == 3
00523 
00531     virtual void lockRead(const char *fileName,uint32_t lineo) = 0;
00532 
00541     virtual void lockWrite(const char *fileName,uint32_t lineno) = 0;
00542 
00546     virtual void unlockRead() = 0;
00547 
00551     virtual void unlockWrite() = 0;
00552 
00565     virtual void addActorPair(PxActor *actor0,PxActor *actor1) = 0;
00566 
00573     virtual void removeActorPair(PxActor *actor0,PxActor *actor1) = 0;
00574 
00586     virtual bool findActorPair(PxActor *actor0,PxActor *actor1) const = 0;
00587 
00588 
00599     virtual MirrorScene *createMirrorScene(nvidia::apex::Scene &mirrorScene,
00600         MirrorScene::MirrorFilter &mirrorFilter,
00601         float mirrorStaticDistance,
00602         float mirrorDynamicDistance,
00603         float mirrorRefreshDistance) = 0;
00604 #endif
00605 
00606 
00615     virtual void addBoundingBox(const PxBounds3& bounds, UserBoundingBoxFlags::Enum flags) = 0;
00616 
00623     virtual const PxBounds3 getBoundingBox(const uint32_t index) const = 0;
00624 
00631     virtual UserBoundingBoxFlags::Enum getBoundingBoxFlags(const uint32_t index) const = 0;
00632 
00636     virtual uint32_t getBoundingBoxCount() const = 0;
00637 
00643     virtual void  removeBoundingBox(const uint32_t index) = 0;
00644 
00648     virtual void  removeAllBoundingBoxes() = 0;
00649 
00653     virtual void* getCudaTestManager() const = 0;
00654     
00658     virtual void* getCudaProfileManager() const = 0;
00659 
00665     virtual void setCudaKernelCheckEnabled(bool enabled) = 0;
00666     
00670     virtual bool getCudaKernelCheckEnabled() const = 0;
00671 
00672 #if APEX_UE4
00673 
00676     virtual void updateGravity() = 0;
00677 #endif
00678 };
00679 
00680 
00681 PX_POP_PACK
00682 
00683 }
00684 } // end namespace nvidia::apex
00685 
00686 #endif // SCENE_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.