Panda3D
eggCompositePrimitive.h
1 // Filename: eggCompositePrimitive.h
2 // Created by: drose (13Mar05)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef EGGCOMPOSITEPRIMITIVE_H
16 #define EGGCOMPOSITEPRIMITIVE_H
17 
18 #include "pandabase.h"
19 
20 #include "eggPrimitive.h"
21 
22 ////////////////////////////////////////////////////////////////////
23 // Class : EggCompositePrimitive
24 // Description : The base class for primitives such as triangle strips
25 // and triangle fans, which include several component
26 // triangles, each of which might have its own color
27 // and/or normal.
28 ////////////////////////////////////////////////////////////////////
29 class EXPCL_PANDAEGG EggCompositePrimitive : public EggPrimitive {
30 PUBLISHED:
31  INLINE EggCompositePrimitive(const string &name = "");
32  INLINE EggCompositePrimitive(const EggCompositePrimitive &copy);
33  INLINE EggCompositePrimitive &operator = (const EggCompositePrimitive &copy);
34  virtual ~EggCompositePrimitive();
35 
36  virtual Shading get_shading() const;
37 
38  INLINE int get_num_components() const;
39  INLINE const EggAttributes *get_component(int i) const;
40  INLINE EggAttributes *get_component(int i);
41  MAKE_SEQ(get_components, get_num_components, get_component);
42  INLINE void set_component(int i, const EggAttributes *attrib);
43 
44  INLINE bool triangulate_into(EggGroupNode *container) const;
45  PT(EggCompositePrimitive) triangulate_in_place();
46 
47  virtual void unify_attributes(Shading shading);
48  virtual void apply_last_attribute();
49  virtual void apply_first_attribute();
50  virtual void post_apply_flat_attribute();
51  virtual bool cleanup();
52 
53 protected:
54  virtual int get_num_lead_vertices() const=0;
55  virtual void prepare_add_vertex(EggVertex *vertex, int i, int n);
56  virtual void prepare_remove_vertex(EggVertex *vertex, int i, int n);
57 
58  virtual bool do_triangulate(EggGroupNode *container) const;
59 
60  void write_body(ostream &out, int indent_level) const;
61 
62 private:
64  Components _components;
65 
66 public:
67 
68  static TypeHandle get_class_type() {
69  return _type_handle;
70  }
71  static void init_type() {
72  EggPrimitive::init_type();
73  register_type(_type_handle, "EggCompositePrimitive",
74  EggPrimitive::get_class_type());
75  }
76  virtual TypeHandle get_type() const {
77  return get_class_type();
78  }
79  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
80 
81 private:
82  static TypeHandle _type_handle;
83 
84 };
85 
86 #include "eggCompositePrimitive.I"
87 
88 #endif
A base class for any of a number of kinds of geometry primitives: polygons, point lights...
Definition: eggPrimitive.h:51
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:51
The set of attributes that may be applied to vertices as well as polygons, such as surface normal and...
Definition: eggAttributes.h:37
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:41
virtual Shading get_shading() const
Returns the shading properties apparent on this particular primitive.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85