Panda3D
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties
Public Types | Public Member Functions | Static Public Member Functions
EggPrimitive Class Reference

A base class for any of a number of kinds of geometry primitives: polygons, point lights, nurbs patches, parametrics curves, etc. More...

Inheritance diagram for EggPrimitive:
EggNode EggAttributes EggRenderMode EggNamedObject MemoryBase EggObject EggCompositePrimitive EggCurve EggPoint EggPolygon EggSurface EggLine EggTriangleFan EggTriangleStrip EggNurbsCurve EggNurbsSurface

List of all members.

Public Types

enum  Shading { SUnknown = 0, SOverall = 1, SPerFace = 2, SPerVertex = 3 }

Public Member Functions

 addTexture (EggTexture texture)
 Applies the indicated texture to the primitive.
EggVertex addVertex (EggVertex vertex)
 Adds the indicated vertex to the end of the primitive's list of vertices, and returns it.
 applyFirstAttribute ()
 Sets the first vertex of the triangle (or each component) to the primitive normal and/or color, if the primitive is flat-shaded.
 applyLastAttribute ()
 Sets the last vertex of the triangle (or each component) to the primitive normal and/or color, if the primitive is flat-shaded.
bool cleanup ()
 Cleans up modeling errors in whatever context this makes sense.
 clear ()
 Removes all of the vertices from the primitive.
 clearConnectedShading ()
 Resets the connected_shading member in this primitive, so that get_connected_shading() will recompute a new value.
 clearMaterial ()
 Removes any material from the primitive.
 clearTexture ()
 Removes any texturing from the primitive.
 copyAttributes (EggAttributes const other)
 Copies the rendering attributes from the indicated primitive.
 copyAttributes (EggPrimitive const other)
 Copies the rendering attributes from the indicated primitive.
 copyVertices (EggPrimitive const other)
 Replaces the current primitive's list of vertices with a copy of the list of vertices on the other primitive.
EggRenderMode determineAlphaMode ()
 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.
EggRenderMode determineBin ()
 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.
EggRenderMode determineDepthOffset ()
 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.
EggRenderMode determineDepthTestMode ()
 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.
EggRenderMode determineDepthWriteMode ()
 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.
EggRenderMode determineDrawOrder ()
 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.
EggRenderMode determineVisibilityMode ()
 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 getBfaceFlag ()
 Retrieves the backfacing flag of the polygon.
Shading getConnectedShading ()
 Determines what sort of shading properties this primitive's connected neighbors have.
EggMaterial getMaterial ()
 Returns a pointer to the applied material, or NULL if there is no material applied.
int getNumTextures ()
 Returns the number of textures applied to the primitive.
int getNumVertices ()
EggVertexPool getPool ()
 Returns the vertex pool associated with the vertices of the primitive, or NULL if the primitive has no vertices.
Shading getShading ()
 Returns the shading properties apparent on this particular primitive.
string getSortName ()
 Returns the name of the primitive for the purposes of sorting primitives into different groups, if there is one.
EggTexture getTexture ()
 Returns the first texture on the primitive, if any, or NULL if there are no textures on the primitive.
EggTexture getTexture (int n)
 Returns the nth texture that has been applied to the primitive.
list getTextures ()
EggVertex getVertex (int index)
 Returns a particular index based on its index number.
list getVertices ()
bool hasMaterial ()
 Returns true if the primitive is materiald (and get_material() will return a real pointer), false otherwise (and get_material() will return NULL).
bool hasNormals ()
 Returns true if any of the primitives (e.g.
bool hasPrimitives ()
 Returns true if there are any primitives (e.g.
bool hasTexture ()
 Returns true if the primitive has any textures specified, false otherwise.
bool hasTexture (EggTexture texture)
 Returns true if the primitive has the particular indicated texture, false otherwise.
bool hasVertexColor ()
 Returns true if any vertex on the primitive has a specific color set, false otherwise.
bool hasVertexNormal ()
 Returns true if any vertex on the primitive has a specific normal set, false otherwise.
bool jointHasPrimitives ()
 Returns true if there are any primitives (e.g.
EggPrimitive operator= (EggPrimitive const copy)
 postApplyFlatAttribute ()
 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*.
 removeDoubledVerts (bool closed)
 Certain kinds of primitives, particularly polygons, don't like to have the same vertex repeated consecutively.
 removeNonuniqueVerts ()
 Removes any multiple appearances of the same vertex from the primitive.
EggVertex removeVertex (EggVertex vertex)
 Removes the indicated vertex from the primitive and returns it.
 reverseVertexOrdering ()
 Reverses the ordering of the vertices in this primitive, if appropriate, in order to change the direction the polygon appears to be facing.
 setBfaceFlag (bool flag)
 Sets the backfacing flag of the polygon.
 setMaterial (EggMaterial material)
 Applies the indicated material to the primitive.
 setTexture (EggTexture texture)
 Replaces the current list of textures with the indicated texture.
 setVertex (int index, EggVertex vertex)
 Replaces a particular vertex based on its index number in the list of vertices.
 testVrefIntegrity ()
 unifyAttributes (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.
 write (ostream out, int indent_level)

Static Public Member Functions

static TypeHandle getClassType ()

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.


Member Enumeration Documentation

enum Shading
Enumerator:
SUnknown 
SOverall 
SPerFace 
SPerVertex 

Member Function Documentation

addTexture ( EggTexture  texture)

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.

Adds the indicated vertex to the end of the primitive's list of vertices, and returns it.

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.

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.

bool cleanup ( )

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.

clear ( )

Removes all of the vertices from the primitive.

Resets the connected_shading member in this primitive, so that get_connected_shading() will recompute a new value.

Removes any material from the primitive.

Removes any texturing from the primitive.

copyAttributes ( EggAttributes const  other)

Copies the rendering attributes from the indicated primitive.

copyAttributes ( EggPrimitive const  other)

Copies the rendering attributes from the indicated primitive.

copyVertices ( EggPrimitive const  other)

Replaces the current primitive's list of vertices with a copy of the list of vertices on the other primitive.

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.

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.

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.

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.

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.

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.

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.

bool getBfaceFlag ( )

Retrieves the backfacing flag of the polygon.

See set_bface_flag().

static TypeHandle getClassType ( ) [static]

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).

Returns a pointer to the applied material, or NULL if there is no material applied.

int getNumTextures ( )

Returns the number of textures applied to the primitive.

int getNumVertices ( )

Returns the vertex pool associated with the vertices of the primitive, or NULL if the primitive has no vertices.

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).

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.

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.

EggTexture getTexture ( int  n)

Returns the nth texture that has been applied to the primitive.

list getTextures ( )
EggVertex getVertex ( int  index)

Returns a particular index based on its index number.

list getVertices ( )
bool hasMaterial ( )

Returns true if the primitive is materiald (and get_material() will return a real pointer), false otherwise (and get_material() will return NULL).

bool hasNormals ( )

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.

bool hasPrimitives ( )

Returns true if there are any primitives (e.g.

polygons) defined within this group or below, false otherwise.

bool hasTexture ( )

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.

bool hasTexture ( EggTexture  texture)

Returns true if the primitive has the particular indicated texture, false otherwise.

bool hasVertexColor ( )

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).

bool hasVertexNormal ( )

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).

Returns true if there are any primitives (e.g.

polygons) defined within this group or below, but the search does not include nested joints.

EggPrimitive operator= ( EggPrimitive const  copy)

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*.

removeDoubledVerts ( 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.

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.

Removes the indicated vertex from the primitive and returns it.

If the vertex was not already in the primitive, does nothing and returns NULL.

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.

setBfaceFlag ( bool  flag)

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.

setMaterial ( EggMaterial  material)

Applies the indicated material to the primitive.

setTexture ( EggTexture  texture)

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.

setVertex ( int  index,
EggVertex  vertex 
)

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.

unifyAttributes ( 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.

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.

write ( ostream  out,
int  indent_level 
)

Reimplemented from EggNode.

 All Classes Namespaces Functions Variables Enumerations Enumerator Properties