Panda3D
physxShape.h
1 // Filename: physxShape.h
2 // Created by: enn0x (16Sep09)
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 PHYSXSHAPE_H
16 #define PHYSXSHAPE_H
17 
18 #include "pandabase.h"
19 #include "pointerTo.h"
20 #include "luse.h"
21 
22 #include "physxObject.h"
23 #include "physxEnums.h"
24 #include "physx_includes.h"
25 
26 class PhysxActor;
27 class PhysxMaterial;
28 class PhysxGroupsMask;
29 class PhysxBounds3;
30 class PhysxSphere;
31 class PhysxBox;
32 class PhysxCapsule;
33 class PhysxRay;
34 class PhysxRaycastHit;
35 class PhysxCcdSkeleton;
36 
37 ////////////////////////////////////////////////////////////////////
38 // Class : PhysxShape
39 // Description : Abstract base class for shapes.
40 ////////////////////////////////////////////////////////////////////
41 class EXPCL_PANDAPHYSX PhysxShape : public PhysxObject, public PhysxEnums {
42 
43 PUBLISHED:
44  void release();
45 
46  PhysxActor *get_actor() const;
47 
48  void set_name(const char *name);
49  void set_flag(const PhysxShapeFlag flag, bool value);
50  void set_skin_width(float skinWidth);
51  void set_group(unsigned short group);
52  void set_local_pos(const LPoint3f &pos);
53  void set_local_mat(const LMatrix4f &mat);
54  void set_material(const PhysxMaterial &material);
55  void set_material_index(unsigned short idx);
56  void set_groups_mask(const PhysxGroupsMask &mask);
57  void set_ccd_skeleton(PhysxCcdSkeleton *skel);
58 
59  const char *get_name() const;
60  bool get_flag(const PhysxShapeFlag flag) const;
61  float get_skin_width() const;
62  unsigned short get_group() const;
63  LPoint3f get_local_pos() const;
64  LMatrix4f get_local_mat() const;
65  unsigned short get_material_index() const;
66  PhysxGroupsMask get_groups_mask() const;
67  PhysxBounds3 get_world_bounds() const;
68  PhysxCcdSkeleton *get_ccd_skeleton() const;
69 
70  bool check_overlap_aabb(const PhysxBounds3 &world_bounds) const;
71  bool check_overlap_capsule(const PhysxCapsule &world_capsule) const;
72  bool check_overlap_obb(const PhysxBox &world_box) const;
73  bool check_overlap_sphere(const PhysxSphere &world_sphere) const;
74  PhysxRaycastHit raycast(const PhysxRay &worldRay, bool firstHit, bool smoothNormal) const;
75 
76  INLINE void ls() const;
77  INLINE void ls(ostream &out, int indent_level=0) const;
78 
79 public:
80  static PhysxShape *factory(NxShapeType shapeType);
81 
82  virtual NxShape *ptr() const = 0;
83 
84  virtual void link(NxShape *shapePtr) = 0;
85  virtual void unlink() = 0;
86 
87 protected:
88  INLINE PhysxShape();
89 
90 private:
91  string _name;
92  PT(PhysxCcdSkeleton) _skel;
93 
94 ////////////////////////////////////////////////////////////////////
95 public:
96  static TypeHandle get_class_type() {
97  return _type_handle;
98  }
99  static void init_type() {
100  PhysxObject::init_type();
101  register_type(_type_handle, "PhysxShape",
102  PhysxObject::get_class_type());
103  }
104  virtual TypeHandle get_type() const {
105  return get_class_type();
106  }
107  virtual TypeHandle force_init_type() {
108  init_type();
109  return get_class_type();
110  }
111 
112 private:
113  static TypeHandle _type_handle;
114 };
115 
116 #include "physxShape.I"
117 
118 #endif // PHYSXSHAPE_H
Represents a sphere defined by its center point and radius.
Definition: physxSphere.h:28
Represents an oriented bounding box, as a center point, extents(radii) and a rotation.
Definition: physxBox.h:32
Abstract base class for shapes.
Definition: physxShape.h:41
Represention of a axis aligned bounding box.
Definition: physxBounds3.h:32
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
A class for describing a shape's surface properties.
Definition: physxMaterial.h:51
This structure captures results for a single raycast query.
This class exists just to provide scoping for the enums shared by PhysX classes.
Definition: physxEnums.h:357
This is a 4-by-4 transform matrix.
Definition: lmatrix.h:451
Represents a capsule.
Definition: physxCapsule.h:27
Actors are the main simulation objects.
Definition: physxActor.h:48
A Convex Mesh.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
Represents an ray as an origin and direction.
Definition: physxRay.h:28
128-bit bitmask class.