Panda3D
Loading...
Searching...
No Matches
eggNode.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 eggNode.h
10 * @author drose
11 * @date 1999-01-16
12 */
13
14#ifndef EGGNODE_H
15#define EGGNODE_H
16
17#include "pandabase.h"
18
19#include "eggNamedObject.h"
20
21#include "typedObject.h"
22#include "lmatrix.h"
23#include "pointerTo.h"
24#include "referenceCount.h"
25#include "extension.h"
26
27class EggGroupNode;
28class EggRenderMode;
30
31/**
32 * A base class for things that may be directly added into the egg hierarchy.
33 * This includes groups, joints, polygons, vertex pools, etc., but does not
34 * include things like vertices.
35 */
36class EXPCL_PANDA_EGG EggNode : public EggNamedObject {
37PUBLISHED:
38 INLINE explicit EggNode(const std::string &name = "");
39 INLINE EggNode(const EggNode &copy);
40 INLINE EggNode &operator = (const EggNode &copy);
41
42 INLINE EggGroupNode *get_parent() const;
43 INLINE int get_depth() const;
44 INLINE bool is_under_instance() const;
45 INLINE bool is_under_transform() const;
46 INLINE bool is_local_coord() const;
47
48 MAKE_PROPERTY(parent, get_parent);
49 MAKE_PROPERTY(depth, get_depth);
50
51 INLINE const LMatrix4d &get_vertex_frame() const;
52 INLINE const LMatrix4d &get_node_frame() const;
53 INLINE const LMatrix4d &get_vertex_frame_inv() const;
54 INLINE const LMatrix4d &get_node_frame_inv() const;
55 INLINE const LMatrix4d &get_vertex_to_node() const;
56 INLINE const LMatrix4d &get_node_to_vertex() const;
57
58 INLINE const LMatrix4d *get_vertex_frame_ptr() const;
59 INLINE const LMatrix4d *get_node_frame_ptr() const;
60 INLINE const LMatrix4d *get_vertex_frame_inv_ptr() const;
61 INLINE const LMatrix4d *get_node_frame_inv_ptr() const;
62 INLINE const LMatrix4d *get_vertex_to_node_ptr() const;
63 INLINE const LMatrix4d *get_node_to_vertex_ptr() const;
64
65 INLINE void transform(const LMatrix4d &mat);
66 INLINE void transform_vertices_only(const LMatrix4d &mat);
67 INLINE void flatten_transforms();
68 void apply_texmats();
69
70 int rename_node(vector_string strip_prefix);
71
72 virtual bool is_joint() const;
73 virtual bool is_anim_matrix() const;
74
82 virtual bool determine_indexed();
83 virtual bool determine_decal();
84
85 virtual void write(std::ostream &out, int indent_level) const=0;
86 bool parse_egg(const std::string &egg_syntax);
87
88#ifdef _DEBUG
89 void test_under_integrity() const;
90#else
91 void test_under_integrity() const { }
92#endif // _DEBUG
93
94 EXTENSION(PyObject *__reduce__() const);
95
96protected:
97 enum UnderFlags {
98 UF_under_instance = 0x001,
99 UF_under_transform = 0x002,
100 UF_local_coord = 0x004,
101 };
102
103 virtual bool egg_start_parse_body();
104
105 virtual void update_under(int depth_offset);
106 virtual void adjust_under();
107 virtual bool has_primitives() const;
108 virtual bool joint_has_primitives() const;
109 virtual bool has_normals() const;
110
111 virtual void r_transform(const LMatrix4d &mat, const LMatrix4d &inv,
112 CoordinateSystem to_cs);
113 virtual void r_transform_vertices(const LMatrix4d &mat);
114 virtual void r_mark_coordsys(CoordinateSystem cs);
115 virtual void r_flatten_transforms();
116 virtual void r_apply_texmats(EggTextureCollection &textures);
117
118 // These members are updated automatically by prepare_add_child(),
119 // prepare_remove_child(), and update_under(). Other functions shouldn't be
120 // fiddling with them.
121
122 EggGroupNode *_parent;
123 int _depth;
124 int _under_flags;
125
126 typedef RefCountObj<LMatrix4d> MatrixFrame;
127
128 PT(MatrixFrame) _vertex_frame;
129 PT(MatrixFrame) _node_frame;
130 PT(MatrixFrame) _vertex_frame_inv;
131 PT(MatrixFrame) _node_frame_inv;
132 PT(MatrixFrame) _vertex_to_node;
133 PT(MatrixFrame) _node_to_vertex;
134
135
136public:
137
138 static TypeHandle get_class_type() {
139 return _type_handle;
140 }
141 static void init_type() {
142 EggNamedObject::init_type();
143 register_type(_type_handle, "EggNode",
144 EggNamedObject::get_class_type());
145 MatrixFrame::init_type();
146 }
147 virtual TypeHandle get_type() const {
148 return get_class_type();
149 }
150 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
151
152private:
153 static TypeHandle _type_handle;
154
155 friend class EggGroupNode;
156 friend class EggTable;
157};
158
159#include "eggNode.I"
160
161#endif
A base class for nodes in the hierarchy that are not leaf nodes.
virtual EggRenderMode * determine_bin()
Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this leve...
Definition eggNode.cxx:174
const LMatrix4d & get_vertex_frame_inv() const
Returns the inverse of the matrix returned by get_vertex_frame().
Definition eggNode.I:135
virtual bool is_joint() const
Returns true if this particular node represents a <Joint> entry or not.
Definition eggNode.cxx:65
const LMatrix4d & get_vertex_to_node() const
Returns the transformation matrix suitable for converting the vertices as read from the egg file into...
Definition eggNode.I:166
virtual EggRenderMode * determine_alpha_mode()
Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this leve...
Definition eggNode.cxx:85
void transform_vertices_only(const LMatrix4d &mat)
Applies the indicated transformation only to vertices that appear in global space within vertex pools...
Definition eggNode.I:270
const LMatrix4d * get_vertex_frame_inv_ptr() const
Returns either a NULL pointer or a unique pointer shared by nodes with the same get_vertex_frame_inv(...
Definition eggNode.I:215
bool is_under_instance() const
Returns true if there is an <Instance> node somewhere in the egg tree at or above this node,...
Definition eggNode.I:68
int rename_node(vector_string strip_prefix)
Rename by stripping out the prefix.
Definition eggNode.cxx:34
virtual EggRenderMode * determine_depth_test_mode()
Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this leve...
Definition eggNode.cxx:115
const LMatrix4d * get_vertex_to_node_ptr() const
Returns either a NULL pointer or a unique pointer shared by nodes with the same get_vertex_to_node() ...
Definition eggNode.I:234
void apply_texmats()
Applies the texture matrices to the UV's of the vertices that reference them, and then removes the te...
Definition eggNode.cxx:53
virtual EggRenderMode * determine_depth_offset()
Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this leve...
Definition eggNode.cxx:145
void transform(const LMatrix4d &mat)
Applies the indicated transformation to the node and all of its descendants.
Definition eggNode.I:253
const LMatrix4d * get_node_frame_ptr() const
Returns either a NULL pointer or a unique pointer shared by nodes with the same get_node_frame() matr...
Definition eggNode.I:206
const LMatrix4d & get_node_frame() const
Returns the coordinate frame of the node itself.
Definition eggNode.I:122
virtual bool is_anim_matrix() const
Returns true if this node represents a table of animation transformation data, false otherwise.
Definition eggNode.cxx:74
const LMatrix4d & get_node_to_vertex() const
Returns the transformation matrix suitable for converting vertices in the coordinate space of the nod...
Definition eggNode.I:183
virtual bool determine_indexed()
Walks back up the hierarchy, looking for an EggGroup at this level or above that has the "indexed" sc...
Definition eggNode.cxx:191
const LMatrix4d & get_vertex_frame() const
Returns the coordinate frame of the vertices referenced by primitives at or under this node.
Definition eggNode.I:108
const LMatrix4d * get_node_to_vertex_ptr() const
Returns either a NULL pointer or a unique pointer shared by nodes with the same get_node_to_vertex() ...
Definition eggNode.I:243
const LMatrix4d * get_node_frame_inv_ptr() const
Returns either a NULL pointer or a unique pointer shared by nodes with the same get_node_frame_inv() ...
Definition eggNode.I:225
const LMatrix4d * get_vertex_frame_ptr() const
Returns either a NULL pointer or a unique pointer shared by nodes with the same get_vertex_frame() ma...
Definition eggNode.I:196
bool is_under_transform() const
Returns true if there is a <Transform> entry somewhere in the egg tree at or above this node,...
Definition eggNode.I:77
void flatten_transforms()
Removes any transform and instance records from this node in the scene graph and below.
Definition eggNode.I:284
get_depth
Returns the number of nodes above this node in the egg hierarchy.
Definition eggNode.h:49
bool parse_egg(const std::string &egg_syntax)
Parses the egg syntax given in the indicate string as if it had been read from the egg file within th...
Definition eggNode.cxx:224
virtual EggRenderMode * determine_depth_write_mode()
Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this leve...
Definition eggNode.cxx:100
bool is_local_coord() const
Returns true if this node's vertices are not in the global coordinate space.
Definition eggNode.I:87
virtual EggRenderMode * determine_visibility_mode()
Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this leve...
Definition eggNode.cxx:130
const LMatrix4d & get_node_frame_inv() const
Returns the inverse of the matrix returned by get_node_frame().
Definition eggNode.I:149
virtual EggRenderMode * determine_draw_order()
Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this leve...
Definition eggNode.cxx:160
virtual bool determine_decal()
Walks back up the hierarchy, looking for an EggGroup at this level or above that has the "decal" flag...
Definition eggNode.cxx:208
This class stores miscellaneous rendering properties that is associated with geometry,...
This is a collection of textures by TRef name.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.