Panda3D
Public Member Functions | Static Public Member Functions | List of all members
EggVertexPool Class Reference

A collection of vertices. More...

Inheritance diagram for EggVertexPool:
EggNode EggNamedObject EggObject Namable TypedReferenceCount TypedObject ReferenceCount

Public Member Functions

 __init__ (const EggVertexPool copy)
 Copying a vertex pool is of questionable value, since it will copy all of the vertices and assign new pointers to them all. More...
 
 __init__ (str name)
 
 addUnusedVerticesToPrim (EggPrimitive prim)
 Adds all of the unused vertices in this vertex pool to the indicated primitive, in ascending order. More...
 
EggVertex addVertex (EggVertex vertex, int index)
 Adds the indicated vertex to the pool. More...
 
EggVertex createUniqueVertex (const EggVertex copy)
 Creates a new vertex in the pool that is a copy of the indicated one and returns it. More...
 
EggVertex findMatchingVertex (const EggVertex copy)
 If the EggVertexPool already has a vertex matching the indicated vertex, returns it; otherwise, returns NULL. More...
 
 getAuxNames (VectorString aux_names)
 Returns the list of auxiliary data names that are defined by any vertices in the pool. More...
 
EggVertex getForwardVertex (int index)
 Returns the vertex in the pool with the indicated index number. More...
 
int getHighestIndex ()
 Returns the highest index number used by any vertex in the pool (except forward references). More...
 
int getNumDimensions ()
 Returns the maximum number of dimensions used by any vertex in the pool. More...
 
 getUvNames (VectorString uv_names, VectorString uvw_names, VectorString tbn_names)
 Returns the list of UV names that are defined by any vertices in the pool, as well as the subset of UV names that actually define 3-d texture coordinates ("uvw_names"). More...
 
EggVertex getVertex (int index)
 Returns the vertex in the pool with the indicated index number, or NULL if no vertices have that index number. More...
 
bool hasAux ()
 Returns true if any vertex in the pool has auxiliary data defined, false if none of them do. More...
 
bool hasColors ()
 Returns true if any vertex in the pool has a color defined, false if none of them do. More...
 
bool hasDefinedVertices ()
 Returns true if any vertices in the pool are fully defined vertices, false if all vertices are forward references. More...
 
bool hasForwardVertices ()
 Returns true if any vertices in the pool are undefined forward-reference vertices, false if all vertices are defined. More...
 
bool hasNonwhiteColors ()
 Returns true if any vertex in the pool has a color defined other than white, false if no vertices have colors, or if all colors are white. More...
 
bool hasNormals ()
 Returns true if any vertex in the pool has a normal defined, false if none of them do. More...
 
bool hasUvs ()
 Returns true if any vertex in the pool has a uv defined, false if none of them do. More...
 
bool hasVertex (int index)
 Returns true if the indicated vertex has been defined in the vertex pool, false otherwise. More...
 
EggVertex makeNewVertex ()
 Allocates and returns a new vertex from the pool. More...
 
EggVertex makeNewVertex (const LPoint2d pos)
 Allocates and returns a new vertex from the pool. More...
 
EggVertex makeNewVertex (const LPoint3d pos)
 Allocates and returns a new vertex from the pool. More...
 
EggVertex makeNewVertex (const LPoint4d pos)
 Allocates and returns a new vertex from the pool. More...
 
EggVertex makeNewVertex (double pos)
 Allocates and returns a new vertex from the pool. More...
 
EggVertex operator [] (int index)
 Returns the vertex in the pool with the indicated index number, or NULL if no vertices have that index number. More...
 
int removeUnusedVertices ()
 Removes all vertices from the pool that are not referenced by at least one primitive. More...
 
 removeVertex (EggVertex vertex)
 Removes the vertex from the pool. More...
 
 setHighestIndex (int highest_index)
 Artificially changes the "highest index number", so that a newly created vertex will begin at this number plus 1. More...
 
EggVertexPool::SizeType size ()
 Returns the number of vertices in the pool. More...
 
 sortByExternalIndex ()
 Re-orders (and re-numbers) the vertices in this vertex pool so that they appear in increasing order by the optional external_index that has been assigned to each vertex. More...
 
 transform (const LMatrix4d mat)
 Applies the indicated transformation matrix to all the vertices. More...
 
- Public Member Functions inherited from EggNode
 applyTexmats ()
 Applies the texture matrices to the UV's of the vertices that reference them, and then removes the texture matrices from the textures themselves. More...
 
EggRenderMode determineAlphaMode ()
 Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this level or above this node that has an alpha_mode other than AM_unspecified. More...
 
EggRenderMode determineBin ()
 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 bin specified. More...
 
bool determineDecal ()
 Walks back up the hierarchy, looking for an EggGroup at this level or above that has the "decal" flag set. More...
 
EggRenderMode determineDepthOffset ()
 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_offset specified. More...
 
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. More...
 
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. More...
 
EggRenderMode determineDrawOrder ()
 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 draw_order specified. More...
 
bool determineIndexed ()
 Walks back up the hierarchy, looking for an EggGroup at this level or above that has the "indexed" scalar set. More...
 
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. More...
 
 flattenTransforms ()
 Removes any transform and instance records from this node in the scene graph and below. More...
 
int getDepth ()
 Returns the number of nodes above this node in the egg hierarchy. More...
 
const LMatrix4d getNodeFrame ()
 Returns the coordinate frame of the node itself. More...
 
const LMatrix4d getNodeFrameInv ()
 Returns the inverse of the matrix returned by get_node_frame(). More...
 
const LMatrix4d getNodeFrameInvPtr ()
 Returns either a NULL pointer or a unique pointer shared by nodes with the same get_node_frame_inv() matrix. More...
 
const LMatrix4d getNodeFramePtr ()
 Returns either a NULL pointer or a unique pointer shared by nodes with the same get_node_frame() matrix. More...
 
const LMatrix4d getNodeToVertex ()
 Returns the transformation matrix suitable for converting vertices in the coordinate space of the node to the appropriate coordinate space for storing in the egg file. More...
 
const LMatrix4d getNodeToVertexPtr ()
 Returns either a NULL pointer or a unique pointer shared by nodes with the same get_node_to_vertex() matrix. More...
 
EggGroupNode getParent ()
 
const LMatrix4d getVertexFrame ()
 Returns the coordinate frame of the vertices referenced by primitives at or under this node. More...
 
const LMatrix4d getVertexFrameInv ()
 Returns the inverse of the matrix returned by get_vertex_frame(). More...
 
const LMatrix4d getVertexFrameInvPtr ()
 Returns either a NULL pointer or a unique pointer shared by nodes with the same get_vertex_frame_inv() matrix. More...
 
const LMatrix4d getVertexFramePtr ()
 Returns either a NULL pointer or a unique pointer shared by nodes with the same get_vertex_frame() matrix. More...
 
const LMatrix4d getVertexToNode ()
 Returns the transformation matrix suitable for converting the vertices as read from the egg file into the coordinate space of the node. More...
 
const LMatrix4d getVertexToNodePtr ()
 Returns either a NULL pointer or a unique pointer shared by nodes with the same get_vertex_to_node() matrix. More...
 
bool isAnimMatrix ()
 Returns true if this node represents a table of animation transformation data, false otherwise. More...
 
bool isJoint ()
 Returns true if this particular node represents a <Joint> entry or not. More...
 
bool isLocalCoord ()
 Returns true if this node's vertices are not in the global coordinate space. More...
 
bool isUnderInstance ()
 Returns true if there is an <Instance> node somewhere in the egg tree at or above this node, false otherwise. More...
 
bool isUnderTransform ()
 Returns true if there is a <Transform> entry somewhere in the egg tree at or above this node, false otherwise. More...
 
EggNode operator= (const EggNode copy)
 
bool parseEgg (str egg_syntax)
 Parses the egg syntax given in the indicate string as if it had been read from the egg file within this object's definition. More...
 
int renameNode (VectorString strip_prefix)
 Rename by stripping out the prefix. More...
 
 testUnderIntegrity ()
 
 transform (const LMatrix4d mat)
 Applies the indicated transformation to the node and all of its descendants. More...
 
 transformVerticesOnly (const LMatrix4d mat)
 Applies the indicated transformation only to vertices that appear in global space within vertex pools at this node and below. More...
 
 write (Ostream out, int indent_level)
 
- Public Member Functions inherited from EggNamedObject
 __init__ (const EggNamedObject copy)
 
 __init__ (str name)
 
EggNamedObject operator= (const EggNamedObject copy)
 
 output (Ostream out)
 
- Public Member Functions inherited from EggObject
 __init__ ()
 
 __init__ (const EggObject copy)
 
 clearUserData ()
 Removes all user data pointers from the node. More...
 
 clearUserData (TypeHandle type)
 Removes the user data pointer of the indicated type. More...
 
EggUserData getUserData ()
 Returns the user data pointer most recently stored on this object, or NULL if nothing was previously stored. More...
 
EggUserData getUserData (TypeHandle type)
 Returns the user data pointer of the indicated type, if it exists, or NULL if it does not. More...
 
bool hasUserData ()
 Returns true if a generic user data pointer has recently been set and not yet cleared, false otherwise. More...
 
bool hasUserData (TypeHandle type)
 Returns true if the user data pointer of the indicated type has been set, false otherwise. More...
 
EggObject operator= (const EggObject copy)
 
 setUserData (EggUserData user_data)
 Sets the user data associated with this object. More...
 
- Public Member Functions inherited from TypedObject
TypeHandle getType ()
 
int getTypeIndex ()
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. More...
 
bool isExactType (TypeHandle handle)
 Returns true if the current object is the indicated type exactly. More...
 
bool isOfType (TypeHandle handle)
 Returns true if the current object is or derives from the indicated type. More...
 
- Public Member Functions inherited from ReferenceCount
int getRefCount ()
 Returns the current reference count. More...
 
 ref ()
 Explicitly increments the reference count. More...
 
bool testRefCountIntegrity ()
 Does some easy checks to make sure that the reference count isn't completely bogus. More...
 
bool testRefCountNonzero ()
 Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More...
 
bool unref ()
 Explicitly decrements the reference count. More...
 
- Public Member Functions inherited from Namable
 __init__ (const Namable)
 
 __init__ (str initial_name)
 
 clearName ()
 Resets the Namable's name to empty. More...
 
str getName ()
 
bool hasName ()
 Returns true if the Namable has a nonempty name set, false if the name is empty. More...
 
 output (Ostream out)
 Outputs the Namable. More...
 
 setName (str name)
 

Static Public Member Functions

static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from EggNode
static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from EggNamedObject
static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from EggObject
static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from TypedReferenceCount
static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from TypedObject
static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from ReferenceCount
static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from Namable
static TypeHandle getClassType ()
 

Additional Inherited Members

- Public Attributes inherited from EggNode
int depth
 Returns the number of nodes above this node in the egg hierarchy. More...
 
EggGroupNode parent
 
- Public Attributes inherited from TypedObject
TypeHandle type
 Returns the TypeHandle representing this object's type. More...
 
- Public Attributes inherited from ReferenceCount
int ref_count
 The current reference count. More...
 
- Public Attributes inherited from Namable
const String name
 

Detailed Description

A collection of vertices.

There may be any number of vertex pools in a single egg structure. The vertices in a single pool need not necessarily have any connection to each other, but it is necessary that any one primitive (e.g. a polygon) must pull all its vertices from the same pool.

An EggVertexPool is an STL-style container of pointers to EggVertex's. Functions add_vertex() and remove_vertex() are provided to manipulate the list. The list may also be operated on (read-only) via iterators and begin()/end().

Member Function Documentation

◆ __init__() [1/2]

__init__ ( const EggVertexPool  copy)

Copying a vertex pool is of questionable value, since it will copy all of the vertices and assign new pointers to them all.

There will be no polygons referring to the new vertices.

◆ __init__() [2/2]

__init__ ( str  name)

◆ addUnusedVerticesToPrim()

addUnusedVerticesToPrim ( EggPrimitive  prim)

Adds all of the unused vertices in this vertex pool to the indicated primitive, in ascending order.

◆ addVertex()

EggVertex addVertex ( EggVertex  vertex,
int  index 
)

Adds the indicated vertex to the pool.

It is an error if the vertex is already a member of this or any other pool. The vertex must have been allocated from the free store; its pointer will now be owned by the vertex pool. If the index number is supplied, tries to assign that index number; it is an error if the index number is already in use.

It is possible that a forward reference to this vertex was requested in the past; if so, the data from the supplied vertex is copied onto the forward reference, which becomes the actual vertex. In this case, a different pointer is saved (and returned) than the one actually passed in. In the usual case, however, the vertex pointer passed in is the one that is saved in the vertex pool and returned from this method.

◆ createUniqueVertex()

EggVertex createUniqueVertex ( const EggVertex  copy)

Creates a new vertex in the pool that is a copy of the indicated one and returns it.

If there is already a vertex in the pool like the indicated one, simply returns that one.

◆ findMatchingVertex()

EggVertex findMatchingVertex ( const EggVertex  copy)

If the EggVertexPool already has a vertex matching the indicated vertex, returns it; otherwise, returns NULL.

This is similar to create_unique_vertex() except that a new vertex is never created.

◆ getAuxNames()

getAuxNames ( VectorString  aux_names)

Returns the list of auxiliary data names that are defined by any vertices in the pool.

◆ getClassType()

static TypeHandle getClassType ( )
static

◆ getForwardVertex()

EggVertex getForwardVertex ( int  index)

Returns the vertex in the pool with the indicated index number.

If there is not a vertex in the pool with the indicated index number, creates a special forward-reference EggVertex that has no data, on the assumption that the vertex pool has not yet been fully read and more data will be available later.

◆ getHighestIndex()

int getHighestIndex ( )

Returns the highest index number used by any vertex in the pool (except forward references).

Returns -1 if the pool is empty.

◆ getNumDimensions()

int getNumDimensions ( )

Returns the maximum number of dimensions used by any vertex in the pool.

◆ getUvNames()

getUvNames ( VectorString  uv_names,
VectorString  uvw_names,
VectorString  tbn_names 
)

Returns the list of UV names that are defined by any vertices in the pool, as well as the subset of UV names that actually define 3-d texture coordinates ("uvw_names").

Also returns the subset of UV/UVW names that define a tangent and binormal. It is the user's responsibility to clear both vectors before calling this method.

◆ getVertex()

EggVertex getVertex ( int  index)

Returns the vertex in the pool with the indicated index number, or NULL if no vertices have that index number.

◆ hasAux()

bool hasAux ( )

Returns true if any vertex in the pool has auxiliary data defined, false if none of them do.

◆ hasColors()

bool hasColors ( )

Returns true if any vertex in the pool has a color defined, false if none of them do.

◆ hasDefinedVertices()

bool hasDefinedVertices ( )

Returns true if any vertices in the pool are fully defined vertices, false if all vertices are forward references.

◆ hasForwardVertices()

bool hasForwardVertices ( )

Returns true if any vertices in the pool are undefined forward-reference vertices, false if all vertices are defined.

◆ hasNonwhiteColors()

bool hasNonwhiteColors ( )

Returns true if any vertex in the pool has a color defined other than white, false if no vertices have colors, or if all colors are white.

◆ hasNormals()

bool hasNormals ( )

Returns true if any vertex in the pool has a normal defined, false if none of them do.

◆ hasUvs()

bool hasUvs ( )

Returns true if any vertex in the pool has a uv defined, false if none of them do.

◆ hasVertex()

bool hasVertex ( int  index)

Returns true if the indicated vertex has been defined in the vertex pool, false otherwise.

This does not include forward references.

◆ makeNewVertex() [1/5]

EggVertex makeNewVertex ( )

Allocates and returns a new vertex from the pool.

This is one of three ways to add new vertices to a vertex pool.

◆ makeNewVertex() [2/5]

EggVertex makeNewVertex ( const LPoint2d  pos)

Allocates and returns a new vertex from the pool.

This is one of three ways to add new vertices to a vertex pool.

This flavor of make_new_vertex() explicitly sets the vertex position as it is allocated. It does not attempt to share vertices.

◆ makeNewVertex() [3/5]

EggVertex makeNewVertex ( const LPoint3d  pos)

Allocates and returns a new vertex from the pool.

This is one of three ways to add new vertices to a vertex pool.

This flavor of make_new_vertex() explicitly sets the vertex position as it is allocated. It does not attempt to share vertices.

◆ makeNewVertex() [4/5]

EggVertex makeNewVertex ( const LPoint4d  pos)

Allocates and returns a new vertex from the pool.

This is one of three ways to add new vertices to a vertex pool.

This flavor of make_new_vertex() explicitly sets the vertex position as it is allocated. It does not attempt to share vertices.

◆ makeNewVertex() [5/5]

EggVertex makeNewVertex ( double  pos)

Allocates and returns a new vertex from the pool.

This is one of three ways to add new vertices to a vertex pool.

This flavor of make_new_vertex() explicitly sets the vertex position as it is allocated. It does not attempt to share vertices.

◆ operator []()

EggVertex operator [] ( int  index)

Returns the vertex in the pool with the indicated index number, or NULL if no vertices have that index number.

◆ removeUnusedVertices()

int removeUnusedVertices ( )

Removes all vertices from the pool that are not referenced by at least one primitive.

Also collapses together equivalent vertices, and renumbers all vertices after the operation so their indices are consecutive, beginning at zero. Returns the number of vertices removed.

◆ removeVertex()

removeVertex ( EggVertex  vertex)

Removes the vertex from the pool.

It is an error if the vertex is not already a member of the pool.

◆ setHighestIndex()

setHighestIndex ( int  highest_index)

Artificially changes the "highest index number", so that a newly created vertex will begin at this number plus 1.

This can be used to default a vertex pool to start counting at 1 (or any other index number), instead of the default of 0. Use with caution.

◆ size()

EggVertexPool::SizeType size ( )

Returns the number of vertices in the pool.

◆ sortByExternalIndex()

sortByExternalIndex ( )

Re-orders (and re-numbers) the vertices in this vertex pool so that they appear in increasing order by the optional external_index that has been assigned to each vertex.

◆ transform()

transform ( const LMatrix4d  mat)

Applies the indicated transformation matrix to all the vertices.

However, vertices that are attached to primitives that believe their vertices are in a local coordinate system are transformed only by the scale and rotation component. If a vertex happens to be attached both to a local and a global primitive, and the transformation includes a translation component, the vertex will be split.