Panda3D
|
A base class for any of a number of kinds of geometry primitives: polygons, point lights, nurbs patches, parametrics curves, etc. More...
#include "eggPrimitive.h"
Classes | |
class | ConnectedShadingNode |
Public Types | |
typedef Vertices::const_iterator | const_iterator |
typedef Vertices::const_pointer | const_pointer |
typedef Vertices::const_reference | const_reference |
typedef Vertices::const_reverse_iterator | const_reverse_iterator |
typedef Vertices::difference_type | difference_type |
typedef Vertices::const_iterator | iterator |
typedef Vertices::const_pointer | pointer |
typedef Vertices::const_reference | reference |
typedef Vertices::const_reverse_iterator | reverse_iterator |
enum | Shading { S_unknown, S_overall, S_per_face, S_per_vertex } |
typedef Vertices::size_type | size_type |
Public Member Functions | |
EggPrimitive (const string &name="") | |
EggPrimitive (const EggPrimitive ©) | |
void | add_texture (EggTexture *texture) |
Applies the indicated texture to the primitive. | |
EggVertex * | add_vertex (EggVertex *vertex) |
Adds the indicated vertex to the end of the primitive's list of vertices, and returns it. | |
virtual void | apply_first_attribute () |
Sets the first vertex of the triangle (or each component) to the primitive normal and/or color, if the primitive is flat-shaded. | |
virtual void | apply_last_attribute () |
Sets the last vertex of the triangle (or each component) to the primitive normal and/or color, if the primitive is flat-shaded. | |
iterator | begin () const |
virtual bool | cleanup () |
Cleans up modeling errors in whatever context this makes sense. | |
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 a new value. | |
void | clear_material () |
Removes any material from the primitive. | |
void | clear_texture () |
Removes any texturing from the primitive. | |
void | copy_attributes (const EggPrimitive &other) |
Copies the rendering attributes from the indicated primitive. | |
void | copy_attributes (const EggAttributes &other) |
Copies the rendering attributes from the indicated primitive. | |
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 primitive. | |
virtual EggRenderMode * | determine_alpha_mode () |
Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this level or above this primitive that has an alpha_mode other than AM_unspecified. | |
virtual EggRenderMode * | determine_bin () |
Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this level or above this primitive that has a bin specified. | |
virtual EggRenderMode * | determine_depth_offset () |
Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this level or above this primitive that has a depth_offset specified. | |
virtual EggRenderMode * | determine_depth_test_mode () |
Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this level or above this node that has a depth_test_mode other than DTM_unspecified. | |
virtual EggRenderMode * | determine_depth_write_mode () |
Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this level or above this node that has a depth_write_mode other than DWM_unspecified. | |
virtual EggRenderMode * | determine_draw_order () |
Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this level or above this primitive that has a draw_order specified. | |
virtual EggRenderMode * | determine_visibility_mode () |
Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this level or above this node that has a visibility_mode other than VM_unspecified. | |
bool | empty () const |
iterator | end () const |
iterator | erase (iterator position) |
iterator | erase (iterator first, iterator last) |
Part of the implementaion of the EggPrimitive as an STL container. | |
iterator | find (EggVertex *vertex) |
Returns the iterator pointing to the indicated vertex, or end() if the vertex is not part of the primitive. | |
virtual TypeHandle | force_init_type () |
bool | get_bface_flag () const |
Retrieves the backfacing flag of the polygon. | |
Shading | get_connected_shading () const |
Determines what sort of shading properties this primitive's connected neighbors have. | |
EggMaterial * | get_material () const |
Returns a pointer to the applied material, or NULL if there is no material applied. | |
int | get_num_textures () const |
Returns the number of textures applied to the primitive. | |
int | get_num_vertices () const |
EggVertexPool * | get_pool () const |
Returns the vertex pool associated with the vertices of the primitive, or NULL if the primitive has no vertices. | |
virtual Shading | get_shading () const |
Returns the shading properties apparent on this particular primitive. | |
string | get_sort_name () const |
Returns the name of the primitive for the purposes of sorting primitives into different groups, if there is one. | |
EggTexture * | get_texture () const |
Returns the first texture on the primitive, if any, or NULL if there are no textures on the primitive. | |
EggTexture * | get_texture (int n) const |
Returns the nth texture that has been applied to the primitive. | |
virtual TypeHandle | get_type () const |
EggVertex * | get_vertex (int index) const |
Returns a particular index based on its index number. | |
bool | has_material () const |
Returns true if the primitive is materiald (and get_material() will return a real pointer), false otherwise (and get_material() will return NULL). | |
virtual bool | has_normals () const |
Returns true if any of the primitives (e.g. | |
virtual bool | has_primitives () const |
Returns true if there are any primitives (e.g. | |
bool | has_texture () const |
Returns true if the primitive has any textures specified, false otherwise. | |
bool | has_texture (EggTexture *texture) const |
Returns true if the primitive has the particular indicated texture, false otherwise. | |
bool | has_vertex_color () const |
Returns true if any vertex on the primitive has a specific color set, false otherwise. | |
bool | has_vertex_normal () const |
Returns true if any vertex on the primitive has a specific normal set, false otherwise. | |
iterator | insert (iterator position, EggVertex *x) |
virtual bool | joint_has_primitives () const |
Returns true if there are any primitives (e.g. | |
MAKE_SEQ (get_vertices, get_num_vertices, get_vertex) | |
MAKE_SEQ (get_textures, get_num_textures, get_texture) | |
EggPrimitive & | operator= (const EggPrimitive ©) |
EggVertex * | operator[] (int index) const |
This is read-only: you can't assign directly to an indexed vertex. | |
virtual void | post_apply_flat_attribute () |
Intended as a followup to apply_last_attribute(), this also sets an attribute on the first vertices of the primitive, if they don't already have an attribute set, just so they end up with *something*. | |
reverse_iterator | rbegin () const |
void | remove_doubled_verts (bool closed) |
Certain kinds of primitives, particularly polygons, don't like to have the same vertex repeated consecutively. | |
void | remove_nonunique_verts () |
Removes any multiple appearances of the same vertex from the primitive. | |
EggVertex * | remove_vertex (EggVertex *vertex) |
Removes the indicated vertex from the primitive and returns it. | |
reverse_iterator | rend () const |
void | replace (iterator position, EggVertex *vertex) |
Replaces the vertex at the indicated position with the indicated vertex. | |
virtual void | reverse_vertex_ordering () |
Reverses the ordering of the vertices in this primitive, if appropriate, in order to change the direction the polygon appears to be facing. | |
void | set_bface_flag (bool flag) |
Sets the backfacing flag of the polygon. | |
void | set_material (EggMaterial *material) |
Applies the indicated material to the primitive. | |
void | set_texture (EggTexture *texture) |
Replaces the current list of textures with the indicated texture. | |
void | set_vertex (int index, EggVertex *vertex) |
Replaces a particular vertex based on its index number in the list of vertices. | |
size_type | size () const |
void | test_vref_integrity () const |
virtual void | unify_attributes (Shading shading) |
If the shading property is S_per_vertex, ensures that all vertices have a normal and a color, and the overall primitive does not. | |
virtual void | write (ostream &out, int indent_level) const =0 |
Writes the attributes to the indicated output stream in Egg format. | |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
Protected Member Functions | |
void | do_apply_flat_attribute (int vertex_index, EggAttributes *attrib) |
This is used to implement apply_first_attribute() and apply_last_attribute(). | |
virtual bool | egg_start_parse_body () |
This function is called within parse_egg(). | |
virtual void | prepare_add_vertex (EggVertex *vertex, int i, int n) |
Marks the vertex as belonging to the primitive. | |
virtual void | prepare_remove_vertex (EggVertex *vertex, int i, int n) |
Marks the vertex as removed from the primitive. | |
virtual void | r_apply_texmats (EggTextureCollection &textures) |
The recursive implementation of apply_texmats(). | |
virtual void | r_flatten_transforms () |
The recursive implementation of flatten_transforms(). | |
virtual void | r_transform (const LMatrix4d &mat, const LMatrix4d &inv, CoordinateSystem to_cs) |
This is called from within the egg code by transform(). | |
void | write_body (ostream &out, int indent_level) const |
Writes the attributes and the vertices referenced by the primitive to the indicated output stream in Egg format. | |
Protected Attributes | |
Vertices | _vertices |
Friends | |
class | EggTextureCollection |
A base class for any of a number of kinds of geometry primitives: polygons, point lights, nurbs patches, parametrics curves, etc.
Things with a set of vertices and some rendering properties like color.
An EggPrimitive is an STL-style container of pointers to EggVertex's. In fact, it IS a vector, and can be manipulated in all the ways that vectors can. However, it is necessary that all vertices belong to the same vertex pool.
Definition at line 51 of file eggPrimitive.h.
void EggPrimitive::add_texture | ( | EggTexture * | texture | ) | [inline] |
Applies the indicated texture to the primitive.
Note that, in the case of multiple textures being applied to a single primitive, the order in which the textures are applied does not affect the rendering order; use EggTexture::set_sort() to specify that.
Definition at line 197 of file eggPrimitive.I.
Referenced by DaeMaterials::apply_to(), and set_texture().
Adds the indicated vertex to the end of the primitive's list of vertices, and returns it.
Definition at line 747 of file eggPrimitive.cxx.
References prepare_add_vertex().
Referenced by DXFToEggLayer::add_line(), DXFToEggLayer::add_polygon(), EggVertexPool::add_unused_vertices_to_prim(), copy_vertices(), XFileMesh::create_polygons(), and EggGroupNode::rebuild_vertex_pools().
void EggPrimitive::apply_first_attribute | ( | ) | [virtual] |
Sets the first vertex of the triangle (or each component) to the primitive normal and/or color, if the primitive is flat-shaded.
This reflects the DirectX convention of storing flat-shaded properties on the first vertex, although it is not usually a convention in Egg.
This may introduce redundant vertices to the vertex pool.
Reimplemented in EggCompositePrimitive, and EggTriangleFan.
Definition at line 506 of file eggPrimitive.cxx.
References do_apply_flat_attribute().
Referenced by EggGroupNode::apply_first_attribute().
void EggPrimitive::apply_last_attribute | ( | ) | [virtual] |
Sets the last vertex of the triangle (or each component) to the primitive normal and/or color, if the primitive is flat-shaded.
This reflects the OpenGL convention of storing flat-shaded properties on the last vertex, although it is not usually a convention in Egg.
This may introduce redundant vertices to the vertex pool.
Reimplemented in EggCompositePrimitive.
Definition at line 486 of file eggPrimitive.cxx.
References do_apply_flat_attribute().
Referenced by EggGroupNode::apply_last_attribute().
bool EggPrimitive::cleanup | ( | ) | [virtual] |
Cleans up modeling errors in whatever context this makes sense.
For instance, for a polygon, this calls remove_doubled_verts(true). For a point, it calls remove_nonunique_verts(). Returns true if the primitive is valid, or false if it is degenerate.
Reimplemented in EggCompositePrimitive, EggPoint, and EggPolygon.
Definition at line 566 of file eggPrimitive.cxx.
Referenced by EggGroupNode::remove_invalid_primitives().
void EggPrimitive::clear | ( | ) | [inline] |
Removes all of the vertices from the primitive.
Definition at line 432 of file eggPrimitive.I.
Referenced by copy_vertices(), and EggGroupNode::rebuild_vertex_pools().
void EggPrimitive::clear_connected_shading | ( | ) | [inline] |
Resets the connected_shading member in this primitive, so that get_connected_shading() will recompute a new value.
Definition at line 98 of file eggPrimitive.I.
Referenced by EggGroupNode::clear_connected_shading().
void EggPrimitive::clear_material | ( | ) | [inline] |
Removes any material from the primitive.
Definition at line 251 of file eggPrimitive.I.
void EggPrimitive::clear_texture | ( | ) | [inline] |
Removes any texturing from the primitive.
Definition at line 207 of file eggPrimitive.I.
Referenced by set_texture().
void EggPrimitive::copy_attributes | ( | const EggAttributes & | other | ) |
Copies the rendering attributes from the indicated primitive.
Definition at line 296 of file eggPrimitive.cxx.
Referenced by EggTriangleFan::do_triangulate(), EggTriangleStrip::do_triangulate(), and EggMesherFanMaker::unroll().
void EggPrimitive::copy_attributes | ( | const EggPrimitive & | other | ) |
Copies the rendering attributes from the indicated primitive.
Definition at line 307 of file eggPrimitive.cxx.
References get_bface_flag(), get_material(), set_bface_flag(), and set_material().
void EggPrimitive::copy_vertices | ( | const EggPrimitive & | other | ) |
Replaces the current primitive's list of vertices with a copy of the list of vertices on the other primitive.
Definition at line 791 of file eggPrimitive.cxx.
References add_vertex(), and clear().
EggRenderMode * EggPrimitive::determine_alpha_mode | ( | ) | [virtual] |
Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this level or above this primitive that has an alpha_mode other than AM_unspecified.
Returns a valid EggRenderMode pointer if one is found, or NULL otherwise.
Reimplemented from EggNode.
Definition at line 38 of file eggPrimitive.cxx.
References EggTexture::affects_polygon_alpha(), EggRenderMode::get_alpha_mode(), get_num_textures(), and get_texture().
Referenced by EggRenderState::fill_state().
EggRenderMode * EggPrimitive::determine_bin | ( | ) | [virtual] |
Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this level or above this primitive that has a bin specified.
Returns a valid EggRenderMode pointer if one is found, or NULL otherwise.
Reimplemented from EggNode.
Definition at line 209 of file eggPrimitive.cxx.
References get_num_textures(), get_texture(), and EggRenderMode::has_bin().
Referenced by EggRenderState::fill_state().
EggRenderMode * EggPrimitive::determine_depth_offset | ( | ) | [virtual] |
Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this level or above this primitive that has a depth_offset specified.
Returns a valid EggRenderMode pointer if one is found, or NULL otherwise.
Reimplemented from EggNode.
Definition at line 155 of file eggPrimitive.cxx.
References get_num_textures(), get_texture(), and EggRenderMode::has_depth_offset().
Referenced by EggRenderState::fill_state().
EggRenderMode * EggPrimitive::determine_depth_test_mode | ( | ) | [virtual] |
Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this level or above this node that has a depth_test_mode other than DTM_unspecified.
Returns a valid EggRenderMode pointer if one is found, or NULL otherwise.
Reimplemented from EggNode.
Definition at line 101 of file eggPrimitive.cxx.
References EggRenderMode::get_depth_test_mode(), get_num_textures(), and get_texture().
Referenced by EggRenderState::fill_state().
EggRenderMode * EggPrimitive::determine_depth_write_mode | ( | ) | [virtual] |
Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this level or above this node that has a depth_write_mode other than DWM_unspecified.
Returns a valid EggRenderMode pointer if one is found, or NULL otherwise.
Reimplemented from EggNode.
Definition at line 74 of file eggPrimitive.cxx.
References EggRenderMode::get_depth_write_mode(), get_num_textures(), and get_texture().
Referenced by EggRenderState::fill_state().
EggRenderMode * EggPrimitive::determine_draw_order | ( | ) | [virtual] |
Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this level or above this primitive that has a draw_order specified.
Returns a valid EggRenderMode pointer if one is found, or NULL otherwise.
Reimplemented from EggNode.
Definition at line 182 of file eggPrimitive.cxx.
References get_num_textures(), get_texture(), and EggRenderMode::has_draw_order().
Referenced by EggRenderState::fill_state().
EggRenderMode * EggPrimitive::determine_visibility_mode | ( | ) | [virtual] |
Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this level or above this node that has a visibility_mode other than VM_unspecified.
Returns a valid EggRenderMode pointer if one is found, or NULL otherwise.
Reimplemented from EggNode.
Definition at line 128 of file eggPrimitive.cxx.
References get_num_textures(), get_texture(), and EggRenderMode::get_visibility_mode().
Referenced by EggRenderState::fill_state().
void EggPrimitive::do_apply_flat_attribute | ( | int | vertex_index, |
EggAttributes * | attrib | ||
) | [protected] |
This is used to implement apply_first_attribute() and apply_last_attribute().
It copies the indicated attributes to the specified vertex.
Definition at line 1136 of file eggPrimitive.cxx.
References EggVertex::copy_grefs_from(), EggVertexPool::create_unique_vertex(), get_pool(), get_vertex(), EggAttributes::matches_color(), EggAttributes::matches_normal(), and set_vertex().
Referenced by EggCompositePrimitive::apply_first_attribute(), apply_first_attribute(), EggTriangleFan::apply_first_attribute(), apply_last_attribute(), and EggCompositePrimitive::apply_last_attribute().
bool EggPrimitive::egg_start_parse_body | ( | ) | [protected, virtual] |
This function is called within parse_egg().
It should call the appropriate function on the lexer to initialize the parser into the state associated with this object. If the object cannot be parsed into directly, it should return false.
Reimplemented from EggNode.
Definition at line 1014 of file eggPrimitive.cxx.
EggPrimitive::iterator EggPrimitive::erase | ( | iterator | first, |
iterator | last | ||
) |
Part of the implementaion of the EggPrimitive as an STL container.
Most of the rest of these functions are inline and declared in EggPrimitive.I.
Definition at line 712 of file eggPrimitive.cxx.
References prepare_remove_vertex().
EggPrimitive::iterator EggPrimitive::find | ( | EggVertex * | vertex | ) |
Returns the iterator pointing to the indicated vertex, or end() if the vertex is not part of the primitive.
Definition at line 734 of file eggPrimitive.cxx.
Referenced by has_texture(), EggVertexPool::remove_unused_vertices(), and remove_vertex().
bool EggPrimitive::get_bface_flag | ( | ) | const [inline] |
Retrieves the backfacing flag of the polygon.
See set_bface_flag().
Definition at line 301 of file eggPrimitive.I.
Referenced by copy_attributes(), EggRenderState::fill_state(), EggPolysetMaker::sorts_less(), and write_body().
EggPrimitive::Shading EggPrimitive::get_connected_shading | ( | ) | const [inline] |
Determines what sort of shading properties this primitive's connected neighbors have.
To get the most accurate results, you should first call clear_connected_shading() on all connected primitives (or on all primitives in the egg file). It might also be a good idea to call remove_unused_vertices() to ensure proper connectivity.
You may find it easiest to call these other methods on the EggData root node (they are defined on EggGroupNode).
Definition at line 120 of file eggPrimitive.I.
Referenced by EggRenderState::fill_state(), EggGroupNode::get_connected_shading(), and EggGroupNode::unify_attributes().
EggMaterial * EggPrimitive::get_material | ( | ) | const [inline] |
Returns a pointer to the applied material, or NULL if there is no material applied.
Definition at line 262 of file eggPrimitive.I.
Referenced by copy_attributes(), EggRenderState::fill_state(), EggMaterialCollection::find_used_materials(), EggMaterialCollection::replace_materials(), XFileMaterial::set_from_egg(), EggPolysetMaker::sorts_less(), and write_body().
int EggPrimitive::get_num_textures | ( | ) | const [inline] |
Returns the number of textures applied to the primitive.
Definition at line 218 of file eggPrimitive.I.
Referenced by determine_alpha_mode(), determine_bin(), determine_depth_offset(), determine_depth_test_mode(), determine_depth_write_mode(), determine_draw_order(), determine_visibility_mode(), EggRenderState::fill_state(), EggTextureCollection::find_used_textures(), has_texture(), EggPolysetMaker::sorts_less(), and write_body().
EggVertexPool * EggPrimitive::get_pool | ( | ) | const [inline] |
Returns the vertex pool associated with the vertices of the primitive, or NULL if the primitive has no vertices.
Definition at line 480 of file eggPrimitive.I.
Referenced by do_apply_flat_attribute(), EggLoader::make_polyset(), EggMesher::mesh(), prepare_add_vertex(), and write_body().
EggPrimitive::Shading EggPrimitive::get_shading | ( | ) | const [virtual] |
Returns the shading properties apparent on this particular primitive.
This returns S_per_vertex if the vertices have colors or normals (and they are not all the same values), or for a simple primitive, S_overall otherwise. A composite primitive may also return S_per_face if the individual component primitives have colors or normals that are not all the same values.
To get the most accurate results, you should call clear_shading() on all connected primitives (or on all primitives in the egg file), followed by get_shading() on each primitive. You may find it easiest to call these methods on the EggData root node (they are defined on EggGroupNode).
Reimplemented in EggCompositePrimitive.
Definition at line 247 of file eggPrimitive.cxx.
References get_vertex(), has_vertex_color(), has_vertex_normal(), EggAttributes::matches_color(), and EggAttributes::matches_normal().
Referenced by unify_attributes(), and EggGroupNode::unify_attributes().
string EggPrimitive::get_sort_name | ( | ) | const [inline] |
Returns the name of the primitive for the purposes of sorting primitives into different groups, if there is one.
Presently, this is defined as the primitive name itself, unless it begins with a digit.
Definition at line 82 of file eggPrimitive.I.
Referenced by EggBinner::sorts_less().
EggTexture * EggPrimitive::get_texture | ( | ) | const [inline] |
Returns the first texture on the primitive, if any, or NULL if there are no textures on the primitive.
This method is deprecated and is used in support of single-texturing only. New code should be written to use the multitexture variants instead.
Definition at line 182 of file eggPrimitive.I.
References has_texture().
Referenced by determine_alpha_mode(), determine_bin(), determine_depth_offset(), determine_depth_test_mode(), determine_depth_write_mode(), determine_draw_order(), determine_visibility_mode(), EggRenderState::fill_state(), EggTextureCollection::find_used_textures(), XFileVertex::set_from_egg(), XFileMaterial::set_from_egg(), EggPolysetMaker::sorts_less(), and write_body().
EggTexture * EggPrimitive::get_texture | ( | int | n | ) | const [inline] |
Returns the nth texture that has been applied to the primitive.
Definition at line 229 of file eggPrimitive.I.
EggVertex * EggPrimitive::get_vertex | ( | int | index | ) | const [inline] |
Returns a particular index based on its index number.
Definition at line 466 of file eggPrimitive.I.
References EggTextureCollection::size().
Referenced by EggPolygon::calculate_normal(), do_apply_flat_attribute(), EggNurbsSurface::get_cv(), get_shading(), post_apply_flat_attribute(), EggCompositePrimitive::post_apply_flat_attribute(), r_apply_texmats(), r_flatten_transforms(), EggGroupNode::recompute_polygon_normals(), and EggGroupNode::strip_normals().
bool EggPrimitive::has_material | ( | ) | const [inline] |
Returns true if the primitive is materiald (and get_material() will return a real pointer), false otherwise (and get_material() will return NULL).
Definition at line 275 of file eggPrimitive.I.
Referenced by EggRenderState::fill_state(), EggMaterialCollection::find_used_materials(), EggMaterialCollection::replace_materials(), XFileMaterial::set_from_egg(), EggPolysetMaker::sorts_less(), and write_body().
bool EggPrimitive::has_normals | ( | ) | const [virtual] |
Returns true if any of the primitives (e.g.
polygons) defined within this group or below have either face or vertex normals defined, false otherwise.
Reimplemented from EggNode.
Definition at line 688 of file eggPrimitive.cxx.
bool EggPrimitive::has_primitives | ( | ) | const [virtual] |
Returns true if there are any primitives (e.g.
polygons) defined within this group or below, false otherwise.
Reimplemented from EggNode.
Definition at line 664 of file eggPrimitive.cxx.
bool EggPrimitive::has_texture | ( | ) | const [inline] |
Returns true if the primitive has any textures specified, false otherwise.
This method is deprecated and is used in support of single-texturing only. New code should be written to use the multitexture variants instead.
Definition at line 155 of file eggPrimitive.I.
References get_num_textures().
Referenced by get_texture(), XFileVertex::set_from_egg(), and XFileMaterial::set_from_egg().
bool EggPrimitive::has_texture | ( | EggTexture * | texture | ) | const [inline] |
Returns true if the primitive has the particular indicated texture, false otherwise.
Definition at line 166 of file eggPrimitive.I.
References find().
bool EggPrimitive::has_vertex_color | ( | ) | const |
Returns true if any vertex on the primitive has a specific color set, false otherwise.
If you call unify_attributes() first, this will also return false even if all the vertices were set to the same value (since unify_attributes() removes redundant vertex properties).
Definition at line 348 of file eggPrimitive.cxx.
Referenced by get_shading(), and EggPolysetMaker::sorts_less().
bool EggPrimitive::has_vertex_normal | ( | ) | const |
Returns true if any vertex on the primitive has a specific normal set, false otherwise.
If you call unify_attributes() first, this will also return false even if all the vertices were set to the same value (since unify_attributes() removes redundant vertex properties).
Definition at line 326 of file eggPrimitive.cxx.
Referenced by get_shading(), and EggPolysetMaker::sorts_less().
bool EggPrimitive::joint_has_primitives | ( | ) | const [virtual] |
Returns true if there are any primitives (e.g.
polygons) defined within this group or below, but the search does not include nested joints.
Reimplemented from EggNode.
Definition at line 676 of file eggPrimitive.cxx.
EggVertex * EggPrimitive::operator[] | ( | int | index | ) | const [inline] |
This is read-only: you can't assign directly to an indexed vertex.
See set_vertex() instead.
Definition at line 373 of file eggPrimitive.I.
References EggTextureCollection::size().
void EggPrimitive::post_apply_flat_attribute | ( | ) | [virtual] |
Intended as a followup to apply_last_attribute(), this also sets an attribute on the first vertices of the primitive, if they don't already have an attribute set, just so they end up with *something*.
Reimplemented in EggCompositePrimitive.
Definition at line 521 of file eggPrimitive.cxx.
References EggAttributes::get_color(), and get_vertex().
Referenced by EggGroupNode::post_apply_flat_attribute().
void EggPrimitive::prepare_add_vertex | ( | EggVertex * | vertex, |
int | i, | ||
int | n | ||
) | [protected, virtual] |
Marks the vertex as belonging to the primitive.
This is an internal function called by the STL-like functions push_back() and insert(), in preparation for actually adding the vertex.
i indicates the new position of the vertex in the list; n indicates the new number of vertices after the operation has completed.
Reimplemented in EggCompositePrimitive.
Definition at line 866 of file eggPrimitive.cxx.
References get_pool(), and EggVertex::get_pool().
Referenced by add_vertex(), and replace().
void EggPrimitive::prepare_remove_vertex | ( | EggVertex * | vertex, |
int | i, | ||
int | n | ||
) | [protected, virtual] |
Marks the vertex as removed from the primitive.
This is an internal function called by the STL-like functions pop_back() and erase(), in preparation for actually doing the removal.
i indicates the former position of the vertex in the list; n indicates the current number of vertices before the operation has completed.
It is an error to attempt to remove a vertex that is not already a vertex of this primitive.
Reimplemented in EggCompositePrimitive.
Definition at line 899 of file eggPrimitive.cxx.
Referenced by erase(), remove_doubled_verts(), remove_nonunique_verts(), and replace().
void EggPrimitive::r_apply_texmats | ( | EggTextureCollection & | textures | ) | [protected, virtual] |
The recursive implementation of apply_texmats().
Reimplemented from EggNode.
Reimplemented in EggNurbsSurface.
Definition at line 1070 of file eggPrimitive.cxx.
References EggTransform::clear_transform(), EggVertex::copy_grefs_from(), EggTextureCollection::create_unique_texture(), EggVertexPool::create_unique_vertex(), EggVertex::get_pool(), EggTransform::get_transform3d(), EggTexture::get_uv_name(), EggVertex::get_uv_obj(), EggVertexUV::get_uvw(), get_vertex(), EggTransform::has_transform(), EggTransform::has_transform3d(), EggVertexUV::has_w(), EggVertex::set_uv_obj(), set_vertex(), and EggTransform::transform_is_identity().
void EggPrimitive::r_flatten_transforms | ( | ) | [protected, virtual] |
The recursive implementation of flatten_transforms().
Reimplemented from EggNode.
Definition at line 1043 of file eggPrimitive.cxx.
References EggVertex::copy_grefs_from(), EggVertexPool::create_unique_vertex(), EggVertex::get_pool(), get_vertex(), EggNode::get_vertex_frame(), EggNode::is_local_coord(), set_vertex(), EggAttributes::transform(), and EggVertex::transform().
void EggPrimitive::r_transform | ( | const LMatrix4d & | mat, |
const LMatrix4d & | inv, | ||
CoordinateSystem | to_cs | ||
) | [protected, virtual] |
This is called from within the egg code by transform().
It applies a transformation matrix to the current node in some sensible way, then continues down the tree.
The first matrix is the transformation to apply; the second is its inverse. The third parameter is the coordinate system we are changing to, or CS_default if we are not changing coordinate systems.
Reimplemented from EggNode.
Definition at line 1033 of file eggPrimitive.cxx.
References EggAttributes::transform().
void EggPrimitive::remove_doubled_verts | ( | bool | closed | ) |
Certain kinds of primitives, particularly polygons, don't like to have the same vertex repeated consecutively.
Unfortunately, some modeling programs (like MultiGen) make this an easy mistake to make.
It's handy to have a function to remove these redundant vertices. If closed is true, it also checks that the first and last vertices are not the same.
This function identifies repeated vertices by position only; it does not consider any other properties, such as color or UV, significant in differentiating vertices.
Definition at line 589 of file eggPrimitive.cxx.
References prepare_remove_vertex().
Referenced by EggPolygon::cleanup().
void EggPrimitive::remove_nonunique_verts | ( | ) |
Removes any multiple appearances of the same vertex from the primitive.
This primarily makes sense for a point primitive, which is really a collection of points and which doesn't make sense to include the same point twice, in any order.
Definition at line 636 of file eggPrimitive.cxx.
References prepare_remove_vertex().
Referenced by EggPoint::cleanup().
Removes the indicated vertex from the primitive and returns it.
If the vertex was not already in the primitive, does nothing and returns NULL.
Definition at line 766 of file eggPrimitive.cxx.
References find().
void EggPrimitive::replace | ( | iterator | position, |
EggVertex * | x | ||
) | [inline] |
Replaces the vertex at the indicated position with the indicated vertex.
It is an error to call this with an invalid position iterator (e.g. end()).
Definition at line 413 of file eggPrimitive.I.
References prepare_add_vertex(), and prepare_remove_vertex().
Referenced by EggVertexPool::remove_unused_vertices(), set_vertex(), and unify_attributes().
void EggPrimitive::reverse_vertex_ordering | ( | ) | [virtual] |
Reverses the ordering of the vertices in this primitive, if appropriate, in order to change the direction the polygon appears to be facing.
Does not adjust the surface normal, if any.
Definition at line 549 of file eggPrimitive.cxx.
Referenced by EggGroupNode::reverse_vertex_ordering().
void EggPrimitive::set_bface_flag | ( | bool | flag | ) | [inline] |
Sets the backfacing flag of the polygon.
If this is true, the polygon will be rendered so that both faces are visible; if it is false, only the front face of the polygon will be visible.
Definition at line 289 of file eggPrimitive.I.
Referenced by CLwoSurface::apply_properties(), DaeMaterials::apply_to(), and copy_attributes().
void EggPrimitive::set_material | ( | EggMaterial * | material | ) | [inline] |
Applies the indicated material to the primitive.
Definition at line 241 of file eggPrimitive.I.
Referenced by CLwoSurface::apply_properties(), DaeMaterials::apply_to(), XFileMaterial::apply_to_egg(), copy_attributes(), and EggMaterialCollection::replace_materials().
void EggPrimitive::set_texture | ( | EggTexture * | texture | ) | [inline] |
Replaces the current list of textures with the indicated texture.
This method is deprecated and is used in support of single-texturing only. Please use the multitexture variant add_texture instead.
Definition at line 139 of file eggPrimitive.I.
References add_texture(), and clear_texture().
Referenced by CLwoSurface::apply_properties(), and XFileMaterial::apply_to_egg().
void EggPrimitive::set_vertex | ( | int | index, |
EggVertex * | vertex | ||
) | [inline] |
Replaces a particular vertex based on its index number in the list of vertices.
This is just a convenience function for people who don't want to mess with the iterators.
Definition at line 455 of file eggPrimitive.I.
References replace(), and EggTextureCollection::size().
Referenced by do_apply_flat_attribute(), r_apply_texmats(), r_flatten_transforms(), EggGroupNode::recompute_polygon_normals(), EggNurbsSurface::set_cv(), and EggGroupNode::strip_normals().
void EggPrimitive::unify_attributes | ( | EggPrimitive::Shading | shading | ) | [virtual] |
If the shading property is S_per_vertex, ensures that all vertices have a normal and a color, and the overall primitive does not.
If the shading property is S_per_face, and this is a composite primitive, ensures that all components have a normal and a color, and the vertices and overall primitive do not. (If this is a simple primitive, S_per_face works the same as S_overall, below).
If the shading property is S_overall, ensures that no vertices or components have a normal or a color, and the overall primitive does (if any exists at all).
After this call, either the primitive will have normals or its vertices will, but not both. Ditto for colors.
This may create redundant vertices in the vertex pool.
Reimplemented in EggCompositePrimitive.
Definition at line 383 of file eggPrimitive.cxx.
References EggAttributes::copy_color(), EggVertex::copy_grefs_from(), EggAttributes::copy_normal(), EggVertexPool::create_unique_vertex(), EggAttributes::get_color(), EggVertex::get_pool(), get_shading(), and replace().
Referenced by EggGroupNode::unify_attributes().
virtual void EggPrimitive::write | ( | ostream & | out, |
int | indent_level | ||
) | const [pure virtual] |
Writes the attributes to the indicated output stream in Egg format.
Reimplemented from EggAttributes.
Implemented in EggLine, EggNurbsCurve, EggNurbsSurface, EggPoint, EggPolygon, EggTriangleFan, and EggTriangleStrip.
Referenced by write_body().
void EggPrimitive::write_body | ( | ostream & | out, |
int | indent_level | ||
) | const [protected] |
Writes the attributes and the vertices referenced by the primitive to the indicated output stream in Egg format.
Reimplemented in EggCompositePrimitive.
Definition at line 925 of file eggPrimitive.cxx.
References get_bface_flag(), EggVertex::get_index(), get_material(), get_num_textures(), get_pool(), EggVertex::get_pool(), get_texture(), has_material(), Namable::has_name(), and write().
Referenced by EggNurbsCurve::write(), EggNurbsSurface::write(), and EggPoint::write().