GeomPrimitive

Inheritance:

Methods of GeomPrimitive:

Methods of CopyOnWriteObject:

Methods of CachedTypedWritableReferenceCount:

Methods of TypedWritableReferenceCount:

Methods of TypedWritable:

Methods of TypedObject:

Methods of ReferenceCount:

Constants in GeomEnums:

addConsecutiveVertices
void GeomPrimitive::add_consecutive_vertices(int start, int num_vertices);

Description: Adds a consecutive sequence of vertices, beginning at start, to the primitive.
Don't call this in a downstream thread unless you don't mind it blowing away other changes you might have recently made in an upstream thread.

addNextVertices
void GeomPrimitive::add_next_vertices(int num_vertices);

Description: Adds the next n vertices in sequence, beginning from the last vertex added to the primitive + 1.
This is most useful when you are building up a primitive and a GeomVertexData at the same time, and you just want the primitive to reference the first n vertices from the data, then the next n, and so on.

addVertex
void GeomPrimitive::add_vertex(int vertex);

Description: Adds the indicated vertex to the list of vertex indices used by the graphics primitive type. To define a primitive, you must call add_vertex() for each vertex of the new primitive, and then call close_primitive() after you have specified the last vertex of each primitive.
Don't call this in a downstream thread unless you don't mind it blowing away other changes you might have recently made in an upstream thread.

addVertices
void GeomPrimitive::add_vertices(int v1, int v2);

Description: Adds several vertices in a row.

checkValid
bool GeomPrimitive::check_valid(GeomVertexData const *vertex_data) const;

Description: Verifies that the primitive only references vertices that actually exist within the indicated GeomVertexData. Returns true if the primitive appears to be valid, false otherwise.

clearVertices
void GeomPrimitive::clear_vertices(void);

Description: Removes all of the vertices and primitives from the object, so they can be re-added.
Don't call this in a downstream thread unless you don't mind it blowing away other changes you might have recently made in an upstream thread.

closePrimitive
bool GeomPrimitive::close_primitive(void);

Description: Indicates that the previous n calls to add_vertex(), since the last call to close_primitive(), have fully defined a new primitive. Returns true if successful, false otherwise.
Don't call this in a downstream thread unless you don't mind it blowing away other changes you might have recently made in an upstream thread.

decompose
ConstPointerTo< GeomPrimitive > GeomPrimitive::decompose(void) const;

Description: Decomposes a complex primitive type into a simpler primitive type, for instance triangle strips to triangles, and returns a pointer to the new primitive definition. If the decomposition cannot be performed, this might return the original object.
This method is useful for application code that wants to iterate through the set of triangles on the primitive without having to write handlers for each possible kind of primitive type.

doubleside
ConstPointerTo< GeomPrimitive > GeomPrimitive::doubleside(void) const;

Description: Duplicates triangles in the primitive so that each triangle is back-to-back with another triangle facing in the opposite direction. Note that this doesn't affect vertex normals, so this operation alone won't work in the presence of lighting (but see SceneGraphReducer::doubleside()).
Also see CullFaceAttrib, which can enable rendering of both sides of a triangle without having to duplicate it (but which doesn't necessarily work in the presence of lighting).

getClassType
static TypeHandle GeomPrimitive::get_class_type(void);

Undocumented function.

getDataSizeBytes
int GeomPrimitive::get_data_size_bytes(void) const;

Description: Returns the number of bytes stored in the vertices array.

getFirstVertex
int GeomPrimitive::get_first_vertex(void) const;

Description: Returns the first vertex number referenced by the primitive. This is particularly important in the case of a nonindexed primitive, in which case get_first_vertex() and get_num_vertices() completely define the extent of the vertex range.

getGeomRendering
virtual int GeomPrimitive::get_geom_rendering(void) const;

Description: Returns the set of GeomRendering bits that represent the rendering properties required to properly render this primitive.

getIndexType
GeomEnums::NumericType GeomPrimitive::get_index_type(void) const;

Description: Returns the numeric type of the index column. Normally, this will be either NT_uint16 or NT_uint32.

getMaxVertex
int GeomPrimitive::get_max_vertex(void) const;

Description: Returns the maximum vertex index number used by all the primitives in this object.

getMinVertex
int GeomPrimitive::get_min_vertex(void) const;

Description: Returns the minimum vertex index number used by all the primitives in this object.

getModified
UpdateSeq GeomPrimitive::get_modified(void) const;

Description: Returns a sequence number which is guaranteed to change at least every time the vertex index array is modified.

getNumBytes
int GeomPrimitive::get_num_bytes(void) const;

Description: Returns the number of bytes consumed by the primitive and its index table(s).

getNumFaces
int GeomPrimitive::get_num_faces(void) const;

Description: Returns the number of triangles or other fundamental type (such as line segments) represented by all the primitives in this object.

getNumPrimitives
int GeomPrimitive::get_num_primitives(void) const;

Description: Returns the number of individual primitives stored within this object. All primitives are the same type.

getNumVertices
int GeomPrimitive::get_num_vertices(void) const;

Description: Returns the number of vertex vertices used by all the primitives in this object.

getPrimitiveEnd
int GeomPrimitive::get_primitive_end(int n) const;

Description: Returns the element within the _vertices list at which the nth primitive ends. This is one past the last valid element for the nth primitive.

getPrimitiveMaxVertex
int GeomPrimitive::get_primitive_max_vertex(int n) const;

Description: Returns the maximum vertex index number used by the nth primitive in this object.

getPrimitiveMinVertex
int GeomPrimitive::get_primitive_min_vertex(int n) const;

Description: Returns the minimum vertex index number used by the nth primitive in this object.

getPrimitiveNumFaces
int GeomPrimitive::get_primitive_num_faces(int n) const;

Description: Returns the number of triangles or other fundamental type (such as line segments) represented by the nth primitive in this object.

getPrimitiveNumVertices
int GeomPrimitive::get_primitive_num_vertices(int n) const;

Description: Returns the number of vertices used by the nth primitive. This is the same thing as get_primitive_end(n) - get_primitive_start(n).

getPrimitiveStart
int GeomPrimitive::get_primitive_start(int n) const;

Description: Returns the element within the _vertices list at which the nth primitive starts.
If i is one more than the highest valid primitive vertex, the return value will be one more than the last valid vertex. Thus, it is generally true that the vertices used by a particular primitive i are the set get_primitive_start(n) <= vi < get_primitive_start(n + 1) (although this range also includes the unused vertices between primitives).

getPrimitiveType
virtual GeomEnums::PrimitiveType GeomPrimitive::get_primitive_type(void) const = 0;

Undocumented function.

getShadeModel
GeomEnums::ShadeModel GeomPrimitive::get_shade_model(void) const;

Description: Returns the ShadeModel hint for this primitive. This is intended as a hint to the renderer to tell it how the per-vertex colors and normals are applied.

getUsageHint
GeomEnums::UsageHint GeomPrimitive::get_usage_hint(void) const;

Description: Returns the usage hint for this primitive. See geomEnums.h. This has nothing to do with the usage hint associated with the primitive's vertices; this only specifies how often the vertex indices that define the primitive will be modified.
It is perfectly legal (and, in fact, common) for a GeomPrimitive to have UH_static on itself, while referencing vertex data with UH_dynamic. This means that the vertices themselves will be animated, but the primitive will always reference the same set of vertices from the pool.

getVertex
int GeomPrimitive::get_vertex(int i) const;

Description: Returns the ith vertex index in the table.

isComposite
bool GeomPrimitive::is_composite(void) const;

The following published methods are provided for safe, high-level iteration through the vertices and sub-primitives within the GeomPrimitive class. These work correctly regardless of the primitive type and without depending on knowledge about the way primitives' lengths are encoded. You can also safely build up a composite primitive using these methods.
Description: Returns true if the primitive is a composite primitive such as a tristrip or trifan, or false if it is a fundamental primitive such as a collection of triangles.

isIndexed
bool GeomPrimitive::is_indexed(void) const;

Description: Returns true if the primitive is indexed, false otherwise. An indexed primitive stores a table of index numbers into its GeomVertexData, so that it can reference the vertices in any order. A nonindexed primitive, on the other hand, stores only the first vertex number and number of vertices used, so that it can only reference the vertices consecutively.

makeCopy
virtual PointerTo< GeomPrimitive > GeomPrimitive::make_copy(void) const = 0;

Undocumented function.

makeIndexed
void GeomPrimitive::make_indexed(void);

Description: Converts the primitive from nonindexed form to indexed form. This will simply create an index table that is numbered consecutively from get_first_vertex(); it does not automatically collapse together identical vertices that may have been split apart by a previous call to make_nonindexed().
Don't call this in a downstream thread unless you don't mind it blowing away other changes you might have recently made in an upstream thread.

makeNonindexed
void GeomPrimitive::make_nonindexed(GeomVertexData *dest, GeomVertexData const *source);

Description: Converts the primitive from indexed to nonindexed by duplicating vertices as necessary into the indicated dest GeomVertexData.

matchShadeModel
ConstPointerTo< GeomPrimitive > GeomPrimitive::match_shade_model(GeomEnums::ShadeModel shade_model) const;

Description: Returns a new primitive that is compatible with the indicated shade model, if possible, or NULL if this is not possible.
In most cases, this will return either NULL or the original primitive. In the case of a SM_flat_first_vertex vs. a SM_flat_last_vertex (or vice-versa), however, it will return a rotated primitive.

offsetVertices
void GeomPrimitive::offset_vertices(int offset);

Description: Adds the indicated offset to all vertices used by the primitive.
Don't call this in a downstream thread unless you don't mind it blowing away other changes you might have recently made in an upstream thread.

operator =
void GeomPrimitive::operator =(GeomPrimitive const &copy);

Description: The copy assignment operator is not pipeline-safe. This will completely obliterate all stages of the pipeline, so don't do it for a GeomPrimitive that is actively being used for rendering.

operator delete
void GeomPrimitive::operator delete(void *ptr);

Undocumented function.

operator new
void *GeomPrimitive::operator new(unsigned int size);

Undocumented function.

output
virtual void GeomPrimitive::output(ostream &out) const;

Description:

packVertices
void GeomPrimitive::pack_vertices(GeomVertexData *dest, GeomVertexData const *source);

Description: Packs the vertices used by the primitive from the indicated source array onto the end of the indicated destination array.

requestResident
bool GeomPrimitive::request_resident(void) const;

Description: Returns true if the primitive data is currently resident in memory. If this returns false, the primitive data will be brought back into memory shortly; try again later.

reverse
ConstPointerTo< GeomPrimitive > GeomPrimitive::reverse(void) const;

Description: Reverses the winding order in the primitive so that each triangle is facing in the opposite direction it was originally. Note that this doesn't affect vertex normals, so this operation alone won't work in the presence of lighting (but see SceneGraphReducer::reverse()).
Also see CullFaceAttrib, which can change the visible direction of a triangle without having to duplicate it (but which doesn't necessarily work in the presence of lighting).

rotate
ConstPointerTo< GeomPrimitive > GeomPrimitive::rotate(void) const;

Description: Returns a new primitive with the shade_model reversed (if it is flat shaded), if possible. If the primitive type cannot be rotated, returns the original primitive, unrotated.
If the current shade_model indicates flat_vertex_last, this should bring the last vertex to the first position; if it indicates flat_vertex_first, this should bring the first vertex to the last position.

setIndexType
void GeomPrimitive::set_index_type(GeomEnums::NumericType index_type);

Description: Changes the numeric type of the index column. Normally, this should be either NT_uint16 or NT_uint32.
The index type must be large enough to include all of the index values in the primitive. It may be automatically elevated, if necessary, to a larger index type, by a subsequent call to add_index() that names an index value that does not fit in the index type you specify.
Don't call this in a downstream thread unless you don't mind it blowing away other changes you might have recently made in an upstream thread.

setShadeModel
void GeomPrimitive::set_shade_model(GeomEnums::ShadeModel shade_model);

Description: Changes the ShadeModel hint for this primitive. This is different from the ShadeModelAttrib that might also be applied from the scene graph. This does not affect the shade model that is in effect when rendering, but rather serves as a hint to the renderer to tell it how the per-vertex colors and normals on this primitive are applied.
Don't call this in a downstream thread unless you don't mind it blowing away other changes you might have recently made in an upstream thread.

setUsageHint
void GeomPrimitive::set_usage_hint(GeomEnums::UsageHint usage_hint);

Description: Changes the UsageHint hint for this primitive. See get_usage_hint().
Don't call this in a downstream thread unless you don't mind it blowing away other changes you might have recently made in an upstream thread.

validatePtr
static bool GeomPrimitive::validate_ptr(void const *ptr);

Undocumented function.

write
virtual void GeomPrimitive::write(ostream &out, int indent_level) const;

Description:

getClassType
static TypeHandle CopyOnWriteObject::get_class_type(void);

Undocumented function.

cacheRef
void CachedTypedWritableReferenceCount::cache_ref(void) const;

Description: Explicitly increments the cache reference count and the normal reference count simultaneously.

cacheUnref
bool CachedTypedWritableReferenceCount::cache_unref(void) const;

Description: Explicitly decrements the cache reference count and the normal reference count simultaneously.
The return value is true if the new reference count is nonzero, false if it is zero.

getCacheRefCount
int CachedTypedWritableReferenceCount::get_cache_ref_count(void) const;

Description: Returns the current reference count.

getClassType
static TypeHandle CachedTypedWritableReferenceCount::get_class_type(void);

Undocumented function.

testRefCountIntegrity
bool CachedTypedWritableReferenceCount::test_ref_count_integrity(void) const;

Description: Does some easy checks to make sure that the reference count isn't completely bogus.

getClassType
static TypeHandle TypedWritableReferenceCount::get_class_type(void);

Undocumented function.

getClassType
static TypeHandle TypedWritable::get_class_type(void);

Undocumented function.

getClassType
static TypeHandle TypedObject::get_class_type(void);

Undocumented function.

getType
virtual TypeHandle TypedObject::get_type(void) const = 0;

Derived classes should override this function to return get_class_type().

getTypeIndex
int TypedObject::get_type_index(void) const;

Description: 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().

isExactType
bool TypedObject::is_exact_type(TypeHandle handle) const;

Description: Returns true if the current object is the indicated type exactly.

isOfType
bool TypedObject::is_of_type(TypeHandle handle) const;

Description: Returns true if the current object is or derives from the indicated type.

getClassType
static TypeHandle ReferenceCount::get_class_type(void);

Undocumented function.

getRefCount
int ReferenceCount::get_ref_count(void) const;

Description: Returns the current reference count.

ref
void ReferenceCount::ref(void) const;

Description: 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.
This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it.

testRefCountIntegrity
bool ReferenceCount::test_ref_count_integrity(void) const;

Description: Does some easy checks to make sure that the reference count isn't completely bogus. Returns true if ok, false otherwise.

testRefCountNonzero
bool ReferenceCount::test_ref_count_nonzero(void) const;

Description: Does some easy checks to make sure that the reference count isn't zero, or completely bogus. Returns true if ok, false otherwise.

unref
bool ReferenceCount::unref(void) const;

Description: 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; plus, we don't have a virtual destructor anyway.) However, see the helper function unref_delete().
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.
This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it.
The return value is true if the new reference count is nonzero, false if it is zero.