Panda3D
 All Classes Functions Variables Enumerations
actorNode.h
1 // Filename: actorNode.h
2 // Created by: charles (07Aug00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef ACTORNODE_H
16 #define ACTORNODE_H
17 
18 #include "pandabase.h"
19 #include "physicalNode.h"
20 
21 ////////////////////////////////////////////////////////////////////
22 // Class : ActorNode
23 // Description : Like a physical node, but with a little more. The
24 // actornode assumes responsibility for its own
25 // transform, and changes in its own PhysicsObject will
26 // be reflected as transforms. This relation goes both
27 // ways; changes in the transform will update the
28 // object's position (shoves).
29 ////////////////////////////////////////////////////////////////////
30 class EXPCL_PANDAPHYSICS ActorNode : public PhysicalNode {
31 PUBLISHED:
32  ActorNode(const string &name = "");
33  ActorNode(const ActorNode &copy);
34  virtual ~ActorNode();
35 
36  PhysicsObject *get_physics_object() { return _mass_center; }
37 
38  void set_contact_vector(const LVector3 &contact_vector);
39  const LVector3 &get_contact_vector() const;
40 
41  // update the parent scene graph node with PhysicsObject information
42  // i.e. copy from PhysicsObject to PandaNode
43  void update_transform();
44 
45  void set_transform_limit(PN_stdfloat limit) { _transform_limit = limit; };
46  virtual void write(ostream &out, unsigned int indent=0) const;
47 
48 private:
49  PhysicsObject *_mass_center;
50  LVector3 _contact_vector;
51  bool _ok_to_callback;
52  PN_stdfloat _transform_limit;
53 
54  // node hook if the client changes the node's transform.
55  // i.e. copy from PandaNode to PhysicsObject
56  virtual void transform_changed();
57  void test_transform(const TransformState *ts) const;
58 
59 public:
60  static TypeHandle get_class_type() {
61  return _type_handle;
62  }
63  static void init_type() {
64  PhysicalNode::init_type();
65  register_type(_type_handle, "ActorNode",
66  PhysicalNode::get_class_type());
67  }
68  virtual TypeHandle get_type() const {
69  return get_class_type();
70  }
71  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
72 
73 private:
74  static TypeHandle _type_handle;
75 
76 };
77 
78 #include "actorNode.I"
79 
80 #endif // ACTORNODE_H
A body on which physics will be applied.
Definition: physicsObject.h:29
virtual void write(ostream &out, unsigned int indent=0) const
Write a string representation of this instance to <out>.
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
Definition: lvector3.h:100
Graph node that encapsulated a series of physical objects.
Definition: physicalNode.h:31
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
Like a physical node, but with a little more.
Definition: actorNode.h:30