Panda3D
eggCompositePrimitive.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 eggCompositePrimitive.h
10  * @author drose
11  * @date 2005-03-13
12  */
13 
14 #ifndef EGGCOMPOSITEPRIMITIVE_H
15 #define EGGCOMPOSITEPRIMITIVE_H
16 
17 #include "pandabase.h"
18 
19 #include "eggPrimitive.h"
20 
21 /**
22  * The base class for primitives such as triangle strips and triangle fans,
23  * which include several component triangles, each of which might have its own
24  * color and/or normal.
25  */
26 class EXPCL_PANDA_EGG EggCompositePrimitive : public EggPrimitive {
27 PUBLISHED:
28  INLINE explicit EggCompositePrimitive(const std::string &name = "");
29  INLINE EggCompositePrimitive(const EggCompositePrimitive &copy);
30  INLINE EggCompositePrimitive &operator = (const EggCompositePrimitive &copy);
31  virtual ~EggCompositePrimitive();
32 
33  virtual Shading get_shading() const;
34 
35  INLINE size_t get_num_components() const;
36  INLINE const EggAttributes *get_component(size_t i) const;
37  INLINE EggAttributes *get_component(size_t i);
38  MAKE_SEQ(get_components, get_num_components, get_component);
39  INLINE void set_component(size_t i, const EggAttributes *attrib);
40 
41  MAKE_SEQ_PROPERTY(components, get_num_components, get_component, set_component);
42 
43  INLINE bool triangulate_into(EggGroupNode *container) const;
44  PT(EggCompositePrimitive) triangulate_in_place();
45 
46  virtual void unify_attributes(Shading shading);
47  virtual void apply_last_attribute();
48  virtual void apply_first_attribute();
49  virtual void post_apply_flat_attribute();
50  virtual bool cleanup();
51 
52 protected:
53  virtual int get_num_lead_vertices() const=0;
54  virtual void prepare_add_vertex(EggVertex *vertex, int i, int n);
55  virtual void prepare_remove_vertex(EggVertex *vertex, int i, int n);
56 
57  virtual bool do_triangulate(EggGroupNode *container) const;
58 
59  void write_body(std::ostream &out, int indent_level) const;
60 
61 private:
63  Components _components;
64 
65 public:
66 
67  static TypeHandle get_class_type() {
68  return _type_handle;
69  }
70  static void init_type() {
71  EggPrimitive::init_type();
72  register_type(_type_handle, "EggCompositePrimitive",
73  EggPrimitive::get_class_type());
74  }
75  virtual TypeHandle get_type() const {
76  return get_class_type();
77  }
78  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
79 
80 private:
81  static TypeHandle _type_handle;
82 
83 };
84 
85 #include "eggCompositePrimitive.I"
86 
87 #endif
A base class for any of a number of kinds of geometry primitives: polygons, point lights,...
Definition: eggPrimitive.h:47
virtual void unify_attributes(Shading shading)
If the shading property is S_per_vertex, ensures that all vertices have a normal and a color,...
The base class for primitives such as triangle strips and triangle fans, which include several compon...
virtual void apply_first_attribute()
Sets the first vertex of the triangle (or each component) to the primitive normal and/or color,...
virtual void apply_last_attribute()
Sets the last vertex of the triangle (or each component) to the primitive normal and/or color,...
virtual bool cleanup()
Cleans up modeling errors in whatever context this makes sense.
A base class for nodes in the hierarchy that are not leaf nodes.
Definition: eggGroupNode.h:46
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.
The set of attributes that may be applied to vertices as well as polygons, such as surface normal and...
Definition: eggAttributes.h:33
virtual void post_apply_flat_attribute()
Intended as a followup to apply_last_attribute(), this also sets an attribute on the first vertices o...
Any one-, two-, three-, or four-component vertex, possibly with attributes such as a normal.
Definition: eggVertex.h:39
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81