Panda3D
physxManager.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file physxManager.h
10  * @author enn0x
11  * @date 2009-09-01
12  */
13 
14 #ifndef PHYSXMANAGER_H
15 #define PHYSXMANAGER_H
16 
17 #include "pandabase.h"
18 #include "pointerTo.h"
19 #include "luse.h"
20 
21 #include "physxEnums.h"
22 #include "physxObjectCollection.h"
23 #include "physx_includes.h"
24 
25 class PhysxScene;
26 class PhysxSceneDesc;
27 class PhysxHeightField;
29 class PhysxTriangleMesh;
30 class PhysxConvexMesh;
31 class PhysxClothMesh;
32 class PhysxSoftBodyMesh;
33 class PhysxOutputStream;
34 class PhysxCcdSkeleton;
36 
37 /**
38  * The central interface to the PhysX subsystem. Used e. g. for
39  * setting/retrieving global parameters or for creating scenes.
40  */
41 class EXPCL_PANDAPHYSX PhysxManager : public PhysxEnums {
42 
43 protected:
44  PhysxManager();
45 
46 public:
47  ~PhysxManager();
48 
49 PUBLISHED:
50  static PhysxManager *get_global_ptr();
51 
52  void set_parameter(PhysxParameter param, float value);
53  float get_parameter(PhysxParameter param);
54 
55  bool is_hardware_available();
56  unsigned int get_num_ppus();
57  unsigned int get_hw_version();
58  const char *get_internal_version();
59 
60  unsigned int get_num_scenes() const;
61  PhysxScene *create_scene(PhysxSceneDesc &desc);
62  PhysxScene *get_scene(unsigned int idx) const;
63  MAKE_SEQ(get_scenes, get_num_scenes, get_scene);
64 
65  unsigned int get_num_height_fields();
66  PhysxHeightField *create_height_field(PhysxHeightFieldDesc &desc);
67  PhysxHeightField *get_height_field(unsigned int idx);
68  MAKE_SEQ(get_height_fields, get_num_height_fields, get_height_field);
69 
70  unsigned int get_num_convex_meshes();
71  PhysxConvexMesh *get_convex_mesh(unsigned int idx);
72  MAKE_SEQ(get_convex_meshes, get_num_convex_meshes, get_convex_mesh);
73 
74  unsigned int get_num_triangle_meshes();
75  PhysxTriangleMesh *get_triangle_mesh(unsigned int idx);
76  MAKE_SEQ(get_triangle_meshes, get_num_triangle_meshes, get_triangle_mesh);
77 
78  unsigned int get_num_cloth_meshes();
79  PhysxClothMesh *get_cloth_mesh(unsigned int idx);
80  MAKE_SEQ(get_cloth_meshes, get_num_cloth_meshes, get_cloth_mesh);
81 
82  unsigned int get_num_soft_body_meshes();
83  PhysxSoftBodyMesh *get_soft_body_mesh(unsigned int idx);
84  MAKE_SEQ(get_soft_body_meshes, get_num_soft_body_meshes, get_soft_body_mesh);
85 
86  unsigned int get_num_ccd_skeletons();
87  PhysxCcdSkeleton *create_ccd_skeleton(PhysxCcdSkeletonDesc &desc);
88  PhysxCcdSkeleton *get_ccd_skeleton(unsigned int idx);
89  MAKE_SEQ(get_ccd_skeletons, get_num_ccd_skeletons, get_ccd_skeleton);
90 
91  INLINE void ls() const;
92  INLINE void ls(std::ostream &out, int indent_level=0) const;
93 
94 public:
95  INLINE NxPhysicsSDK *get_sdk() const;
96 
104 
105  INLINE static NxVec3 vec3_to_nxVec3(const LVector3f &v);
106  INLINE static LVector3f nxVec3_to_vec3(const NxVec3 &v);
107  INLINE static NxExtendedVec3 vec3_to_nxExtVec3(const LVector3f &v);
108  INLINE static LVector3f nxExtVec3_to_vec3(const NxExtendedVec3 &v);
109  INLINE static NxVec3 point3_to_nxVec3(const LPoint3f &p);
110  INLINE static LPoint3f nxVec3_to_point3(const NxVec3 &p);
111  INLINE static NxExtendedVec3 point3_to_nxExtVec3(const LPoint3f &p);
112  INLINE static LPoint3f nxExtVec3_to_point3(const NxExtendedVec3 &p);
113  INLINE static NxQuat quat_to_nxQuat(const LQuaternionf &q);
114  INLINE static LQuaternionf nxQuat_to_quat(const NxQuat &q);
115  INLINE static NxMat34 mat4_to_nxMat34(const LMatrix4f &m);
116  INLINE static LMatrix4f nxMat34_to_mat4(const NxMat34 &m);
117  INLINE static NxMat33 mat3_to_nxMat33(const LMatrix3f &m);
118  INLINE static LMatrix3f nxMat33_to_mat3(const NxMat33 &m);
119 
120  INLINE static void update_vec3_from_nxVec3(LVector3f &v, const NxVec3 &nVec);
121  INLINE static void update_point3_from_nxVec3(LPoint3f &p, const NxVec3 &nVec);
122 
123 private:
124  NxPhysicsSDK *_sdk;
125 
126  static PhysxManager *_global_ptr;
127 
128  class PhysxOutputStream : public NxUserOutputStream {
129  void reportError(NxErrorCode code, const char *message, const char *file, int line);
130  NxAssertResponse reportAssertViolation(const char *message, const char *file, int line);
131  void print(const char *message);
132  const char *get_error_code_string(NxErrorCode code);
133  };
134  static PhysxOutputStream _outputStream;
135 
136  static const char *get_sdk_error_string(const NxSDKCreateError &error);
137 };
138 
139 #include "physxManager.I"
140 
141 #endif // PHYSXMANAGER_H
Descriptor for PhysxScene.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
The central interface to the PhysX subsystem.
Definition: physxManager.h:41
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A scene is a collection of bodies, constraints, and effectors which can interact.
Definition: physxScene.h:69
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Descriptor class for height fields.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This class exists just to provide scoping for the enums shared by PhysX classes.
Definition: physxEnums.h:355
A height field object.
A Convex Mesh.
A Convex Mesh.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.