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