Panda3D
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 
27 class EggGroupNode;
28 class 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  */
36 class EXPCL_PANDA_EGG EggNode : public EggNamedObject {
37 PUBLISHED:
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 
75  virtual EggRenderMode *determine_alpha_mode();
76  virtual EggRenderMode *determine_depth_write_mode();
77  virtual EggRenderMode *determine_depth_test_mode();
78  virtual EggRenderMode *determine_visibility_mode();
79  virtual EggRenderMode *determine_depth_offset();
80  virtual EggRenderMode *determine_draw_order();
81  virtual EggRenderMode *determine_bin();
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 
96 protected:
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 
136 public:
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 
152 private:
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.
Definition: eggGroupNode.h:46
This is a fairly low-level base class–any egg object that has a name.
A base class for things that may be directly added into the egg hierarchy.
Definition: eggNode.h:36
This class stores miscellaneous rendering properties that is associated with geometry,...
Definition: eggRenderMode.h:31
This corresponds to a.
Definition: eggTable.h:27
This is a collection of textures by TRef name.
Another kind of proxy, similar to RefCountProxy.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
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(),...
Definition: register_type.I:22
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.