Panda3D
 All Classes Functions Variables Enumerations
eggCompositePrimitive.I
1 // Filename: eggCompositePrimitive.I
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 
16 ////////////////////////////////////////////////////////////////////
17 // Function: EggCompositePrimitive::Constructor
18 // Access: Published
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE EggCompositePrimitive::
22 EggCompositePrimitive(const string &name) : EggPrimitive(name) {
23 }
24 
25 ////////////////////////////////////////////////////////////////////
26 // Function: EggCompositePrimitive::Copy constructor
27 // Access: Published
28 // Description:
29 ////////////////////////////////////////////////////////////////////
30 INLINE EggCompositePrimitive::
31 EggCompositePrimitive(const EggCompositePrimitive &copy) : EggPrimitive(copy) {
32 }
33 
34 ////////////////////////////////////////////////////////////////////
35 // Function: EggCompositePrimitive::Copy assignment operator
36 // Access: Published
37 // Description:
38 ////////////////////////////////////////////////////////////////////
39 INLINE EggCompositePrimitive &EggCompositePrimitive::
40 operator = (const EggCompositePrimitive &copy) {
41  EggPrimitive::operator = (copy);
42  return *this;
43 }
44 
45 ////////////////////////////////////////////////////////////////////
46 // Function: EggCompositePrimitive::get_num_components
47 // Access: Published
48 // Description: Returns the number of individual component triangles
49 // within the composite. Each one of these might have a
50 // different set of attributes.
51 ////////////////////////////////////////////////////////////////////
52 INLINE int EggCompositePrimitive::
54  return _components.size();
55 }
56 
57 ////////////////////////////////////////////////////////////////////
58 // Function: EggCompositePrimitive::get_component
59 // Access: Published
60 // Description: Returns the attributes for the nth component
61 // triangle.
62 ////////////////////////////////////////////////////////////////////
64 get_component(int i) const {
65  nassertr(i >= 0 && i < (int)_components.size(), NULL);
66  return _components[i];
67 }
68 
69 ////////////////////////////////////////////////////////////////////
70 // Function: EggCompositePrimitive::get_component
71 // Access: Published
72 // Description: Returns the attributes for the nth component
73 // triangle.
74 ////////////////////////////////////////////////////////////////////
76 get_component(int i) {
77  nassertr(i >= 0 && i < (int)_components.size(), NULL);
78  return _components[i];
79 }
80 
81 ////////////////////////////////////////////////////////////////////
82 // Function: EggCompositePrimitive::set_component
83 // Access: Published
84 // Description: Changes the attributes for the nth component
85 // triangle.
86 ////////////////////////////////////////////////////////////////////
87 INLINE void EggCompositePrimitive::
88 set_component(int i, const EggAttributes *attrib) {
89  nassertv(i >= 0 && i < (int)_components.size());
90  _components[i] = new EggAttributes(*attrib);
91 }
92 
93 ////////////////////////////////////////////////////////////////////
94 // Function: EggCompositePrimitive::triangulate_into
95 // Access: Published
96 // Description: Subdivides the composite primitive into triangles and
97 // adds those triangles to the indicated container.
98 // Does not remove the primitive from its existing
99 // parent or modify it in any way.
100 //
101 // Returns true if the triangulation is successful, or
102 // false if there was some error (in which case the
103 // container may contain some partial triangulation).
104 ////////////////////////////////////////////////////////////////////
105 INLINE bool EggCompositePrimitive::
106 triangulate_into(EggGroupNode *container) const {
107  return do_triangulate(container);
108 }
A base class for any of a number of kinds of geometry primitives: polygons, point lights...
Definition: eggPrimitive.h:51
The base class for primitives such as triangle strips and triangle fans, which include several compon...
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
const EggAttributes * get_component(int i) const
Returns the attributes for the nth component triangle.
void set_component(int i, const EggAttributes *attrib)
Changes the attributes for the nth component triangle.
bool triangulate_into(EggGroupNode *container) const
Subdivides the composite primitive into triangles and adds those triangles to the indicated container...
int get_num_components() const
Returns the number of individual component triangles within the composite.