actorNode.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. #ifndef ACTORNODE_H
  15. #define ACTORNODE_H
  16. #include "pandabase.h"
  17. #include "physicalNode.h"
  18. ////////////////////////////////////////////////////////////////////
  19. // Class : ActorNode
  20. // Description : Like a physical node, but with a little more. The
  21. // actornode assumes responsibility for its own
  22. // transform, and changes in its own PhysicsObject will
  23. // be reflected as transforms. This relation goes both
  24. // ways; changes in the transform will update the
  25. // object's position (shoves).
  26. ////////////////////////////////////////////////////////////////////
  27. class EXPCL_PANDAPHYSICS ActorNode : public PhysicalNode {
  28. PUBLISHED:
  29. ActorNode(const string &name = "");
  30. ActorNode(const ActorNode &copy);
  31. virtual ~ActorNode();
  32. PhysicsObject *get_physics_object() { return _mass_center; }
  33. void set_contact_vector(const LVector3f &contact_vector);
  34. const LVector3f &get_contact_vector() const;
  35. // update the parent scene graph node with PhysicsObject information
  36. // i.e. copy from PhysicsObject to PandaNode
  37. void update_transform();
  38. void set_transform_limit(float limit) { _transform_limit = limit; };
  39. virtual void write(ostream &out, unsigned int indent=0) const;
  40. private:
  41. PhysicsObject *_mass_center;
  42. LVector3f _contact_vector;
  43. bool _ok_to_callback;
  44. float _transform_limit;
  45. // node hook if the client changes the node's transform.
  46. // i.e. copy from PandaNode to PhysicsObject
  47. virtual void transform_changed();
  48. void test_transform(const TransformState *ts) const;
  49. public:
  50. static TypeHandle get_class_type() {
  51. return _type_handle;
  52. }
  53. static void init_type() {
  54. PhysicalNode::init_type();
  55. register_type(_type_handle, "ActorNode",
  56. PhysicalNode::get_class_type());
  57. }
  58. virtual TypeHandle get_type() const {
  59. return get_class_type();
  60. }
  61. virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
  62. private:
  63. static TypeHandle _type_handle;
  64. };
  65. #include "actorNode.I"
  66. #endif // ACTORNODE_H