Panda3D
|
00001 // Filename: actorNode.h 00002 // Created by: charles (07Aug00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef ACTORNODE_H 00016 #define ACTORNODE_H 00017 00018 #include "pandabase.h" 00019 #include "physicalNode.h" 00020 00021 //////////////////////////////////////////////////////////////////// 00022 // Class : ActorNode 00023 // Description : Like a physical node, but with a little more. The 00024 // actornode assumes responsibility for its own 00025 // transform, and changes in its own PhysicsObject will 00026 // be reflected as transforms. This relation goes both 00027 // ways; changes in the transform will update the 00028 // object's position (shoves). 00029 //////////////////////////////////////////////////////////////////// 00030 class EXPCL_PANDAPHYSICS ActorNode : public PhysicalNode { 00031 PUBLISHED: 00032 ActorNode(const string &name = ""); 00033 ActorNode(const ActorNode ©); 00034 virtual ~ActorNode(); 00035 00036 PhysicsObject *get_physics_object() { return _mass_center; } 00037 00038 void set_contact_vector(const LVector3 &contact_vector); 00039 const LVector3 &get_contact_vector() const; 00040 00041 // update the parent scene graph node with PhysicsObject information 00042 // i.e. copy from PhysicsObject to PandaNode 00043 void update_transform(); 00044 00045 void set_transform_limit(PN_stdfloat limit) { _transform_limit = limit; }; 00046 virtual void write(ostream &out, unsigned int indent=0) const; 00047 00048 private: 00049 PhysicsObject *_mass_center; 00050 LVector3 _contact_vector; 00051 bool _ok_to_callback; 00052 PN_stdfloat _transform_limit; 00053 00054 // node hook if the client changes the node's transform. 00055 // i.e. copy from PandaNode to PhysicsObject 00056 virtual void transform_changed(); 00057 void test_transform(const TransformState *ts) const; 00058 00059 public: 00060 static TypeHandle get_class_type() { 00061 return _type_handle; 00062 } 00063 static void init_type() { 00064 PhysicalNode::init_type(); 00065 register_type(_type_handle, "ActorNode", 00066 PhysicalNode::get_class_type()); 00067 } 00068 virtual TypeHandle get_type() const { 00069 return get_class_type(); 00070 } 00071 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00072 00073 private: 00074 static TypeHandle _type_handle; 00075 00076 }; 00077 00078 #include "actorNode.I" 00079 00080 #endif // ACTORNODE_H