22 EggPrimitive(
const string &name):
EggNode(name) {
24 _connected_shading = S_unknown;
36 _textures(copy._textures),
37 _material(copy._material),
41 _connected_shading = S_unknown;
51 EggNode::operator = (copy);
52 EggAttributes::operator = (copy);
54 _textures = copy._textures;
55 _material = copy._material;
57 _connected_shading = S_unknown;
83 const string &name = get_name();
84 if (!name.empty() && !isdigit(name[0])) {
99 _connected_shading = S_unknown;
121 if (_connected_shading == S_unknown) {
122 ((
EggPrimitive *)
this)->set_connected_shading(S_unknown,
this);
125 return _connected_shading;
167 PT_EggTexture t = texture;
168 return (::
find(_textures.begin(), _textures.end(), t) != _textures.end());
198 _textures.push_back(texture);
219 return _textures.size();
230 nassertr(n >= 0 && n < (
int)_textures.size(), NULL);
242 _material = material;
311 INLINE EggPrimitive::iterator EggPrimitive::
313 return _vertices.begin();
321 INLINE EggPrimitive::iterator EggPrimitive::
323 return _vertices.end();
331 INLINE EggPrimitive::reverse_iterator EggPrimitive::
333 return _vertices.rbegin();
341 INLINE EggPrimitive::reverse_iterator EggPrimitive::
343 return _vertices.rend();
351 INLINE
bool EggPrimitive::
353 return _vertices.empty();
361 INLINE EggPrimitive::size_type EggPrimitive::
363 return _vertices.size();
374 nassertr(index >= 0 && index < (
int)
size(), NULL);
375 return *(begin() + index);
383 INLINE EggPrimitive::iterator EggPrimitive::
384 insert(iterator position,
EggVertex *x) {
385 prepare_add_vertex(x, position - _vertices.begin(), _vertices.size() + 1);
386 iterator i = _vertices.insert((Vertices::iterator &)position, x);
387 x->test_pref_integrity();
388 test_vref_integrity();
397 INLINE EggPrimitive::iterator EggPrimitive::
398 erase(iterator position) {
399 prepare_remove_vertex(*position, position - _vertices.begin(), _vertices.size());
400 iterator i = _vertices.erase((Vertices::iterator &)position);
401 test_vref_integrity();
414 nassertv(position != end());
418 prepare_remove_vertex(*position, -1, -1);
419 prepare_add_vertex(x, -1, -1);
420 *(Vertices::iterator &)position = x;
422 x->test_pref_integrity();
423 test_vref_integrity();
433 erase(begin(), end());
441 INLINE
int EggPrimitive::
442 get_num_vertices()
const {
456 nassertv(index >= 0 && index < (
int)
size());
457 replace(begin() + index, vertex);
467 nassertr(index >= 0 && index < (
int)
size(), NULL);
468 return *(begin() + index);
481 return empty() ? (
EggVertexPool *)NULL : _vertices.front()->get_pool();
A base class for any of a number of kinds of geometry primitives: polygons, point lights...
void add_texture(EggTexture *texture)
Applies the indicated texture to the primitive.
bool get_bface_flag() const
Retrieves the backfacing flag of the polygon.
EggVertex * operator[](int index) const
This is read-only: you can't assign directly to an indexed vertex.
void clear()
Removes all of the vertices from the primitive.
Defines a texture map that may be applied to geometry.
void set_vertex(int index, EggVertex *vertex)
Replaces a particular vertex based on its index number in the list of vertices.
void copy_vertices(const EggPrimitive &other)
Replaces the current primitive's list of vertices with a copy of the list of vertices on the other pr...
void set_texture(EggTexture *texture)
Replaces the current list of textures with the indicated texture.
EggTexture * get_texture() const
Returns the first texture on the primitive, if any, or NULL if there are no textures on the primitive...
void set_bface_flag(bool flag)
Sets the backfacing flag of the polygon.
The set of attributes that may be applied to vertices as well as polygons, such as surface normal and...
size_type size() const
Returns the number of EggTextures in the collection.
EggMaterial * get_material() const
Returns a pointer to the applied material, or NULL if there is no material applied.
void set_material(EggMaterial *material)
Applies the indicated material to the primitive.
Any one-, two-, three-, or four-component vertex, possibly with attributes such as a normal...
void clear_texture()
Removes any texturing from the primitive.
string get_sort_name() const
Returns the name of the primitive for the purposes of sorting primitives into different groups...
iterator find(EggVertex *vertex)
Returns the iterator pointing to the indicated vertex, or end() if the vertex is not part of the prim...
int get_num_textures() const
Returns the number of textures applied to the primitive.
void clear_material()
Removes any material from the primitive.
bool has_material() const
Returns true if the primitive is materiald (and get_material() will return a real pointer)...
Shading get_connected_shading() const
Determines what sort of shading properties this primitive's connected neighbors have.
A base class for things that may be directly added into the egg hierarchy.
void replace(iterator position, EggVertex *vertex)
Replaces the vertex at the indicated position with the indicated vertex.
EggVertex * get_vertex(int index) const
Returns a particular index based on its index number.
A collection of vertices.
void clear_connected_shading()
Resets the connected_shading member in this primitive, so that get_connected_shading() will recompute...
bool has_texture() const
Returns true if the primitive has any textures specified, false otherwise.
EggVertexPool * get_pool() const
Returns the vertex pool associated with the vertices of the primitive, or NULL if the primitive has n...