18EggPrimitive(
const std::string &name):
EggNode(name) {
20 _connected_shading = S_unknown;
31 _textures(copy._textures),
32 _material(copy._material),
36 _connected_shading = S_unknown;
44 EggNode::operator = (copy);
45 EggAttributes::operator = (copy);
46 EggRenderMode::operator = (copy);
48 _textures = copy._textures;
49 _material = copy._material;
51 _connected_shading = S_unknown;
72 const std::string &name = get_name();
73 if (!name.empty() && !isdigit(name[0])) {
85 _connected_shading = S_unknown;
102 if (_connected_shading == S_unknown) {
103 ((
EggPrimitive *)
this)->set_connected_shading(S_unknown,
this);
106 return _connected_shading;
138 PT_EggTexture t = texture;
139 return (std::find(_textures.begin(), _textures.end(), t) != _textures.end());
163 _textures.push_back(texture);
179 return _textures.size();
187 nassertr(n >= 0 && n < (
int)_textures.size(),
nullptr);
197 _material = material;
224 return _material !=
nullptr;
251INLINE EggPrimitive::iterator EggPrimitive::
253 return _vertices.begin();
259INLINE EggPrimitive::iterator EggPrimitive::
261 return _vertices.end();
267INLINE EggPrimitive::reverse_iterator EggPrimitive::
269 return _vertices.rbegin();
275INLINE EggPrimitive::reverse_iterator EggPrimitive::
277 return _vertices.rend();
283INLINE
bool EggPrimitive::
285 return _vertices.empty();
291INLINE EggPrimitive::size_type EggPrimitive::
293 return _vertices.size();
302 nassertr(index >= 0 && index < (
int)size(),
nullptr);
303 return *(begin() + index);
309INLINE EggPrimitive::iterator EggPrimitive::
311 prepare_add_vertex(x, position - _vertices.begin(), _vertices.size() + 1);
312 iterator i = _vertices.insert((Vertices::iterator &)position, x);
313 x->test_pref_integrity();
314 test_vref_integrity();
321INLINE EggPrimitive::iterator EggPrimitive::
322erase(iterator position) {
323 prepare_remove_vertex(*position, position - _vertices.begin(), _vertices.size());
324 iterator i = _vertices.erase((Vertices::iterator &)position);
325 test_vref_integrity();
336 nassertv(position != end());
340 prepare_remove_vertex(*position, -1, -1);
341 prepare_add_vertex(x, -1, -1);
342 *(Vertices::iterator &)position = x;
344 x->test_pref_integrity();
345 test_vref_integrity();
353 erase(begin(), end());
359INLINE
size_t EggPrimitive::
360get_num_vertices()
const {
371 nassertv(index < size());
372 replace(begin() + index, vertex);
380 if (index > _vertices.size()) {
381 index = _vertices.size();
383 _vertices.insert(_vertices.begin() + index, vertex);
391 nassertr(index < size(),
nullptr);
392 return *(begin() + index);
401 return empty() ? nullptr : _vertices.front()->get_pool();
The set of attributes that may be applied to vertices as well as polygons, such as surface normal and...
A base class for things that may be directly added into the egg hierarchy.
A base class for any of a number of kinds of geometry primitives: polygons, point lights,...
set_bface_flag
Sets the backfacing flag of the polygon.
void clear_texture()
Removes any texturing from the primitive.
get_material
Returns a pointer to the applied material, or NULL if there is no material applied.
get_pool
Returns the vertex pool associated with the vertices of the primitive, or NULL if the primitive has n...
void set_texture(EggTexture *texture)
Replaces the current list of textures with the indicated texture.
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...
set_material
Applies the indicated material to the primitive.
clear_material
Removes any material from the primitive.
bool has_texture() const
Returns true if the primitive has any textures specified, false otherwise.
get_vertex
Returns a particular index based on its index number.
get_connected_shading
Determines what sort of shading properties this primitive's connected neighbors have.
set_vertex
Replaces a particular vertex based on its index number in the list of vertices.
get_bface_flag
Retrieves the backfacing flag of the polygon.
void replace(iterator position, EggVertex *vertex)
Replaces the vertex at the indicated position with the indicated vertex.
get_num_textures
Returns the number of textures applied to the primitive.
get_sort_name
Returns the name of the primitive for the purposes of sorting primitives into different groups,...
void clear()
Removes all of the vertices from the primitive.
void clear_connected_shading()
Resets the connected_shading member in this primitive, so that get_connected_shading() will recompute...
insert_vertex
Inserts a vertex at the given position.
EggVertex * operator[](int index) const
This is read-only: you can't assign directly to an indexed vertex.
get_texture
Returns the first texture on the primitive, if any, or NULL if there are no textures on the primitive...
void add_texture(EggTexture *texture)
Applies the indicated texture to the primitive.
has_material
Returns true if the primitive is materiald (and get_material() will return a real pointer),...
This class stores miscellaneous rendering properties that is associated with geometry,...
Defines a texture map that may be applied to geometry.
A collection of vertices.
Any one-, two-, three-, or four-component vertex, possibly with attributes such as a normal.