Panda3D

modelNode.h
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 modelNode.h
10 * @author drose
11 * @date 2002-03-16
12 */
13
14 #ifndef MODELNODE_H
15 #define MODELNODE_H
16
17 #include "pandabase.h"
18
19 #include "pandaNode.h"
20
21 /**
22 * This node is placed at key points within the scene graph to indicate the
23 * roots of "models": subtrees that are conceptually to be treated as a single
24 * unit, like a car or a room, for instance. It doesn't affect rendering or
25 * any other operations; it's primarily useful as a high-level model
26 * indication.
27 *
28 * ModelNodes are created in response to a <Model> { 1 } flag within an egg
29 * file.
30 */
31 class EXPCL_PANDA_PGRAPH ModelNode : public PandaNode {
32 PUBLISHED:
33 explicit INLINE ModelNode(const std::string &name);
34
35 protected:
36 INLINE ModelNode(const ModelNode &copy);
37
38 public:
39 virtual PandaNode *make_copy() const;
40
41 virtual PandaNode *combine_with(PandaNode *other);
42 virtual bool safe_to_flatten() const;
43 virtual bool safe_to_flatten_below() const;
44 virtual bool safe_to_transform() const;
45 virtual bool safe_to_modify_transform() const;
46 virtual bool safe_to_combine() const;
47 virtual bool preserve_name() const;
48 virtual int get_unsafe_to_apply_attribs() const;
49
50 PUBLISHED:
51 enum PreserveTransform {
52 PT_none,
53 PT_local,
54 PT_net,
55 PT_drop_node,
56 PT_no_touch,
57 };
58
59 INLINE void set_preserve_transform(PreserveTransform preserve_transform);
60 INLINE PreserveTransform get_preserve_transform() const;
61
62 INLINE void set_preserve_attributes(int attrib_mask);
63 INLINE int get_preserve_attributes() const;
64
65 void set_transform_limit(PN_stdfloat limit) { _transform_limit = limit; };
66
67 private:
68 PreserveTransform _preserve_transform;
69 int _preserve_attributes;
70
71 public:
72 static void register_with_read_factory();
73 virtual void write_datagram(BamWriter *manager, Datagram &dg);
74
75 protected:
76 static TypedWritable *make_from_bam(const FactoryParams &params);
77 void fillin(DatagramIterator &scan, BamReader *manager);
78
79 virtual void transform_changed();
80 void test_transform(const TransformState *ts) const;
81
82 PN_stdfloat _transform_limit;
83
84
85
86 public:
87 static TypeHandle get_class_type() {
88 return _type_handle;
89 }
90 static void init_type() {
91 PandaNode::init_type();
92 register_type(_type_handle, "ModelNode",
93 PandaNode::get_class_type());
94 }
95 virtual TypeHandle get_type() const {
96 return get_class_type();
97 }
98 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
99
100 private:
101 static TypeHandle _type_handle;
102 };
103
104 #include "modelNode.I"
105
106 #endif
BamReader
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
BamWriter
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
DatagramIterator
A class to retrieve the individual data elements previously stored in a Datagram.
Definition: datagramIterator.h:27
Datagram
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38
FactoryParams
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:36
ModelNode
This node is placed at key points within the scene graph to indicate the roots of "models": subtrees ...
Definition: modelNode.h:31
PandaNode
A basic node of the scene graph or data graph.
Definition: pandaNode.h:65
PandaNode::preserve_name
virtual bool preserve_name() const
Returns true if the node's name has extrinsic meaning and must be preserved across a flatten operatio...
Definition: pandaNode.cxx:256
PandaNode::combine_with
virtual PandaNode * combine_with(PandaNode *other)
Collapses this PandaNode with the other PandaNode, if possible, and returns a pointer to the combined...
Definition: pandaNode.cxx:319
PandaNode::safe_to_combine
virtual bool safe_to_combine() const
Returns true if it is generally safe to combine this particular kind of PandaNode with other kinds of...
Definition: pandaNode.cxx:228
PandaNode::get_unsafe_to_apply_attribs
virtual int get_unsafe_to_apply_attribs() const
Returns the union of all attributes from SceneGraphReducer::AttribTypes that may not safely be applie...
Definition: pandaNode.cxx:268
PandaNode::safe_to_transform
virtual bool safe_to_transform() const
Returns true if it is generally safe to transform this particular kind of PandaNode by calling the xf...
Definition: pandaNode.cxx:204
PandaNode::safe_to_modify_transform
virtual bool safe_to_modify_transform() const
Returns true if it is safe to automatically adjust the transform on this kind of node.
Definition: pandaNode.cxx:217
PandaNode::register_with_read_factory
static void register_with_read_factory()
Tells the BamReader how to create objects of type PandaNode.
Definition: pandaNode.cxx:3574
PandaNode::safe_to_flatten_below
virtual bool safe_to_flatten_below() const
Returns true if a flatten operation may safely continue past this node, or false if nodes below this ...
Definition: pandaNode.cxx:247
PandaNode::make_copy
virtual PandaNode * make_copy() const
Returns a newly-allocated PandaNode that is a shallow copy of this one.
Definition: pandaNode.cxx:481
PandaNode::write_datagram
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition: pandaNode.cxx:3583
PandaNode::safe_to_flatten
virtual bool safe_to_flatten() const
Returns true if it is generally safe to flatten out this particular kind of PandaNode by duplicating ...
Definition: pandaNode.cxx:195
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
TypedWritable
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
modelNode.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandaNode.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
register_type
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22