Panda3D

Loading...
Searching...
No Matches
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 */
25Transform2SG::
26Transform2SG(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::
38 set_node(PandaNode *node) {
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 */
46PandaNode *Transform2SG::
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::
61do_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}
DataGraphTraverser
This object supervises the traversal of the data graph and the moving of data from one DataNode to it...
Definition dataGraphTraverser.h:32
DataGraphTraverser::get_current_thread
Thread * get_current_thread() const
Returns the currently-executing thread object, as passed to the DataGraphTraverser constructor.
Definition dataGraphTraverser.I:19
DataNodeTransmit
Encapsulates the data generated from (or sent into) any particular DataNode.
Definition dataNodeTransmit.h:32
DataNodeTransmit::get_data
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...
Definition dataNodeTransmit.I:52
DataNodeTransmit::has_data
bool has_data(int index) const
Returns true if the indicated parameter has been stored, false otherwise.
Definition dataNodeTransmit.I:64
DataNode
The fundamental type of node for the data graph.
Definition dataNode.h:52
EventParameter::get_ptr
TypedWritableReferenceCount * get_ptr() const
Retrieves a pointer to the actual value stored in the parameter.
Definition eventParameter.I:219
Thread
A thread; that is, a lightweight process.
Definition thread.h:46
Transform2SG::get_node
PandaNode * get_node() const
Returns the node that this object will adjust, or NULL if the node has not yet been set.
Definition transform2sg.cxx:47
Transform2SG::set_node
void set_node(PandaNode *node)
Sets the node that this object will adjust.
Definition transform2sg.cxx:38
TransformState
Indicates a coordinate-system transform on vertices.
Definition transformState.h:54
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
dataGraphTraverser.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
dataNodeTransmit.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
transform2sg.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
transformState.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.