Panda3D
 All Classes Functions Variables Enumerations
transform2sg.cxx
1 // Filename: transform2sg.cxx
2 // Created by: drose (12Mar02)
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 #include "transform2sg.h"
16 #include "transformState.h"
17 #include "dataNodeTransmit.h"
18 #include "dataGraphTraverser.h"
19 
20 
21 TypeHandle Transform2SG::_type_handle;
22 
23 ////////////////////////////////////////////////////////////////////
24 // Function: Transform2SG::Constructor
25 // Access: Public
26 // Description:
27 ////////////////////////////////////////////////////////////////////
28 Transform2SG::
29 Transform2SG(const string &name) :
30  DataNode(name)
31 {
32  _transform_input = define_input("transform", TransformState::get_class_type());
33 
34  _node = NULL;
35 }
36 
37 ////////////////////////////////////////////////////////////////////
38 // Function: Transform2SG::set_node
39 // Access: Public
40 // Description: Sets the node that this object will adjust.
41 ////////////////////////////////////////////////////////////////////
42 void Transform2SG::
44  _node = node;
45 }
46 
47 ////////////////////////////////////////////////////////////////////
48 // Function: Transform2SG::get_node
49 // Access: Public
50 // Description: Returns the node that this object will adjust, or NULL
51 // if the node has not yet been set.
52 ////////////////////////////////////////////////////////////////////
54 get_node() const {
55  return _node;
56 }
57 
58 
59 ////////////////////////////////////////////////////////////////////
60 // Function: Transform2SG::do_transmit_data
61 // Access: Protected, Virtual
62 // Description: The virtual implementation of transmit_data(). This
63 // function receives an array of input parameters and
64 // should generate an array of output parameters. The
65 // input parameters may be accessed with the index
66 // numbers returned by the define_input() calls that
67 // were made earlier (presumably in the constructor);
68 // likewise, the output parameters should be set with
69 // the index numbers returned by the define_output()
70 // calls.
71 ////////////////////////////////////////////////////////////////////
72 void Transform2SG::
73 do_transmit_data(DataGraphTraverser *trav, const DataNodeTransmit &input,
74  DataNodeTransmit &) {
75  Thread *current_thread = trav->get_current_thread();
76 
77  if (input.has_data(_transform_input)) {
78  const TransformState *transform;
79  DCAST_INTO_V(transform, input.get_data(_transform_input).get_ptr());
80  if (_node != (PandaNode *)NULL) {
81  _node->set_transform(transform, current_thread);
82  }
83  }
84 }
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
The fundamental type of node for the data graph.
Definition: dataNode.h:64
PandaNode * get_node() const
Returns the node that this object will adjust, or NULL if the node has not yet been set...
void set_node(PandaNode *node)
Sets the node that this object will adjust.
const EventParameter & get_data(int index) const
Extracts the data for the indicated index, if it has been stored, or the empty parameter if it has no...
A thread; that is, a lightweight process.
Definition: thread.h:51
TypedWritableReferenceCount * get_ptr() const
Retrieves a pointer to the actual value stored in the parameter.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
bool has_data(int index) const
Returns true if the indicated parameter has been stored, false otherwise.
Encapsulates the data generated from (or sent into) any particular DataNode.
Thread * get_current_thread() const
Returns the currently-executing thread object, as passed to the DataGraphTraverser constructor...
This object supervises the traversal of the data graph and the moving of data from one DataNode to it...