Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/tform/transform2sg.cxx

Go to the documentation of this file.
00001 // Filename: transform2sg.cxx
00002 // Created by:  drose (12Mar02)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #include "transform2sg.h"
00020 #include "transformState.h"
00021 
00022 
00023 TypeHandle Transform2SG::_type_handle;
00024 
00025 ////////////////////////////////////////////////////////////////////
00026 //     Function: Transform2SG::Constructor
00027 //       Access: Public
00028 //  Description:
00029 ////////////////////////////////////////////////////////////////////
00030 Transform2SG::
00031 Transform2SG(const string &name) :
00032   DataNode(name)
00033 {
00034   _transform_input = define_input("transform", EventStoreTransform::get_class_type());
00035   _velocity_input = define_input("velocity", EventStoreVec3::get_class_type());
00036 
00037   _node = NULL;
00038   _velocity_node = NULL;
00039 }
00040 
00041 ////////////////////////////////////////////////////////////////////
00042 //     Function: Transform2SG::set_node
00043 //       Access: Public
00044 //  Description: Sets the node that this object will adjust.
00045 ////////////////////////////////////////////////////////////////////
00046 void Transform2SG::
00047 set_node(PandaNode *node) {
00048   _node = node;
00049 }
00050 
00051 ////////////////////////////////////////////////////////////////////
00052 //     Function: Transform2SG::get_node
00053 //       Access: Public
00054 //  Description: Returns the node that this object will adjust, or NULL
00055 //               if the node has not yet been set.
00056 ////////////////////////////////////////////////////////////////////
00057 PandaNode *Transform2SG::
00058 get_node() const {
00059   return _node;
00060 }
00061 
00062 ////////////////////////////////////////////////////////////////////
00063 //     Function: Transform2SG::set_velocity_node
00064 //       Access: Public
00065 //  Description: Sets the node that this object will assign the
00066 //               computed velocity to.  Normally this is a
00067 //               CollisionNode parented below the node indicated by
00068 //               set_node().  Setting this node allows the collision
00069 //               system to track the velocity imparted to the
00070 //               CollisionNode by the data graph object that set its
00071 //               transform, if that data is available.
00072 ////////////////////////////////////////////////////////////////////
00073 void Transform2SG::
00074 set_velocity_node(PandaNode *node) {
00075   _velocity_node = node;
00076 }
00077 
00078 ////////////////////////////////////////////////////////////////////
00079 //     Function: Transform2SG::get_velocity_node
00080 //       Access: Public
00081 //  Description: Returns the node that this object will assign the
00082 //               computed velocity to.  See set_velocity_node().
00083 ////////////////////////////////////////////////////////////////////
00084 PandaNode *Transform2SG::
00085 get_velocity_node() const {
00086   return _velocity_node;
00087 }
00088 
00089 
00090 ////////////////////////////////////////////////////////////////////
00091 //     Function: Transform2SG::do_transmit_data
00092 //       Access: Protected, Virtual
00093 //  Description: The virtual implementation of transmit_data().  This
00094 //               function receives an array of input parameters and
00095 //               should generate an array of output parameters.  The
00096 //               input parameters may be accessed with the index
00097 //               numbers returned by the define_input() calls that
00098 //               were made earlier (presumably in the constructor);
00099 //               likewise, the output parameters should be set with
00100 //               the index numbers returned by the define_output()
00101 //               calls.
00102 ////////////////////////////////////////////////////////////////////
00103 void Transform2SG::
00104 do_transmit_data(const DataNodeTransmit &input, DataNodeTransmit &) {
00105   if (input.has_data(_transform_input)) {
00106     const EventStoreTransform *transform;
00107     DCAST_INTO_V(transform, input.get_data(_transform_input).get_ptr());
00108     CPT(TransformState) ts = transform->get_value();
00109     if (_node != (PandaNode *)NULL) {
00110       _node->set_transform(ts);
00111     }
00112   }
00113 
00114   if (input.has_data(_velocity_input)) {
00115     const EventStoreVec3 *velocity;
00116     DCAST_INTO_V(velocity, input.get_data(_velocity_input).get_ptr());
00117     LVector3f vel = velocity->get_value();
00118     if (_velocity_node != (PandaNode *)NULL) {
00119       _velocity_node->set_velocity(vel);
00120     }
00121   }
00122 }

Generated on Fri May 2 00:44:31 2003 for Panda by doxygen1.3