Panda3D
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Friends

EggVertex Class Reference

Any one-, two-, three-, or four-component vertex, possibly with attributes such as a normal. More...

#include "eggVertex.h"

Inheritance diagram for EggVertex:
EggObject EggAttributes TypedReferenceCount TypedObject ReferenceCount MemoryBase MemoryBase

List of all members.

Public Types

typedef uv_iterator const_uv_iterator
typedef pset< EggGroup * > GroupRef
typedef pmultiset< EggPrimitive * > PrimitiveRef
typedef
second_of_pair_iterator
< UVMap::const_iterator > 
uv_iterator
typedef UVMap::size_type uv_size_type
typedef pmap< string, PT(EggVertexUV) > UVMap

Public Member Functions

 EggVertex (const EggVertex &copy)
 Copies all properties of the vertex except its vertex pool, index number, and group membership.
void clear_grefs ()
 Removes all group references from the vertex, so that it is not assigned to any group.
void clear_uv ()
 Removes all UV coordinate pairs from the vertex.
void clear_uv (const string &name)
 Removes the named UV coordinate pair from the vertex, along with any UV morphs.
int compare_to (const EggVertex &other) const
 An ordering operator to compare two vertices for sorting order.
void copy_grefs_from (const EggVertex &other)
 Copies all the group references from the other vertex onto this one.
virtual TypeHandle force_init_type ()
int get_external_index () const
 Returns the number set by set_external_index().
int get_index () const
 Returns the index number of the vertex within its pool.
int get_num_dimensions () const
 Returns the number of dimensions the vertex uses.
int get_num_global_coord () const
 Returns the number of primitives that own this vertex whose vertices are interpreted in the global coordinate system.
int get_num_local_coord () const
 Returns the number of primitives that own this vertex whose vertices are interpreted to be in a local coordinate system.
EggVertexPoolget_pool () const
 Returns the vertex pool this vertex belongs in.
double get_pos1 () const
 Only valid if get_num_dimensions() returns 1.
LPoint2d get_pos2 () const
 Only valid if get_num_dimensions() returns 2.
Vertexd get_pos3 () const
 Valid if get_num_dimensions() returns 3 or 4.
LPoint4d get_pos4 () const
 This is always valid, regardless of the value of get_num_dimensions.
virtual TypeHandle get_type () const
TexCoordd get_uv () const
 Returns the unnamed UV coordinate pair on the vertex.
TexCoordd get_uv (const string &name) const
 Returns the named UV coordinate pair on the vertex.
const EggVertexUVget_uv_obj (const string &name) const
 Returns the named EggVertexUV object, which defines both the UV coordinate pair for this name and the UV morphs.
const TexCoord3dget_uvw (const string &name) const
 Returns the named UV coordinate triple on the vertex.
GroupRef::const_iterator gref_begin () const
 Returns an iterator that can, in conjunction with gref_end(), be used to traverse the entire set of groups that reference this vertex.
GroupRef::const_iterator gref_end () const
 Returns an iterator that can, in conjunction with gref_begin(), be used to traverse the entire set of groups that reference this vertex.
GroupRef::size_type gref_size () const
 Returns the number of elements between gref_begin() and gref_end().
bool has_gref (const EggGroup *group) const
 Returns true if the indicated group references this vertex, false otherwise.
int has_pref (const EggPrimitive *prim) const
 Returns the number of times the vertex appears in the indicated primitive, or 0 if it does not appear.
bool has_uv () const
 Returns true if the vertex has an unnamed UV coordinate pair, false otherwise.
bool has_uv (const string &name) const
 Returns true if the vertex has the named UV coordinate pair, and the named UV coordinate pair is 2-d, false otherwise.
bool has_uvw (const string &name) const
 Returns true if the vertex has the named UV coordinate triple, and the named UV coordinate triple is 3-d, false otherwise.
bool is_forward_reference () const
 Returns true if the vertex is a forward reference to some vertex that hasn't been defined yet.
EggVertexUVmodify_uv_obj (const string &name)
 Returns a modifiable pointer to the named EggVertexUV object, which defines both the UV coordinate pair for this name and the UV morphs.
EggVertexoperator= (const EggVertex &copy)
 Copies all properties of the vertex except its vertex pool, index number, and group membership.
void output (ostream &out) const
PrimitiveRef::const_iterator pref_begin () const
 Returns an iterator that can, in conjunction with pref_end(), be used to traverse the entire set of primitives that reference this vertex.
PrimitiveRef::const_iterator pref_end () const
 Returns an iterator that can, in conjunction with pref_begin(), be used to traverse the entire set of primitives that reference this vertex.
PrimitiveRef::size_type pref_size () const
 Returns the number of elements between pref_begin() and pref_end().
void set_external_index (int external_index)
 Sets a special index number that is associated with the EggVertex (but is not written to the egg file).
void set_pos (const LPoint2d &pos)
 Sets the vertex position.
void set_pos (const LPoint3d &pos)
 Sets the vertex position.
void set_pos (const LPoint4d &pos)
 Sets the vertex position.
void set_pos (double pos)
 Sets the vertex position.
void set_pos4 (const LPoint4d &pos)
 This special flavor of set_pos() sets the vertex as a four-component value, but does not change the set number of dimensions.
void set_uv (const TexCoordd &texCoord)
 Replaces the unnamed UV coordinate pair on the vertex with the indicated value.
void set_uv (const string &name, const TexCoordd &texCoord)
 Sets the indicated UV coordinate pair on the vertex.
void set_uv_obj (EggVertexUV *vertex_uv)
 Sets the indicated EggVertexUV on the vertex.
void set_uvw (const string &name, const TexCoord3d &texCoord)
 Sets the indicated UV coordinate triple on the vertex.
bool sorts_less_than (const EggVertex &other) const
 An ordering operator to compare two vertices for sorting order.
void test_gref_integrity () const
 Verifies that the gref list is correct and that all the groups included actually exist and do reference the vertex.
void test_pref_integrity () const
 Verifies that the pref list is correct and that all the primitives included actually exist and do reference the vertex.
void transform (const LMatrix4d &mat)
 Applies the indicated transformation matrix to the vertex.
const_uv_iterator uv_begin () const
 Returns an iterator that allows walking through the complete set of named UV's on the vertex.
const_uv_iterator uv_end () const
 Returns an iterator that allows walking through the complete set of named UV's on the vertex.
uv_size_type uv_size () const
 Returns the number of named UV's on the vertex.
void write (ostream &out, int indent_level) const
 Writes the vertex to the indicated output stream in Egg format.

Static Public Member Functions

static TypeHandle get_class_type ()
static void init_type ()

Public Attributes

EggMorphVertexList _dxyzs

Friends

class EggGroup
class EggPrimitive
class EggVertexPool

Detailed Description

Any one-, two-, three-, or four-component vertex, possibly with attributes such as a normal.

Definition at line 40 of file eggVertex.h.


Constructor & Destructor Documentation

EggVertex::EggVertex ( const EggVertex copy)

Copies all properties of the vertex except its vertex pool, index number, and group membership.

Definition at line 56 of file eggVertex.cxx.

References test_gref_integrity(), and test_pref_integrity().


Member Function Documentation

void EggVertex::clear_grefs ( )

Removes all group references from the vertex, so that it is not assigned to any group.

Definition at line 603 of file eggVertex.cxx.

References EggGroup::unref_vertex().

Referenced by copy_grefs_from(), and EggVertexPool::remove_unused_vertices().

void EggVertex::clear_uv ( ) [inline]

Removes all UV coordinate pairs from the vertex.

Definition at line 238 of file eggVertex.I.

void EggVertex::clear_uv ( const string &  name)

Removes the named UV coordinate pair from the vertex, along with any UV morphs.

Definition at line 279 of file eggVertex.cxx.

References EggVertexUV::filter_name().

int EggVertex::compare_to ( const EggVertex other) const

An ordering operator to compare two vertices for sorting order.

This imposes an arbitrary ordering useful to identify unique vertices.

Group membership is not considered in this comparison. This is somewhat problematic, but cannot easily be helped, because considering group membership would make it difficult to add and remove groups from vertices. It also makes it impossible to meaningfully compare with a concrete EggVertex object (which cannot have group memberships).

However, this is not altogether bad, because two vertices that are identical in all other properties should generally also be identical in group memberships, else the vertices will tend to fly apart when the joints animate.

Definition at line 385 of file eggVertex.cxx.

References EggMorphList< MorphType >::compare_to(), and LVecBase4d::compare_to().

Referenced by sorts_less_than().

void EggVertex::copy_grefs_from ( const EggVertex other)

Copies all the group references from the other vertex onto this one.

This assigns the current vertex to exactly the same groups, with exactly the same memberships, as the given one.

Warning: only an EggVertex allocated from the free store may have groups assigned to it. Do not attempt to call this on a temporary concrete EggVertex object; a core dump will certainly result.

Definition at line 576 of file eggVertex.cxx.

References clear_grefs(), EggGroup::get_vertex_membership(), gref_begin(), gref_end(), EggGroup::ref_vertex(), and test_gref_integrity().

Referenced by EggPrimitive::do_apply_flat_attribute(), EggPrimitive::r_apply_texmats(), EggPrimitive::r_flatten_transforms(), EggGroupNode::rebuild_vertex_pools(), EggGroupNode::recompute_polygon_normals(), EggGroupNode::strip_normals(), EggPrimitive::unify_attributes(), and EggCompositePrimitive::unify_attributes().

int EggVertex::get_external_index ( ) const [inline]

Returns the number set by set_external_index().

See set_external_index().

Definition at line 317 of file eggVertex.I.

Referenced by XFileMesh::create_polygons(), and SoftToEggConverter::FindClosestTriVert().

int EggVertex::get_index ( ) const [inline]

Returns the index number of the vertex within its pool.

Definition at line 287 of file eggVertex.I.

Referenced by EggVertexPool::EggVertexPool(), EggPrimitive::write_body(), and EggGroup::write_vertex_ref().

int EggVertex::get_num_dimensions ( ) const [inline]

Returns the number of dimensions the vertex uses.

Usually this will be 3, but it may be 1, 2, 3, or 4.

Definition at line 122 of file eggVertex.I.

Referenced by EggVertexPool::get_num_dimensions().

int EggVertex::get_num_global_coord ( ) const

Returns the number of primitives that own this vertex whose vertices are interpreted in the global coordinate system.

Definition at line 462 of file eggVertex.cxx.

References EggNode::is_local_coord(), pref_begin(), pref_end(), and test_pref_integrity().

Referenced by EggVertexPool::transform().

int EggVertex::get_num_local_coord ( ) const

Returns the number of primitives that own this vertex whose vertices are interpreted to be in a local coordinate system.

Definition at line 441 of file eggVertex.cxx.

References EggNode::is_local_coord(), pref_begin(), pref_end(), and test_pref_integrity().

Referenced by EggVertexPool::transform().

EggVertexPool * EggVertex::get_pool ( ) const [inline]
double EggVertex::get_pos1 ( ) const [inline]

Only valid if get_num_dimensions() returns 1.

Returns the position as a one-dimensional value.

Definition at line 134 of file eggVertex.I.

LPoint2d EggVertex::get_pos2 ( ) const [inline]

Only valid if get_num_dimensions() returns 2.

Returns the position as a two-dimensional value.

Definition at line 147 of file eggVertex.I.

Vertexd EggVertex::get_pos3 ( ) const [inline]
LPoint4d EggVertex::get_pos4 ( ) const [inline]

This is always valid, regardless of the value of get_num_dimensions.

It returns the position as a four-dimensional value. If the pos has fewer than four dimensions, this value represents the pos extended into four-dimensional homogenous space, e.g. by adding 1 as the fourth component.

Definition at line 178 of file eggVertex.I.

TexCoordd EggVertex::get_uv ( const string &  name) const

Returns the named UV coordinate pair on the vertex.

vertex. It is an error to call this if has_uv(name) returned false.

Definition at line 154 of file eggVertex.cxx.

References EggVertexUV::filter_name(), and LPoint2d::zero().

TexCoordd EggVertex::get_uv ( ) const [inline]

Returns the unnamed UV coordinate pair on the vertex.

It is an error to call this if has_uv() has returned false.

This is the more restrictive interface, and is generally useful only in the absence of multitexturing; see get_uv(name) for the interface that supports multitexturing.

Definition at line 211 of file eggVertex.I.

References has_uv(), and LPoint2d::zero().

Referenced by XFileVertex::set_from_egg(), and set_uv().

const EggVertexUV * EggVertex::get_uv_obj ( const string &  name) const

Returns the named EggVertexUV object, which defines both the UV coordinate pair for this name and the UV morphs.

This object might be shared between multiple vertices. You should not attempt to modify this object; instead, call modify_uv_object to return a modifiable pointer.

Definition at line 230 of file eggVertex.cxx.

References EggVertexUV::filter_name().

Referenced by EggPrimitive::r_apply_texmats().

const TexCoord3d & EggVertex::get_uvw ( const string &  name) const

Returns the named UV coordinate triple on the vertex.

vertex. It is an error to call this if has_uvw(name) returned false.

Definition at line 168 of file eggVertex.cxx.

References EggVertexUV::filter_name(), and LPoint3d::zero().

Referenced by set_uvw().

EggVertex::GroupRef::const_iterator EggVertex::gref_begin ( ) const

Returns an iterator that can, in conjunction with gref_end(), be used to traverse the entire set of groups that reference this vertex.

Each iterator returns a pointer to a group.

This interface is not safe to use outside of PANDAEGG.DLL.

Definition at line 517 of file eggVertex.cxx.

Referenced by copy_grefs_from(), and test_gref_integrity().

EggVertex::GroupRef::const_iterator EggVertex::gref_end ( ) const

Returns an iterator that can, in conjunction with gref_begin(), be used to traverse the entire set of groups that reference this vertex.

Each iterator returns a pointer to a group.

This interface is not safe to use outside of PANDAEGG.DLL.

Definition at line 533 of file eggVertex.cxx.

Referenced by copy_grefs_from(), and test_gref_integrity().

EggVertex::GroupRef::size_type EggVertex::gref_size ( ) const

Returns the number of elements between gref_begin() and gref_end().

This interface is not safe to use outside of PANDAEGG.DLL.

Definition at line 547 of file eggVertex.cxx.

bool EggVertex::has_gref ( const EggGroup group) const

Returns true if the indicated group references this vertex, false otherwise.

Definition at line 558 of file eggVertex.cxx.

Referenced by EggGroup::test_vref_integrity().

int EggVertex::has_pref ( const EggPrimitive prim) const

Returns the number of times the vertex appears in the indicated primitive, or 0 if it does not appear.

Definition at line 669 of file eggVertex.cxx.

Referenced by EggPrimitive::test_vref_integrity().

bool EggVertex::has_uv ( const string &  name) const

Returns true if the vertex has the named UV coordinate pair, and the named UV coordinate pair is 2-d, false otherwise.

Definition at line 120 of file eggVertex.cxx.

References EggVertexUV::filter_name(), and EggVertexUV::has_w().

bool EggVertex::has_uv ( ) const [inline]

Returns true if the vertex has an unnamed UV coordinate pair, false otherwise.

This is the more restrictive interface, and is generally useful only in the absence of multitexturing; see has_uv(name) for the interface that supports multitexturing.

Definition at line 194 of file eggVertex.I.

Referenced by get_uv(), EggVertexPool::has_uvs(), and XFileVertex::set_from_egg().

bool EggVertex::has_uvw ( const string &  name) const

Returns true if the vertex has the named UV coordinate triple, and the named UV coordinate triple is 3-d, false otherwise.

Definition at line 137 of file eggVertex.cxx.

References EggVertexUV::filter_name(), and EggVertexUV::has_w().

bool EggVertex::is_forward_reference ( ) const [inline]

Returns true if the vertex is a forward reference to some vertex that hasn't been defined yet.

In this case, the vertex may not have any properties filled in yet.

This can only happen if you implicitly create a vertex via EggVertexPool::get_forward_vertex(). Presumably, when the vertex pool is later filled in, this vertex will be replaced with real data.

Definition at line 43 of file eggVertex.I.

Referenced by EggVertexPool::add_vertex(), EggVertexPool::get_vertex(), EggVertexPool::has_defined_vertices(), and EggVertexPool::has_forward_vertices().

EggVertexUV * EggVertex::modify_uv_obj ( const string &  name)

Returns a modifiable pointer to the named EggVertexUV object, which defines both the UV coordinate pair for this name and the UV morphs.

Returns NULL if there is no such named UV object.

Definition at line 247 of file eggVertex.cxx.

References EggVertexUV::filter_name().

EggVertex & EggVertex::operator= ( const EggVertex copy)

Copies all properties of the vertex except its vertex pool, index number, and group membership.

Definition at line 79 of file eggVertex.cxx.

References test_gref_integrity(), and test_pref_integrity().

EggVertex::PrimitiveRef::const_iterator EggVertex::pref_begin ( ) const

Returns an iterator that can, in conjunction with pref_end(), be used to traverse the entire set of primitives that reference this vertex.

Each iterator returns a pointer to a primitive.

This interface is not safe to use outside of PANDAEGG.DLL.

Definition at line 628 of file eggVertex.cxx.

Referenced by get_num_global_coord(), get_num_local_coord(), and test_pref_integrity().

EggVertex::PrimitiveRef::const_iterator EggVertex::pref_end ( ) const

Returns an iterator that can, in conjunction with pref_begin(), be used to traverse the entire set of primitives that reference this vertex.

Each iterator returns a pointer to a primitive.

This interface is not safe to use outside of PANDAEGG.DLL.

Definition at line 644 of file eggVertex.cxx.

Referenced by get_num_global_coord(), get_num_local_coord(), and test_pref_integrity().

EggVertex::GroupRef::size_type EggVertex::pref_size ( ) const

Returns the number of elements between pref_begin() and pref_end().

This interface is not safe to use outside of PANDAEGG.DLL.

Definition at line 658 of file eggVertex.cxx.

Referenced by EggVertexPool::remove_unused_vertices().

void EggVertex::set_external_index ( int  external_index) [inline]

Sets a special index number that is associated with the EggVertex (but is not written to the egg file).

This number is not interpreted by any egg code; it is simply maintained along with the vertex. It *is* used to differentiate otherwise identical vertices in EggVertexPool::create_unique_vertex(), however.

The intention of this number is as an aid for file converters, to associate an EggVertex back to the index number of the original source vertex.

Definition at line 306 of file eggVertex.I.

Referenced by XFileMesh::create_polygons().

void EggVertex::set_pos ( const LPoint3d pos) [inline]

Sets the vertex position.

This variant sets the vertex to a three-dimensional value.

Definition at line 80 of file eggVertex.I.

void EggVertex::set_pos ( double  pos) [inline]

Sets the vertex position.

This variant sets the vertex to a one-dimensional value.

Definition at line 54 of file eggVertex.I.

Referenced by DXFToEggLayer::add_vertex(), XFileMesh::create_polygons(), and EggVertexPool::make_new_vertex().

void EggVertex::set_pos ( const LPoint4d pos) [inline]

Sets the vertex position.

This variant sets the vertex to a four-dimensional value.

Definition at line 93 of file eggVertex.I.

void EggVertex::set_pos ( const LPoint2d pos) [inline]

Sets the vertex position.

This variant sets the vertex to a two-dimensional value.

Definition at line 67 of file eggVertex.I.

void EggVertex::set_pos4 ( const LPoint4d pos) [inline]

This special flavor of set_pos() sets the vertex as a four-component value, but does not change the set number of dimensions.

It's handy for retrieving the vertex position via get_pos4, manipulating it, then storing it back again, without worrying about the number of dimensions it actually had.

Definition at line 110 of file eggVertex.I.

void EggVertex::set_uv ( const string &  name,
const TexCoordd uv 
)

Sets the indicated UV coordinate pair on the vertex.

This replaces any UV coordinate pair with the same name already on the vertex, but preserves UV morphs.

Definition at line 182 of file eggVertex.cxx.

References EggVertexUV::filter_name(), and get_uv().

void EggVertex::set_uv ( const TexCoordd uv) [inline]

Replaces the unnamed UV coordinate pair on the vertex with the indicated value.

This is the more restrictive interface, and is generally useful only in the absence of multitexturing; see set_uv(name, uv) for the interface that supports multitexturing.

Definition at line 228 of file eggVertex.I.

Referenced by XFileMesh::create_polygons().

void EggVertex::set_uv_obj ( EggVertexUV uv)

Sets the indicated EggVertexUV on the vertex.

This replaces any UV coordinate pair with the same name already on the vertex, including UV morphs.

Definition at line 268 of file eggVertex.cxx.

Referenced by EggPrimitive::r_apply_texmats().

void EggVertex::set_uvw ( const string &  name,
const TexCoord3d uvw 
)

Sets the indicated UV coordinate triple on the vertex.

This replaces any UV coordinate pair or triple with the same name already on the vertex, but preserves UV morphs.

Definition at line 205 of file eggVertex.cxx.

References EggVertexUV::filter_name(), and get_uvw().

bool EggVertex::sorts_less_than ( const EggVertex other) const [inline]

An ordering operator to compare two vertices for sorting order.

This imposes an arbitrary ordering useful to identify unique vertices.

Definition at line 329 of file eggVertex.I.

References compare_to().

void EggVertex::test_gref_integrity ( ) const

Verifies that the gref list is correct and that all the groups included actually exist and do reference the vertex.

Definition at line 683 of file eggVertex.cxx.

References EggGroup::get_vertex_membership(), gref_begin(), gref_end(), and ReferenceCount::test_ref_count_integrity().

Referenced by copy_grefs_from(), EggVertex(), operator=(), and write().

void EggVertex::test_pref_integrity ( ) const

Verifies that the pref list is correct and that all the primitives included actually exist and do reference the vertex.

Definition at line 706 of file eggVertex.cxx.

References pref_begin(), pref_end(), and ReferenceCount::test_ref_count_integrity().

Referenced by EggPrimitive::add_vertex(), EggVertex(), get_num_global_coord(), get_num_local_coord(), operator=(), EggVertexPool::remove_unused_vertices(), EggPrimitive::remove_vertex(), EggPrimitive::replace(), write(), and EggPrimitive::write_body().

void EggVertex::transform ( const LMatrix4d mat)

Applies the indicated transformation matrix to the vertex.

Reimplemented from EggAttributes.

Definition at line 483 of file eggVertex.cxx.

Referenced by XFileMesh::create_polygons(), EggPrimitive::r_flatten_transforms(), and EggVertexPool::transform().

EggVertex::const_uv_iterator EggVertex::uv_begin ( ) const [inline]

Returns an iterator that allows walking through the complete set of named UV's on the vertex.

This interface is not safe to use outside of PANDAEGG.DLL.

Definition at line 252 of file eggVertex.I.

Referenced by EggVertexPool::get_uv_names().

EggVertex::const_uv_iterator EggVertex::uv_end ( ) const [inline]

Returns an iterator that allows walking through the complete set of named UV's on the vertex.

This interface is not safe to use outside of PANDAEGG.DLL.

Definition at line 266 of file eggVertex.I.

Referenced by EggVertexPool::get_uv_names().

EggVertex::uv_size_type EggVertex::uv_size ( ) const [inline]

Returns the number of named UV's on the vertex.

Definition at line 276 of file eggVertex.I.

void EggVertex::write ( ostream &  out,
int  indent_level 
) const

Writes the vertex to the indicated output stream in Egg format.

Reimplemented from EggAttributes.

Definition at line 318 of file eggVertex.cxx.

References test_gref_integrity(), and test_pref_integrity().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations