00001 // Filename: transform2sg.cxx 00002 // Created by: drose (12Mar02) 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 #include "transform2sg.h" 00016 #include "transformState.h" 00017 #include "dataNodeTransmit.h" 00018 #include "dataGraphTraverser.h" 00019 00020 00021 TypeHandle Transform2SG::_type_handle; 00022 00023 //////////////////////////////////////////////////////////////////// 00024 // Function: Transform2SG::Constructor 00025 // Access: Public 00026 // Description: 00027 //////////////////////////////////////////////////////////////////// 00028 Transform2SG:: 00029 Transform2SG(const string &name) : 00030 DataNode(name) 00031 { 00032 _transform_input = define_input("transform", TransformState::get_class_type()); 00033 00034 _node = NULL; 00035 } 00036 00037 //////////////////////////////////////////////////////////////////// 00038 // Function: Transform2SG::set_node 00039 // Access: Public 00040 // Description: Sets the node that this object will adjust. 00041 //////////////////////////////////////////////////////////////////// 00042 void Transform2SG:: 00043 set_node(PandaNode *node) { 00044 _node = node; 00045 } 00046 00047 //////////////////////////////////////////////////////////////////// 00048 // Function: Transform2SG::get_node 00049 // Access: Public 00050 // Description: Returns the node that this object will adjust, or NULL 00051 // if the node has not yet been set. 00052 //////////////////////////////////////////////////////////////////// 00053 PandaNode *Transform2SG:: 00054 get_node() const { 00055 return _node; 00056 } 00057 00058 00059 //////////////////////////////////////////////////////////////////// 00060 // Function: Transform2SG::do_transmit_data 00061 // Access: Protected, Virtual 00062 // Description: The virtual implementation of transmit_data(). This 00063 // function receives an array of input parameters and 00064 // should generate an array of output parameters. The 00065 // input parameters may be accessed with the index 00066 // numbers returned by the define_input() calls that 00067 // were made earlier (presumably in the constructor); 00068 // likewise, the output parameters should be set with 00069 // the index numbers returned by the define_output() 00070 // calls. 00071 //////////////////////////////////////////////////////////////////// 00072 void Transform2SG:: 00073 do_transmit_data(DataGraphTraverser *trav, const DataNodeTransmit &input, 00074 DataNodeTransmit &) { 00075 Thread *current_thread = trav->get_current_thread(); 00076 00077 if (input.has_data(_transform_input)) { 00078 const TransformState *transform; 00079 DCAST_INTO_V(transform, input.get_data(_transform_input).get_ptr()); 00080 if (_node != (PandaNode *)NULL) { 00081 _node->set_transform(transform, current_thread); 00082 } 00083 } 00084 }