18 EggPrimitive(
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;
70 INLINE std::string EggPrimitive::
71 get_sort_name()
const {
72 const std::string &name = get_name();
73 if (!name.empty() && !isdigit(name[0])) {
85 _connected_shading = S_unknown;
100 INLINE EggPrimitive::Shading EggPrimitive::
101 get_connected_shading()
const {
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());
150 get_texture()
const {
163 _textures.push_back(texture);
177 INLINE
int EggPrimitive::
178 get_num_textures()
const {
179 return _textures.size();
186 get_texture(
int n)
const {
187 nassertr(n >= 0 && n < (
int)_textures.size(),
nullptr);
197 _material = material;
203 INLINE
void EggPrimitive::
213 get_material()
const {
222 INLINE
bool EggPrimitive::
223 has_material()
const {
224 return _material !=
nullptr;
242 INLINE
bool EggPrimitive::
243 get_bface_flag()
const {
251 INLINE EggPrimitive::iterator EggPrimitive::
253 return _vertices.begin();
259 INLINE EggPrimitive::iterator EggPrimitive::
261 return _vertices.end();
267 INLINE EggPrimitive::reverse_iterator EggPrimitive::
269 return _vertices.rbegin();
275 INLINE EggPrimitive::reverse_iterator EggPrimitive::
277 return _vertices.rend();
283 INLINE
bool EggPrimitive::
285 return _vertices.empty();
291 INLINE EggPrimitive::size_type EggPrimitive::
293 return _vertices.size();
302 nassertr(index >= 0 && index < (
int)
size(),
nullptr);
303 return *(begin() + index);
309 INLINE EggPrimitive::iterator EggPrimitive::
310 insert(iterator position,
EggVertex *x) {
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();
321 INLINE EggPrimitive::iterator EggPrimitive::
322 erase(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());
359 INLINE
size_t EggPrimitive::
360 get_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();
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.
void clear()
Removes all of the vertices from the primitive.
Defines a texture map that may be applied to geometry.
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.
set_bface_flag
Sets the backfacing flag of the polygon.
set_material
Applies the indicated material to the primitive.
get_vertex
Returns a particular index based on its index number.
set_vertex
Replaces a particular vertex based on its index number in the list of vertices.
This class stores miscellaneous rendering properties that is associated with geometry,...
The set of attributes that may be applied to vertices as well as polygons, such as surface normal and...
Any one-, two-, three-, or four-component vertex, possibly with attributes such as a normal.
void clear_texture()
Removes any texturing from the primitive.
bool has_texture() const
Returns true if the primitive has any textures specified, false otherwise.
insert_vertex
Inserts a vertex at the given position.
get_num_textures
Returns the number of textures applied to the primitive.
A base class for things that may be directly added into the egg hierarchy.
size_type size() const
Returns the number of EggTextures in the collection.
void replace(iterator position, EggVertex *vertex)
Replaces the vertex at the indicated position with the indicated vertex.
get_texture
Returns the nth EggTexture in the collection.
A collection of vertices.
void clear_connected_shading()
Resets the connected_shading member in this primitive, so that get_connected_shading() will recompute...
EggVertex * operator [](int index) const
This is read-only: you can't assign directly to an indexed vertex.