Panda3D
actorNode.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 actorNode.h
10  * @author charles
11  * @date 2000-08-07
12  */
13 
14 #ifndef ACTORNODE_H
15 #define ACTORNODE_H
16 
17 #include "pandabase.h"
18 #include "physicalNode.h"
19 
20 /**
21  * Like a physical node, but with a little more. The actornode assumes
22  * responsibility for its own transform, and changes in its own PhysicsObject
23  * will be reflected as transforms. This relation goes both ways; changes in
24  * the transform will update the object's position (shoves).
25  */
26 class EXPCL_PANDA_PHYSICS ActorNode : public PhysicalNode {
27 PUBLISHED:
28  explicit ActorNode(const std::string &name = "");
29  ActorNode(const ActorNode &copy);
30  virtual ~ActorNode();
31 
32  PhysicsObject *get_physics_object() { return _mass_center; }
33 
34  void set_contact_vector(const LVector3 &contact_vector);
35  const LVector3 &get_contact_vector() const;
36 
37  // update the parent scene graph node with PhysicsObject information i.e.
38  // copy from PhysicsObject to PandaNode
39  void update_transform();
40 
41  void set_transform_limit(PN_stdfloat limit) { _transform_limit = limit; };
42  virtual void write(std::ostream &out, int indent=0) const;
43 
44 private:
45  PhysicsObject *_mass_center;
46  LVector3 _contact_vector;
47  bool _ok_to_callback;
48  PN_stdfloat _transform_limit;
49 
50  // node hook if the client changes the node's transform. i.e. copy from
51  // PandaNode to PhysicsObject
52  virtual void transform_changed();
53  void test_transform(const TransformState *ts) const;
54 
55 public:
56  static TypeHandle get_class_type() {
57  return _type_handle;
58  }
59  static void init_type() {
60  PhysicalNode::init_type();
61  register_type(_type_handle, "ActorNode",
62  PhysicalNode::get_class_type());
63  }
64  virtual TypeHandle get_type() const {
65  return get_class_type();
66  }
67  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
68 
69 private:
70  static TypeHandle _type_handle;
71 
72 };
73 
74 #include "actorNode.I"
75 
76 #endif // ACTORNODE_H
Indicates a coordinate-system transform on vertices.
A body on which physics will be applied.
Definition: physicsObject.h:27
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void write(std::ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
Graph node that encapsulated a series of physical objects.
Definition: physicalNode.h:28
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
Definition: indent.cxx:20
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
Like a physical node, but with a little more.
Definition: actorNode.h:26