Panda3D
transform2sg.cxx
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file transform2sg.cxx
10  * @author drose
11  * @date 2002-03-12
12  */
13 
14 #include "transform2sg.h"
15 #include "transformState.h"
16 #include "dataNodeTransmit.h"
17 #include "dataGraphTraverser.h"
18 
19 
20 TypeHandle Transform2SG::_type_handle;
21 
22 /**
23  *
24  */
25 Transform2SG::
26 Transform2SG(const std::string &name) :
27  DataNode(name)
28 {
29  _transform_input = define_input("transform", TransformState::get_class_type());
30 
31  _node = nullptr;
32 }
33 
34 /**
35  * Sets the node that this object will adjust.
36  */
37 void Transform2SG::
39  _node = node;
40 }
41 
42 /**
43  * Returns the node that this object will adjust, or NULL if the node has not
44  * yet been set.
45  */
47 get_node() const {
48  return _node;
49 }
50 
51 
52 /**
53  * The virtual implementation of transmit_data(). This function receives an
54  * array of input parameters and should generate an array of output
55  * parameters. The input parameters may be accessed with the index numbers
56  * returned by the define_input() calls that were made earlier (presumably in
57  * the constructor); likewise, the output parameters should be set with the
58  * index numbers returned by the define_output() calls.
59  */
60 void Transform2SG::
61 do_transmit_data(DataGraphTraverser *trav, const DataNodeTransmit &input,
62  DataNodeTransmit &) {
63  Thread *current_thread = trav->get_current_thread();
64 
65  if (input.has_data(_transform_input)) {
66  const TransformState *transform;
67  DCAST_INTO_V(transform, input.get_data(_transform_input).get_ptr());
68  if (_node != nullptr) {
69  _node->set_transform(transform, current_thread);
70  }
71  }
72 }
PandaNode * get_node() const
Returns the node that this object will adjust, or NULL if the node has not yet been set.
A basic node of the scene graph or data graph.
Definition: pandaNode.h:64
The fundamental type of node for the data graph.
Definition: dataNode.h:52
Indicates a coordinate-system transform on vertices.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void set_node(PandaNode *node)
Sets the node that this object will adjust.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool has_data(int index) const
Returns true if the indicated parameter has been stored, false otherwise.
Thread * get_current_thread() const
Returns the currently-executing thread object, as passed to the DataGraphTraverser constructor.
TypedWritableReferenceCount * get_ptr() const
Retrieves a pointer to the actual value stored in the parameter.
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:46
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
Encapsulates the data generated from (or sent into) any particular DataNode.
This object supervises the traversal of the data graph and the moving of data from one DataNode to it...