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

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

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

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. There will be no polygons referring to the new vertices. 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. 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. More...
 
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. More...
 
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. 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. 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. More...
 
int getHighestIndex ()
 Returns the highest index number used by any vertex in the pool (except forward references). Returns -1 if the pool is empty. 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"). 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. 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. This does not include forward references. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. 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. 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. More...
 
 removeVertex (EggVertex vertex)
 Removes the vertex from the pool. It is an error if the vertex is not already a member of 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. 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. 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. 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. 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. Returns a valid EggRenderMode pointer if one is found, or NULL otherwise. 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. Returns a valid EggRenderMode pointer if one is found, or NULL otherwise. More...
 
bool determineDecal ()
 Walks back up the hierarchy, looking for an EggGroup at this level or above that has the "decal" flag set. Returns the value of the decal flag if it is found, or false if it is not. 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. Returns a valid EggRenderMode pointer if one is found, or NULL otherwise. 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. Returns a valid EggRenderMode pointer if one is found, or NULL otherwise. 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. Returns a valid EggRenderMode pointer if one is found, or NULL otherwise. 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. Returns a valid EggRenderMode pointer if one is found, or NULL otherwise. More...
 
bool determineIndexed ()
 Walks back up the hierarchy, looking for an EggGroup at this level or above that has the "indexed" scalar set. Returns the value of the indexed scalar if it is found, or false if it is not. 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. Returns a valid EggRenderMode pointer if one is found, or NULL otherwise. More...
 
 flattenTransforms ()
 Removes any transform and instance records from this node in the scene graph and below. If an instance node is encountered, removes the instance and applies the transform to its vertices, duplicating vertices if necessary. 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. This is simply the net product of all transformations up to the root. More...
 
const LMatrix4d getNodeFrameInv ()
 Returns the inverse of the matrix returned by get_node_frame(). See 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. This is the same thing as: 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. This is not the same as get_node_frame(). More...
 
const LMatrix4d getVertexFrameInv ()
 Returns the inverse of the matrix returned by get_vertex_frame(). See 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. This is the same thing as: 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. This is a handy thing to know since Joints are sorted to the end of their sibling list when writing an egg file. See EggGroupNode::write(). More...
 
bool isLocalCoord ()
 Returns true if this node's vertices are not in the global coordinate space. This will be the case if there was an <Instance> node under a transform at or above this node. 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. Updates the object accordingly. Returns true if successful, false if there was some parse error or if the object does not support this functionality. 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. Joints and other transforms are not affected, nor are local vertices. 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. This may be any EggUserData-derived object. The egg library will do nothing with this pointer, except to hold its reference count and return the pointer on request. More...
 
- Public Member Functions inherited from TypedObject
TypeHandle getType ()
 Derived classes should override this function to return get_class_type(). More...
 
int getTypeIndex ()
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. This is equivalent to get_type().get_index(). 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. User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically. More...
 
bool testRefCountIntegrity ()
 Does some easy checks to make sure that the reference count isn't completely bogus. Returns true if ok, false otherwise. More...
 
bool testRefCountNonzero ()
 Does some easy checks to make sure that the reference count isn't zero, or completely bogus. Returns true if ok, false otherwise. More...
 
bool unref ()
 Explicitly decrements the reference count. Note that the object will not be implicitly deleted by unref() simply because the reference count drops to zero. (Having a member function delete itself is problematic.) However, see the helper function unref_delete(). More...
 
- Public Member Functions inherited from Namable
 __init__ (const Namable copy)
 
 __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...
 
Namable operator= (const Namable other)
 
 output (Ostream out)
 Outputs the Namable. This function simply writes the name to the output stream; most Namable derivatives will probably redefine this. 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 ()
 

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.