|
|
|
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"
List of all members.
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 EggAttributes &other) |
| | Copies the rendering attributes from the indicated primitive.
|
| void | copy_attributes (const EggPrimitive &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_textures, get_num_textures, get_texture) |
|
| MAKE_SEQ (get_vertices, get_num_vertices, get_vertex) |
|
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 |
Detailed Description
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.
Member Function Documentation
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_primitive(), and set_texture().
Removes any material from the primitive.
Definition at line 251 of file eggPrimitive.I.
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().
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 EggTriangleFan::apply_first_attribute(), EggCompositePrimitive::apply_first_attribute(), apply_first_attribute(), EggCompositePrimitive::apply_last_attribute(), and apply_last_attribute().
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 |
|
) |
| |
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().
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().
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().
Returns the nth texture that has been applied to the primitive.
Definition at line 229 of file eggPrimitive.I.
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.
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.
Returns true if the primitive has the particular indicated texture, false otherwise.
Definition at line 166 of file eggPrimitive.I.
References find().
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] |
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 EggVertex::get_pool(), and get_pool().
Referenced by add_vertex(), and replace().
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().
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().
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().
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().
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().
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().
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(), EggVertex::get_pool(), get_pool(), get_texture(), has_material(), Namable::has_name(), and write().
Referenced by EggPatch::write(), EggPoint::write(), EggNurbsCurve::write(), and EggNurbsSurface::write().
The documentation for this class was generated from the following files:
| | |