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