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 
26 class EggGroupNode;
27 class EggRenderMode;
29 
30 /**
31  * A base class for things that may be directly added into the egg hierarchy.
32  * This includes groups, joints, polygons, vertex pools, etc., but does not
33  * include things like vertices.
34  */
35 class EXPCL_PANDA_EGG EggNode : public EggNamedObject {
36 PUBLISHED:
37  INLINE explicit EggNode(const std::string &name = "");
38  INLINE EggNode(const EggNode &copy);
39  INLINE EggNode &operator = (const EggNode &copy);
40 
41  INLINE EggGroupNode *get_parent() const;
42  INLINE int get_depth() const;
43  INLINE bool is_under_instance() const;
44  INLINE bool is_under_transform() const;
45  INLINE bool is_local_coord() const;
46 
47  MAKE_PROPERTY(parent, get_parent);
48  MAKE_PROPERTY(depth, get_depth);
49 
50  INLINE const LMatrix4d &get_vertex_frame() const;
51  INLINE const LMatrix4d &get_node_frame() const;
52  INLINE const LMatrix4d &get_vertex_frame_inv() const;
53  INLINE const LMatrix4d &get_node_frame_inv() const;
54  INLINE const LMatrix4d &get_vertex_to_node() const;
55  INLINE const LMatrix4d &get_node_to_vertex() const;
56 
57  INLINE const LMatrix4d *get_vertex_frame_ptr() const;
58  INLINE const LMatrix4d *get_node_frame_ptr() const;
59  INLINE const LMatrix4d *get_vertex_frame_inv_ptr() const;
60  INLINE const LMatrix4d *get_node_frame_inv_ptr() const;
61  INLINE const LMatrix4d *get_vertex_to_node_ptr() const;
62  INLINE const LMatrix4d *get_node_to_vertex_ptr() const;
63 
64  INLINE void transform(const LMatrix4d &mat);
65  INLINE void transform_vertices_only(const LMatrix4d &mat);
66  INLINE void flatten_transforms();
67  void apply_texmats();
68 
69  int rename_node(vector_string strip_prefix);
70 
71  virtual bool is_joint() const;
72  virtual bool is_anim_matrix() const;
73 
74  virtual EggRenderMode *determine_alpha_mode();
75  virtual EggRenderMode *determine_depth_write_mode();
76  virtual EggRenderMode *determine_depth_test_mode();
77  virtual EggRenderMode *determine_visibility_mode();
78  virtual EggRenderMode *determine_depth_offset();
79  virtual EggRenderMode *determine_draw_order();
80  virtual EggRenderMode *determine_bin();
81  virtual bool determine_indexed();
82  virtual bool determine_decal();
83 
84  virtual void write(std::ostream &out, int indent_level) const=0;
85  bool parse_egg(const std::string &egg_syntax);
86 
87 #ifdef _DEBUG
88  void test_under_integrity() const;
89 #else
90  void test_under_integrity() const { }
91 #endif // _DEBUG
92 
93 
94 protected:
95  enum UnderFlags {
96  UF_under_instance = 0x001,
97  UF_under_transform = 0x002,
98  UF_local_coord = 0x004,
99  };
100 
101  virtual bool egg_start_parse_body();
102 
103  virtual void update_under(int depth_offset);
104  virtual void adjust_under();
105  virtual bool has_primitives() const;
106  virtual bool joint_has_primitives() const;
107  virtual bool has_normals() const;
108 
109  virtual void r_transform(const LMatrix4d &mat, const LMatrix4d &inv,
110  CoordinateSystem to_cs);
111  virtual void r_transform_vertices(const LMatrix4d &mat);
112  virtual void r_mark_coordsys(CoordinateSystem cs);
113  virtual void r_flatten_transforms();
114  virtual void r_apply_texmats(EggTextureCollection &textures);
115 
116  // These members are updated automatically by prepare_add_child(),
117  // prepare_remove_child(), and update_under(). Other functions shouldn't be
118  // fiddling with them.
119 
120  EggGroupNode *_parent;
121  int _depth;
122  int _under_flags;
123 
124  typedef RefCountObj<LMatrix4d> MatrixFrame;
125 
126  PT(MatrixFrame) _vertex_frame;
127  PT(MatrixFrame) _node_frame;
128  PT(MatrixFrame) _vertex_frame_inv;
129  PT(MatrixFrame) _node_frame_inv;
130  PT(MatrixFrame) _vertex_to_node;
131  PT(MatrixFrame) _node_to_vertex;
132 
133 
134 public:
135 
136  static TypeHandle get_class_type() {
137  return _type_handle;
138  }
139  static void init_type() {
140  EggNamedObject::init_type();
141  register_type(_type_handle, "EggNode",
142  EggNamedObject::get_class_type());
143  MatrixFrame::init_type();
144  }
145  virtual TypeHandle get_type() const {
146  return get_class_type();
147  }
148  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
149 
150 private:
151  static TypeHandle _type_handle;
152 
153  friend class EggGroupNode;
154  friend class EggTable;
155 };
156 
157 #include "eggNode.I"
158 
159 #endif
A base class for nodes in the hierarchy that are not leaf nodes.
Definition: eggGroupNode.h:46
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
This class stores miscellaneous rendering properties that is associated with geometry,...
Definition: eggRenderMode.h:31
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This corresponds to a.
Definition: eggTable.h:27
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:35
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.