Panda3D
physxPlaneShape.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 physxPlaneShape.h
10  * @author enn0x
11  * @date 2009-09-16
12  */
13 
14 #ifndef PHYSXPLANESHAPE_H
15 #define PHYSXPLANESHAPE_H
16 
17 #include "pandabase.h"
18 #include "luse.h"
19 
20 #include "physxShape.h"
21 #include "physx_includes.h"
22 
24 
25 /**
26  * A plane collision detection primitive. By default it is configured to be
27  * the y == 0 plane. You can then set a normal and a d to specify an
28  * arbitrary plane. d is the distance of the plane from the origin along the
29  * normal, assuming the normal is normalized. Thus the plane equation is:
30  * normal.x * X + normal.y * Y + normal.z * Z = d
31  *
32  * Note: the plane does not represent an infinitely thin object, but rather a
33  * completely solid negative half space (all points p for which normal.dot(p)
34  * - d < 0 are inside the solid region.)
35  *
36  * Each shape is owned by an actor that it is attached to.
37  *
38  * An instance can be created by calling the createShape() method of the
39  * PhysxActor object that should own it, with a PhysxPlaneShapeDesc object as
40  * the parameter, or by adding the shape descriptor into the PhysxActorDesc
41  * class before creating the actor.
42  *
43  * The shape is deleted by calling release() on the shape itself.
44  */
45 class EXPCL_PANDAPHYSX PhysxPlaneShape : public PhysxShape {
46 
47 PUBLISHED:
48  INLINE PhysxPlaneShape();
49  INLINE ~PhysxPlaneShape();
50 
51  void save_to_desc(PhysxPlaneShapeDesc &shapeDesc) const;
52 
53  void set_plane(const LVector3f &normal, float d);
54 
55 public:
56  INLINE NxShape *ptr() const { return (NxShape *)_ptr; };
57 
58  void link(NxShape *shapePtr);
59  void unlink();
60 
61 private:
62  NxPlaneShape *_ptr;
63 
64 public:
65  static TypeHandle get_class_type() {
66  return _type_handle;
67  }
68  static void init_type() {
69  PhysxShape::init_type();
70  register_type(_type_handle, "PhysxPlaneShape",
71  PhysxShape::get_class_type());
72  }
73  virtual TypeHandle get_type() const {
74  return get_class_type();
75  }
76  virtual TypeHandle force_init_type() {
77  init_type();
78  return get_class_type();
79  }
80 
81 private:
82  static TypeHandle _type_handle;
83 };
84 
85 #include "physxPlaneShape.I"
86 
87 #endif // PHYSXPLANESHAPE_H
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
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Abstract base class for shapes.
Definition: physxShape.h:39
A plane collision detection primitive.
Descriptor class for PhysxPlaneShape.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81