Panda3D
bulletCapsuleShape.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 bulletCapsuleShape.h
10  * @author enn0x
11  * @date 2010-01-27
12  */
13 
14 #ifndef __BULLET_CAPSULE_SHAPE_H__
15 #define __BULLET_CAPSULE_SHAPE_H__
16 
17 #include "pandabase.h"
18 
19 #include "bullet_includes.h"
20 #include "bullet_utils.h"
21 #include "bulletShape.h"
22 
23 #include "collisionCapsule.h"
24 
25 /**
26  *
27  */
28 class EXPCL_PANDABULLET BulletCapsuleShape : public BulletShape {
29 private:
30  // Only used by make_from_bam
31  INLINE BulletCapsuleShape();
32 
33 PUBLISHED:
34  explicit BulletCapsuleShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up=Z_up);
36  INLINE ~BulletCapsuleShape();
37 
38  static BulletCapsuleShape *make_from_solid(const CollisionCapsule *solid);
39 
40  INLINE PN_stdfloat get_radius() const;
41  INLINE PN_stdfloat get_half_height() const;
42 
43 public:
44  INLINE PN_stdfloat get_height() const;
45 
46  virtual btCollisionShape *ptr() const;
47 
48 PUBLISHED:
49  MAKE_PROPERTY(radius, get_radius);
50  MAKE_PROPERTY(height, get_height);
51 
52 private:
53  btCapsuleShape *_shape;
54  PN_stdfloat _radius;
55  PN_stdfloat _height;
56  BulletUpAxis _up;
57 
58 public:
59  static void register_with_read_factory();
60  virtual void write_datagram(BamWriter *manager, Datagram &dg);
61 
62 protected:
63  static TypedWritable *make_from_bam(const FactoryParams &params);
64  void fillin(DatagramIterator &scan, BamReader *manager);
65 
66 public:
67  static TypeHandle get_class_type() {
68  return _type_handle;
69  }
70  static void init_type() {
71  BulletShape::init_type();
72  register_type(_type_handle, "BulletCapsuleShape",
73  BulletShape::get_class_type());
74  }
75  virtual TypeHandle get_type() const {
76  return get_class_type();
77  }
78  virtual TypeHandle force_init_type() {
79  init_type();
80  return get_class_type();
81  }
82 
83 private:
84  static TypeHandle _type_handle;
85 };
86 
87 #include "bulletCapsuleShape.I"
88 
89 #endif // __BULLET_CAPSULE_SHAPE_H__
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
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.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
virtual void fillin(DatagramIterator &scan, BamReader *manager)
This internal function is intended to be called by each class's make_from_bam() method to read in all...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
This implements a solid consisting of a cylinder with hemispherical endcaps, also known as a capsule ...
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:36
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A class to retrieve the individual data elements previously stored in a Datagram.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38