Panda3D
bulletHeightfieldShape.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 bulletHeightfieldShape.h
10  * @author enn0x
11  * @date 2010-02-05
12  */
13 
14 #ifndef __BULLET_HEIGHTFIELD_SHAPE_H__
15 #define __BULLET_HEIGHTFIELD_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 "pnmImage.h"
24 #include "texture.h"
25 #include "texturePeeker.h"
26 
27 /**
28  *
29  */
30 class EXPCL_PANDABULLET BulletHeightfieldShape : public BulletShape {
31 private:
32  INLINE BulletHeightfieldShape();
33 
34 PUBLISHED:
35  explicit BulletHeightfieldShape(const PNMImage &image, PN_stdfloat max_height, BulletUpAxis up=Z_up);
36  explicit BulletHeightfieldShape(Texture *tex, PN_stdfloat max_height, BulletUpAxis up=Z_up);
38  INLINE ~BulletHeightfieldShape();
39 
40  void set_use_diamond_subdivision(bool flag=true);
41 
42 public:
43  virtual btCollisionShape *ptr() const;
44 
45 private:
46  int _num_rows;
47  int _num_cols;
48  btScalar *_data;
49  btHeightfieldTerrainShape *_shape;
50  PN_stdfloat _max_height;
51  BulletUpAxis _up;
52 
53 public:
54  static void register_with_read_factory();
55  virtual void write_datagram(BamWriter *manager, Datagram &dg);
56 
57 protected:
58  static TypedWritable *make_from_bam(const FactoryParams &params);
59  void fillin(DatagramIterator &scan, BamReader *manager);
60 
61 public:
62  static TypeHandle get_class_type() {
63  return _type_handle;
64  }
65  static void init_type() {
66  BulletShape::init_type();
67  register_type(_type_handle, "BulletHeightfieldShape",
68  BulletShape::get_class_type());
69  }
70  virtual TypeHandle get_type() const {
71  return get_class_type();
72  }
73  virtual TypeHandle force_init_type() {
74  init_type();
75  return get_class_type();
76  }
77 
78 private:
79  static TypeHandle _type_handle;
80 };
81 
82 #include "bulletHeightfieldShape.I"
83 
84 #endif // __BULLET_HEIGHTFIELD_SHAPE_H__
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pnmImage.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
DatagramIterator
A class to retrieve the individual data elements previously stored in a Datagram.
Definition: datagramIterator.h:27
register_type
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
BamReader
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
BamWriter
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
Texture
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Definition: texture.h:71
bullet_includes.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypedWritable
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
PNMImage
The name of this class derives from the fact that we originally implemented it as a layer on top of t...
Definition: pnmImage.h:58
Datagram
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38
BulletShape
Definition: bulletShape.h:27
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
FactoryParams
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:36
TypedWritable::write_datagram
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition: typedWritable.cxx:54
bullet_utils.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
BulletHeightfieldShape
Definition: bulletHeightfieldShape.h:30
bulletHeightfieldShape.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
texturePeeker.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bulletShape.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
texture.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypedWritable::fillin
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...
Definition: typedWritable.cxx:103