|
|
|
This is an abstract base class for a family of classes that represent the fundamental geometry primitives that may be stored in a Geom.
More...
#include "geomPrimitive.h"
List of all members.
Classes |
| class | CData |
Public Member Functions |
|
| GeomPrimitive (UsageHint usage_hint) |
|
| GeomPrimitive (const GeomPrimitive ©) |
| void | add_consecutive_vertices (int start, int num_vertices) |
| | Adds a consecutive sequence of vertices, beginning at start, to the primitive.
|
| void | add_next_vertices (int num_vertices) |
| | Adds the next n vertices in sequence, beginning from the last vertex added to the primitive + 1.
|
| void | add_vertex (int vertex) |
| | Adds the indicated vertex to the list of vertex indices used by the graphics primitive type.
|
| void | add_vertices (int v1, int v2) |
| | Adds several vertices in a row.
|
| void | add_vertices (int v1, int v2, int v3) |
| | Adds several vertices in a row.
|
| void | add_vertices (int v1, int v2, int v3, int v4) |
| | Adds several vertices in a row.
|
| void | calc_tight_bounds (LPoint3 &min_point, LPoint3 &max_point, bool &found_any, const GeomVertexData *vertex_data, bool got_mat, const LMatrix4 &mat, const InternalName *column_name, Thread *current_thread) const |
| | Expands min_point and max_point to include all of the vertices in the Geom, if any (or the data of any point type, for instance, texture coordinates--based on the column name).
|
| bool | check_valid (const GeomVertexData *vertex_data) const |
| | Verifies that the primitive only references vertices that actually exist within the indicated GeomVertexData.
|
| void | clear_minmax () |
| | Undoes a previous call to set_minmax(), and allows the minimum and maximum values to be recomputed normally.
|
| void | clear_vertices () |
| | Removes all of the vertices and primitives from the object, so they can be re-added.
|
| bool | close_primitive () |
| | Indicates that the previous n calls to add_vertex(), since the last call to close_primitive(), have fully defined a new primitive.
|
|
| CPT (GeomPrimitive) decompose() const |
|
| CPT (GeomPrimitive) rotate() const |
|
| CPT (GeomPrimitive) doubleside() const |
|
| CPT (GeomPrimitive) reverse() const |
|
| CPT (GeomPrimitive) match_shade_model(ShadeModel shade_model) const |
|
| CPT (GeomPrimitive) make_points() const |
|
| CPT (GeomVertexArrayData) get_vertices() const |
|
| CPT (GeomVertexArrayData) get_mins() const |
|
| CPT (GeomVertexArrayData) get_maxs() const |
|
| CPT (GeomVertexArrayFormat) get_index_format() const |
|
virtual bool | draw (GraphicsStateGuardianBase *gsg, const GeomPrimitivePipelineReader *reader, bool force) const =0 |
| virtual void | finalize (BamReader *manager) |
| | Called by the BamReader to perform any final actions needed for setting up the object after all objects have been read and all pointers have been completed.
|
|
virtual TypeHandle | force_init_type () |
| int | get_data_size_bytes () const |
| | Returns the number of bytes stored in the vertices array.
|
| CPTA_int | get_ends () const |
| | Returns a const pointer to the primitive ends array so application code can read it directly.
|
| int | get_first_vertex () const |
| | Returns the first vertex number referenced by the primitive.
|
| virtual int | get_geom_rendering () const |
| | Returns the set of GeomRendering bits that represent the rendering properties required to properly render this primitive.
|
| int | get_index_stride () const |
| | A convenience function to return the gap between successive index numbers, in bytes, of the index data.
|
| NumericType | get_index_type () const |
| | Returns the numeric type of the index column.
|
| int | get_max_vertex () const |
| | Returns the maximum vertex index number used by all the primitives in this object.
|
| virtual int | get_min_num_vertices_per_primitive () const |
| | Returns the minimum number of vertices that must be added before close_primitive() may legally be called.
|
| int | get_min_vertex () const |
| | Returns the minimum vertex index number used by all the primitives in this object.
|
| UpdateSeq | get_modified () const |
| | Returns a sequence number which is guaranteed to change at least every time the vertex index array is modified.
|
| int | get_num_bytes () const |
| | Returns the number of bytes consumed by the primitive and its index table(s).
|
| int | get_num_faces () const |
| | Returns the number of triangles or other fundamental type (such as line segments) represented by all the primitives in this object.
|
| int | get_num_primitives () const |
| | Returns the number of individual primitives stored within this object.
|
| virtual int | get_num_unused_vertices_per_primitive () const |
| | Returns the number of vertices that are added between primitives that aren't, strictly speaking, part of the primitives themselves.
|
| int | get_num_vertices () const |
| | Returns the number of vertices used by all the primitives in this object.
|
| virtual int | get_num_vertices_per_primitive () const |
| | If the primitive type is a simple type in which all primitives have the same number of vertices, like triangles, returns the number of vertices per primitive.
|
| int | get_primitive_end (int n) const |
| | Returns the element within the _vertices list at which the nth primitive ends.
|
| int | get_primitive_max_vertex (int n) const |
| | Returns the maximum vertex index number used by the nth primitive in this object.
|
| int | get_primitive_min_vertex (int n) const |
| | Returns the minimum vertex index number used by the nth primitive in this object.
|
| int | get_primitive_num_faces (int n) const |
| | Returns the number of triangles or other fundamental type (such as line segments) represented by the nth primitive in this object.
|
| int | get_primitive_num_vertices (int n) const |
| | Returns the number of vertices used by the nth primitive.
|
| int | get_primitive_start (int n) const |
| | Returns the element within the _vertices list at which the nth primitive starts.
|
|
virtual PrimitiveType | get_primitive_type () const =0 |
| ShadeModel | get_shade_model () const |
| | Returns the ShadeModel hint for this primitive.
|
|
virtual TypeHandle | get_type () const |
| UsageHint | get_usage_hint () const |
| | Returns the usage hint for this primitive.
|
| int | get_vertex (int i) const |
| | Returns the ith vertex index in the table.
|
| bool | is_composite () const |
| | 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.
|
| bool | is_indexed () const |
| | Returns true if the primitive is indexed, false otherwise.
|
| bool | is_prepared (PreparedGraphicsObjects *prepared_objects) const |
| | Returns true if the data has already been prepared or enqueued for preparation on the indicated GSG, false otherwise.
|
| void | make_indexed () |
| | Converts the primitive from nonindexed form to indexed form.
|
| void | make_nonindexed (GeomVertexData *dest, const GeomVertexData *source) |
| | Converts the primitive from indexed to nonindexed by duplicating vertices as necessary into the indicated dest GeomVertexData.
|
|
| MAKE_SEQ (get_vertices, get_num_vertices, get_vertex) |
| PTA_int | modify_ends () |
| | Returns a modifiable pointer to the primitive ends array, so application code can directly fiddle with this data.
|
| void | offset_vertices (int offset) |
| | Adds the indicated offset to all vertices used by the primitive.
|
| void | operator= (const GeomPrimitive ©) |
| | The copy assignment operator is not pipeline-safe.
|
|
virtual void | output (ostream &out) const |
| void | pack_vertices (GeomVertexData *dest, const GeomVertexData *source) |
| | Packs the vertices used by the primitive from the indicated source array onto the end of the indicated destination array.
|
| void | prepare (PreparedGraphicsObjects *prepared_objects) |
| | Indicates that the data should be enqueued to be prepared in the indicated prepared_objects at the beginning of the next frame.
|
| IndexBufferContext * | prepare_now (PreparedGraphicsObjects *prepared_objects, GraphicsStateGuardianBase *gsg) |
| | Creates a context for the data on the particular GSG, if it does not already exist.
|
|
virtual | PT (GeomPrimitive) make_copy() const =0 |
|
| PT (GeomVertexArrayData) modify_vertices(int num_vertices |
|
| PT (GeomVertexArrayData) make_index_data() const |
| bool | release (PreparedGraphicsObjects *prepared_objects) |
| | Frees the data context only on the indicated object, if it exists there.
|
| int | release_all () |
| | Frees the context allocated on all objects for which the data has been declared.
|
| bool | request_resident () const |
| | Returns true if the primitive data is currently resident in memory.
|
| void | reserve_num_vertices (int num_vertices) |
| | This ensures that enough memory space for n vertices is allocated, so that you may increase the number of vertices to n without causing a new memory allocation.
|
| void | set_ends (CPTA_int ends) |
| | Completely replaces the primitive ends array with a new table.
|
| void | set_index_type (NumericType index_type) |
| | Changes the numeric type of the index column.
|
| void | set_minmax (int min_vertex, int max_vertex, GeomVertexArrayData *mins, GeomVertexArrayData *maxs) |
| | Explicitly specifies the minimum and maximum vertices, as well as the lists of per-component min and max.
|
| void | set_nonindexed_vertices (int first_vertex, int num_vertices) |
| | Sets the primitive up as a nonindexed primitive, using the indicated vertex range.
|
| void | set_shade_model (ShadeModel shade_model) |
| | Changes the ShadeModel hint for this primitive.
|
| void | set_usage_hint (UsageHint usage_hint) |
| | Changes the UsageHint hint for this primitive.
|
| void | set_vertices (const GeomVertexArrayData *vertices, int num_vertices=-1) |
| | Completely replaces the vertex index list with a new table.
|
|
virtual void | write (ostream &out, int indent_level) const |
| virtual void | write_datagram (BamWriter *manager, Datagram &dg) |
| | Writes the contents of this object to the datagram for shipping out to a Bam file.
|
Static Public Member Functions |
|
static TypeHandle | get_class_type () |
|
static void | init_type () |
Protected Member Functions |
| | GeomPrimitive () |
| | Constructs an invalid object.
|
| virtual void | append_unused_vertices (GeomVertexArrayData *vertices, int vertex) |
| | Called when a new primitive is begun (other than the first primitive), this should add some degenerate vertices between primitives, if the primitive type requires that.
|
|
virtual | CPT (GeomPrimitive) decompose_impl() const |
|
virtual | CPT (GeomVertexArrayData) rotate_impl() const |
|
virtual | CPT (GeomPrimitive) doubleside_impl() const |
|
virtual | CPT (GeomPrimitive) reverse_impl() const |
| void | fillin (DatagramIterator &scan, BamReader *manager) |
| | This internal function is called by make_from_bam to read in all of the relevant data from the BamFile for the new GeomPrimitive.
|
|
virtual | PT (CopyOnWriteObject) make_cow_copy() |
| virtual bool | requires_unused_vertices () const |
| | Should be redefined to return true in any primitive that implements append_unused_vertices().
|
Friends |
|
class | Geom |
|
class | GeomPrimitivePipelineReader |
|
class | PreparedGraphicsObjects |
Detailed Description
This is an abstract base class for a family of classes that represent the fundamental geometry primitives that may be stored in a Geom.
They all have in common the fact that they are defined by tables of vertex data stored in a GeomVertexData object. Each GeomPrimitive object contains an ordered list of integers, which index into the vertex array defined by the GeomVertexData and define the particular vertices of the GeomVertexData that are used for this primitive.
The meaning of a given arrangement of vertices is defined by each individual primitive type; for instance, a GeomTriangle renders a triangle from each three consecutive vertices, while a GeomTriangleStrip renders a strip of (n - 2) connected triangles from each sequence of n vertices.
Definition at line 63 of file geomPrimitive.h.
Constructor & Destructor Documentation
Constructs an invalid object.
Only used when reading from bam.
Definition at line 48 of file geomPrimitive.cxx.
Member Function Documentation
Undoes a previous call to set_minmax(), and allows the minimum and maximum values to be recomputed normally.
This method is intended for low-level usage only. There are higher-level methods for more common usage. We recommend you do not use this method directly. If you do, be sure you know what you are doing!
Definition at line 1237 of file geomPrimitive.cxx.
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.
Definition at line 430 of file geomPrimitive.cxx.
References Geom::get_next_modified().
Referenced by Geom::unify_in_place().
Returns a const pointer to the primitive ends array so application code can read it directly.
Do not attempt to modify the returned array; use modify_ends() or set_ends() for this.
Note that simple primitive types, like triangles, do not have a ends array: since all the primitives have the same number of vertices, it is not needed.
This method is intended for low-level usage only. There are higher-level methods for more common usage. We recommend you do not use this method directly. If you do, be sure you know what you are doing!
Definition at line 331 of file geomPrimitive.I.
A convenience function to return the gap between successive index numbers, in bytes, of the index data.
This method is intended for low-level usage only. There are higher-level methods for more common usage. We recommend you do not use this method directly. If you do, be sure you know what you are doing!
Definition at line 308 of file geomPrimitive.I.
References Thread::get_current_thread().
Returns the numeric type of the index column.
Normally, this will be either NT_uint16 or NT_uint32.
Definition at line 79 of file geomPrimitive.I.
Returns a sequence number which is guaranteed to change at least every time the vertex index array is modified.
Definition at line 252 of file geomPrimitive.I.
Returns the number of bytes consumed by the primitive and its index table(s).
Definition at line 936 of file geomPrimitive.cxx.
If the primitive type is a simple type in which all primitives have the same number of vertices, like triangles, returns the number of vertices per primitive.
If the primitive type is a more complex type in which different primitives might have different numbers of vertices, for instance a triangle strip, returns 0.
This method is intended for low-level usage only. There are higher-level methods for more common usage. We recommend you do not use this method directly. If you do, be sure you know what you are doing!
Reimplemented in GeomPatches, GeomPoints, GeomLines, and GeomTriangles.
Definition at line 1259 of file geomPrimitive.cxx.
Referenced by close_primitive(), get_num_faces(), get_primitive_end(), get_primitive_num_faces(), get_primitive_num_vertices(), get_primitive_start(), and is_composite().
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.
Definition at line 24 of file geomPrimitive.I.
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.
Definition at line 109 of file geomPrimitive.I.
References Thread::get_current_thread().
Referenced by GeomPoints::get_geom_rendering(), GeomTristrips::get_geom_rendering(), GeomLinestrips::get_geom_rendering(), GeomTrifans::get_geom_rendering(), get_geom_rendering(), get_primitive_max_vertex(), get_primitive_min_vertex(), offset_vertices(), pack_vertices(), prepare(), and prepare_now().
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.
Definition at line 572 of file geomPrimitive.cxx.
Returns a modifiable pointer to the primitive ends array, so application code can directly fiddle with this data.
Use with caution, since there are no checks that the data will be left in a stable state.
Note that simple primitive types, like triangles, do not have a ends array: since all the primitives have the same number of vertices, it is not needed.
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.
This method is intended for low-level usage only. There are higher-level methods for more common usage. We recommend you do not use this method directly. If you do, be sure you know what you are doing!
Definition at line 1146 of file geomPrimitive.cxx.
References Geom::get_next_modified().
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.
Definition at line 93 of file geomPrimitive.cxx.
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.
Definition at line 955 of file geomPrimitive.cxx.
References is_composite().
This ensures that enough memory space for n vertices is allocated, so that you may increase the number of vertices to n without causing a new memory allocation.
This is a performance optimization only; it is especially useful when you know ahead of time that you will be adding n vertices to the primitive.
Note that the total you specify here should also include implicit vertices which may be added at each close_primitive() call, according to get_num_unused_vertices_per_primitive().
Note also that making this call will implicitly make the primitive indexed if it is not already, which could result in a performance *penalty*. If you would prefer not to lose the nonindexed nature of your existing GeomPrimitives, check is_indexed() before making this call.
Definition at line 351 of file geomPrimitive.cxx.
Completely replaces the primitive ends array with a new table.
Chances are good that you should also replace the vertices list with set_vertices() at the same time.
Note that simple primitive types, like triangles, do not have a ends array: since all the primitives have the same number of vertices, it is not needed.
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.
This method is intended for low-level usage only. There are higher-level methods for more common usage. We recommend you do not use this method directly. If you do, be sure you know what you are doing!
Definition at line 1182 of file geomPrimitive.cxx.
References Geom::get_next_modified().
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.
Definition at line 164 of file geomPrimitive.cxx.
References get_max_vertex().
Explicitly specifies the minimum and maximum vertices, as well as the lists of per-component min and max.
Use this method with extreme caution. It's generally better to let the GeomPrimitive compute these explicitly, unless for some reason you can do it faster and you absolutely need the speed improvement.
Note that any modification to the vertex array will normally cause this to be recomputed, unless you set it immediately again.
This method is intended for low-level usage only. There are higher-level methods for more common usage. We recommend you do not use this method directly. If you do, be sure you know what you are doing!
Definition at line 1212 of file geomPrimitive.cxx.
References Geom::get_next_modified().
Sets the primitive up as a nonindexed primitive, using the indicated vertex range.
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.
This method is intended for low-level usage only. There are higher-level methods for more common usage. We recommend you do not use this method directly. If you do, be sure you know what you are doing!
Definition at line 1110 of file geomPrimitive.cxx.
References Geom::get_next_modified().
Referenced by make_nonindexed().
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.
Definition at line 45 of file geomPrimitive.I.
Referenced by Geom::unify_in_place().
Completely replaces the vertex index list with a new table.
Chances are good that you should also replace the ends list with set_ends() at the same time.
If num_vertices is not -1, it specifies an artificial limit to the number of vertices in the array. Otherwise, all of the vertices in the array will be used.
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.
This method is intended for low-level usage only. There are higher-level methods for more common usage. We recommend you do not use this method directly. If you do, be sure you know what you are doing!
Definition at line 1085 of file geomPrimitive.cxx.
References Geom::get_next_modified().
Referenced by pack_vertices().
The documentation for this class was generated from the following files:
| | |