#include <builderPrimTempl.h>
Public Types | |
typedef VTX | Vertex |
typedef TYPENAME VTX::VType | VType |
typedef TYPENAME VTX::NType | NType |
typedef TYPENAME VTX::TType | TType |
typedef TYPENAME VTX::CType | CType |
typedef TYPENAME VTX::Attrib | DAttrib |
Public Member Functions | |
BuilderPrimTempl () | |
BuilderPrimTempl (const BuilderPrimTempl ©) | |
BuilderPrimTempl & | operator= (const BuilderPrimTempl ©) |
void | remove_doubled_verts (int closed) |
Removes consecutive identical vertices from the prim definition. | |
bool | is_valid () const |
Returns true if the primitive is well-defined and has the right number of vertices for its primitive type, and all of its vertices are valid. | |
bool | has_normal () const |
Returns true if set_normal() has been called on the primitive. | |
bool | has_color () const |
Returns true if set_color() has been called on the primitive. | |
bool | has_pixel_size () const |
Returns true if set_pixel_size() has been called on the primitive. | |
bool | has_overall_normal () const |
Returns true if the primitive has a single, overall normal value. | |
bool | has_overall_color () const |
Returns true if the primitive has a single, overall color value. | |
bool | has_overall_pixel_size () const |
Returns true if the primitive has a single, overall pixel_size value. | |
bool | has_vertex_normal () const |
Returns true if each of the primitive's vertices has a different normal value set. | |
bool | has_vertex_color () const |
Returns true if each of the primitive's vertices has a different color value set. | |
bool | has_vertex_texcoord () const |
Returns true if each of the primitive's vertices has a texcoord value set. | |
bool | has_vertex_pixel_size () const |
Returns true if each of the primitive's vertices has a different pixel_size value set. | |
bool | has_component_normal () const |
Returns true if the prim is a composite primitive like a tristrip, and its individual components each have a different normal value set. | |
bool | has_component_color () const |
Returns true if the prim is a composite primitive like a tristrip, and its individual components each have a different color value set. | |
bool | has_component_pixel_size () const |
Returns true if the prim is a composite primitive like a tristrip, and its individual components each have a different pixel_size value set. | |
bool | has_any_normal () const |
Returns true if the prim has a normal value set at any level. | |
bool | has_any_color () const |
Returns true if the prim has a color value set at any level. | |
bool | has_any_texcoord () const |
Returns true if the prim has a texcoord value set at any level. | |
bool | has_any_pixel_size () const |
Returns true if the prim has a pixel_size value set at any level. | |
BuilderPrimTempl & | clear () |
Resets the BuilderPrim to its initial, default state. | |
BuilderPrimTempl & | clear_vertices () |
Removes all the vertices that have been added to the BuilderPrim, without otherwise affecting its properties. | |
BuilderPrimTempl & | set_attrib (const DAttrib &attrib) |
Copies the polygon attributes, color and normal, from the indicated attribute structure (which might be another BuilderPrim). | |
BuilderPrimType | get_type () const |
Indicates the type of primitive represented by the BuilderPrim. | |
BuilderPrimTempl & | set_type (BuilderPrimType t) |
Indicates the type of primitive represented by the BuilderPrim. | |
NType | get_normal () const |
Returns the value previously set by set_normal(), or the overall normal value common to all vertices. | |
BuilderPrimTempl & | set_normal (const NType &n) |
Sets the flat normal associated with the primitive. | |
CType | get_color () const |
Returns the value previously set by set_color(), or the overall color value common to all vertices. | |
BuilderPrimTempl & | set_color (const CType &c) |
Sets the flat color associated with the primitive. | |
float | get_pixel_size () const |
Returns the value previously set by set_pixel_size(), or the overall pixel_size value common to all vertices. | |
BuilderPrimTempl & | set_pixel_size (float s) |
Sets the line thickness (for a polygon or line) or size (for a point) in pixels. | |
BuilderPrimTempl & | add_vertex (const Vertex &v) |
Adds a new vertex to the BuilderPrim. | |
int | get_num_verts () const |
Returns the number of vertices in the primitive. | |
Vertex & | get_vertex (int n) |
Returns a reference to the nth vertex of the primitive, where 0 <= n < get_num_verts(). | |
const Vertex & | get_vertex (int n) const |
Returns the nth vertex of the primitive, where 0 <= n < get_num_verts(). | |
BuilderPrimTempl & | add_component (const DAttrib &attrib) |
Normally, this function is only used by the mesher code; user code generally should not need to call it. | |
int | get_num_components () const |
Returns the number of times add_component() has been called. | |
DAttrib & | get_component (int n) |
Returns a refernece to the attribute structure associated with the nth component, where 0 <= n < get_num_components(). | |
const DAttrib & | get_component (int n) const |
Returns the attributes associated with the nth component, where 0 <= n < get_num_components(). | |
bool | operator< (const BuilderPrimTempl &other) const |
Returns true if this primitive should come before the other one, in the bin ordering. | |
ostream & | output (ostream &out) const |
Formats the prim for output in some sensible way. | |
Protected Types | |
typedef pvector< Vertex > | Verts |
typedef pvector< DAttrib > | Components |
Protected Member Functions | |
int | sort_value () const |
Returns a number for grouping primitives, such that only primitives that share the same number can be tristripped together. | |
void | update_overall_attrib () |
Examines the primitive and all of its vertices and components to determine the amount of commonality of each attribute, and updates the bits in _overall to indicate this. | |
Protected Attributes | |
Verts | _verts |
Components | _components |
BuilderPrimType | _type |
int | _overall |
This is a template class on vertex type, which must be either BuilderVertex or BuilderVertexI; these classes are themselves template classes on vertex type, texcoord type, color type, etc.
Definition at line 50 of file builderPrimTempl.h.
|
Definition at line 149 of file builderPrimTempl.h. |
|
Definition at line 56 of file builderPrimTempl.h. |
|
Definition at line 57 of file builderPrimTempl.h. Referenced by BuilderPrimTempl< VTX >::get_color(), BuilderPrimTempl< VTX >::operator<(), and BuilderPrimTempl< VTX >::sort_value(). |
|
Definition at line 54 of file builderPrimTempl.h. |
|
Definition at line 55 of file builderPrimTempl.h. |
|
Definition at line 52 of file builderPrimTempl.h. Referenced by BuilderPrimTempl< VTX >::get_component(). |
|
Definition at line 148 of file builderPrimTempl.h. |
|
Definition at line 53 of file builderPrimTempl.h. |
|
Definition at line 35 of file builderPrimTempl.I. References INLINE. |
|
Definition at line 49 of file builderPrimTempl.I. References BuilderPrimTempl< VTX >::_components, BuilderPrimTempl< VTX >::_overall, BuilderPrimTempl< VTX >::_type, BuilderPrimTempl< VTX >::_verts, and INLINE. |
|
Normally, this function is only used by the mesher code; user code generally should not need to call it. In addition to storing a simple polygon, a BuilderPrim can store a composite primitive, like a triangle strip. In this case, it is useful to store the attributes (like color and normal) associated with each component. When get_type() is one of the composite types, it is the responsibility of the caller to call add_component() once for each component, where the number of components is defined by the type and the number of vertices (e.g. for a triangle strip, the number of components is the number of vertices - 2). Definition at line 838 of file builderPrimTempl.I. |
|
Adds a new vertex to the BuilderPrim. The vertex data is copied into the prim's internal structure. Vertices should be added in counterclockwise order, when viewed from the front. Definition at line 738 of file builderPrimTempl.I. |
|
Resets the BuilderPrim to its initial, default state.
Definition at line 487 of file builderPrimTempl.I. |
|
Removes all the vertices that have been added to the BuilderPrim, without otherwise affecting its properties.
Definition at line 508 of file builderPrimTempl.I. References INLINE. Referenced by BuilderPrimTempl< VTX >::has_component_color(). |
|
Returns the value previously set by set_color(), or the overall color value common to all vertices. It is an error to call this without first testing that one of has_color() or has_overall_color() is true. Definition at line 656 of file builderPrimTempl.I. References BuilderPrimTempl< VTX >::_components, BuilderPrimTempl< VTX >::DAttrib, INLINE, nassertr, and TYPENAME. |
|
Returns the attributes associated with the nth component, where 0 <= n < get_num_components(). See add_component() and get_num_components(). Definition at line 908 of file builderPrimTempl.I. |
|
Returns a refernece to the attribute structure associated with the nth component, where 0 <= n < get_num_components(). This reference may be modified directly, e.g. to change the color of a polygon after it has been added to the tristrip. See add_component() and get_num_components(). Definition at line 888 of file builderPrimTempl.I. References BuilderPrimTempl< VTX >::Vertex. |
|
Returns the value previously set by set_normal(), or the overall normal value common to all vertices. It is an error to call this without first testing that one of has_normal() or has_overall_normal() is true. Definition at line 616 of file builderPrimTempl.I. References BuilderPrimTempl< VTX >::_components. |
|
Returns the number of times add_component() has been called. This should be, but is not necessarily, the same as the number of components in the composite primitive (e.g. a triangle strip). See add_component(). Definition at line 863 of file builderPrimTempl.I. References BuilderPrimTempl< VTX >::get_vertex(), BuilderPrimTempl< VTX >::has_component_color(), BuilderPrimTempl< VTX >::has_component_normal(), BuilderPrimTempl< VTX >::has_component_pixel_size(), BuilderPrimTempl< VTX >::has_vertex_color(), BuilderPrimTempl< VTX >::has_vertex_normal(), BuilderPrimTempl< VTX >::has_vertex_pixel_size(), and BuilderPrimTempl< VTX >::has_vertex_texcoord(). |
|
Returns the number of vertices in the primitive.
Definition at line 755 of file builderPrimTempl.I. References BuilderPrimTempl< VTX >::_verts, and TYPENAME. Referenced by BuilderPrimTempl< VTX >::get_vertex(). |
|
Returns the value previously set by set_pixel_size(), or the overall pixel_size value common to all vertices. It is an error to call this without first testing that one of has_pixel_size() or has_overall_pixel_size() is true. Definition at line 698 of file builderPrimTempl.I. References BuilderPrimTempl< VTX >::has_vertex_normal(), and INLINE. Referenced by BuilderPrimTempl< VTX >::set_color(). |
|
Indicates the type of primitive represented by the BuilderPrim. See set_type(). Definition at line 550 of file builderPrimTempl.I. References BuilderPrimTempl< VTX >::_verts, and INLINE. Referenced by BuilderPrimTempl< VTX >::get_vertex(). |
|
Returns the nth vertex of the primitive, where 0 <= n < get_num_verts().
Definition at line 794 of file builderPrimTempl.I. References BPT_line, BPT_quad, BPT_tri, BPT_trifan, and BPT_tristrip. |
|
Returns a reference to the nth vertex of the primitive, where 0 <= n < get_num_verts(). This reference may be modified directly, e.g. to set a vertex normal on a vertex after it has been added to the primitive. Definition at line 777 of file builderPrimTempl.I. References BPT_point, BPT_poly, BuilderPrimTempl< VTX >::get_num_verts(), and BuilderPrimTempl< VTX >::get_type(). Referenced by BuilderPrimTempl< VTX >::get_num_components(). |
|
Returns true if the prim has a color value set at any level. That is, it returns true if any of has_overall_color(), has_vertex_color(), or has_component_color() is true. Definition at line 430 of file builderPrimTempl.I. References BuilderPrimTempl< VTX >::_type, INLINE, and t. |
|
Returns true if the prim has a normal value set at any level. That is, it returns true if any of has_overall_normal(), has_vertex_normal(), or has_component_normal() is true. Definition at line 409 of file builderPrimTempl.I. References BuilderPrimTempl< VTX >::_type, BuilderPrimType, and INLINE. |
|
Returns true if the prim has a pixel_size value set at any level. That is, it returns true if any of has_overall_pixel_size(), has_vertex_pixel_size(), or has_component_pixel_size() is true. Definition at line 471 of file builderPrimTempl.I. References BuilderPrimTempl< VTX >::_overall. |
|
Returns true if the prim has a texcoord value set at any level. Since texture coordinates can only be set on vertices, this is the same thing as has_vertex_texcoord(). Definition at line 451 of file builderPrimTempl.I. |
|
Returns true if set_color() has been called on the primitive. This is unrelated to the color values that may or may not override from the vertices. Also see has_overall_color(). Definition at line 111 of file builderPrimTempl.I. References BuilderPrimTempl< VTX >::_overall, BAF_overall_normal, BAF_overall_updated, and INLINE. |
|
Returns true if the prim is a composite primitive like a tristrip, and its individual components each have a different color value set.
Definition at line 363 of file builderPrimTempl.I. References BuilderPrimTempl< VTX >::_type, BPT_poly, BuilderPrimTempl< VTX >::clear_vertices(), and INLINE. Referenced by BuilderPrimTempl< VTX >::get_num_components(), and BuilderPrimTempl< VTX >::has_vertex_pixel_size(). |
|
Returns true if the prim is a composite primitive like a tristrip, and its individual components each have a different normal value set.
Definition at line 341 of file builderPrimTempl.I. References BuilderPrimTempl< VTX >::has_component_pixel_size(), BuilderPrimTempl< VTX >::has_overall_pixel_size(), BuilderPrimTempl< VTX >::has_vertex_pixel_size(), and INLINE. Referenced by BuilderPrimTempl< VTX >::get_num_components(), and BuilderPrimTempl< VTX >::has_vertex_texcoord(). |
|
Returns true if the prim is a composite primitive like a tristrip, and its individual components each have a different pixel_size value set.
Definition at line 385 of file builderPrimTempl.I. Referenced by BuilderPrimTempl< VTX >::get_num_components(), and BuilderPrimTempl< VTX >::has_component_normal(). |
|
Returns true if set_normal() has been called on the primitive. This is unrelated to the normal values that may or may not override from the vertices. Also see has_overall_normal(). Definition at line 90 of file builderPrimTempl.I. |
|
Returns true if the primitive has a single, overall color value. This can happen because of one of: (a) the primitive had a color value assigned to it directly, and its individual vertices and components did not; (b) each vertex was assigned the same color value; (c) each component was assigned the same color value. If has_overall_color() returns true, then get_color() will return the overall color value. Definition at line 201 of file builderPrimTempl.I. References BuilderPrimTempl< VTX >::_overall, BAF_overall_updated, BAF_vertex_color, and INLINE. Referenced by BuilderPrimTempl< VTX >::has_vertex_pixel_size(). |
|
Returns true if the primitive has a single, overall normal value. This can happen because of one of: (a) the primitive had a normal value assigned to it directly, and its individual vertices and components did not; (b) each vertex was assigned the same normal value; (c) each component was assigned the same normal value. If has_overall_normal() returns true, then get_normal() will return the overall normal value. Definition at line 165 of file builderPrimTempl.I. References BuilderPrimTempl< VTX >::_overall, BAF_overall_pixel_size, BAF_overall_updated, and INLINE. Referenced by BuilderPrimTempl< VTX >::has_vertex_texcoord(). |
|
Returns true if the primitive has a single, overall pixel_size value. This can happen because of one of: (a) the primitive had a pixel_size value assigned to it directly, and its individual vertices and components did not; (b) each vertex was assigned the same pixel_size value; (c) each component was assigned the same pixel_size value. If has_overall_pixel_size() returns true, then get_pixel_size() will return the overall pixel_size value. Definition at line 239 of file builderPrimTempl.I. References BuilderPrimTempl< VTX >::_overall, BAF_overall_updated, and BAF_vertex_pixel_size. Referenced by BuilderPrimTempl< VTX >::has_component_normal(). |
|
Returns true if set_pixel_size() has been called on the primitive. This is unrelated to the pixel_size values that may or may not override from the vertices. Also see has_overall_pixel_size(). Definition at line 132 of file builderPrimTempl.I. References BuilderPrimTempl< VTX >::_overall, BAF_overall_color, BAF_overall_updated, and INLINE. Referenced by BuilderPrimTempl< VTX >::set_color(). |
|
Returns true if each of the primitive's vertices has a different color value set.
Definition at line 279 of file builderPrimTempl.I. References BuilderPrimTempl< VTX >::_overall, BAF_component_pixel_size, BAF_overall_updated, and INLINE. Referenced by BuilderPrimTempl< VTX >::get_num_components(), and BuilderPrimTempl< VTX >::has_vertex_pixel_size(). |
|
Returns true if each of the primitive's vertices has a different normal value set.
Definition at line 259 of file builderPrimTempl.I. Referenced by BuilderPrimTempl< VTX >::get_num_components(), BuilderPrimTempl< VTX >::get_pixel_size(), and BuilderPrimTempl< VTX >::has_vertex_texcoord(). |
|
Returns true if each of the primitive's vertices has a different pixel_size value set.
Definition at line 319 of file builderPrimTempl.I. References BuilderPrimTempl< VTX >::has_component_color(), BuilderPrimTempl< VTX >::has_overall_color(), BuilderPrimTempl< VTX >::has_vertex_color(), and INLINE. Referenced by BuilderPrimTempl< VTX >::get_num_components(), and BuilderPrimTempl< VTX >::has_component_normal(). |
|
Returns true if each of the primitive's vertices has a texcoord value set.
Definition at line 299 of file builderPrimTempl.I. References BuilderPrimTempl< VTX >::has_component_normal(), BuilderPrimTempl< VTX >::has_overall_normal(), BuilderPrimTempl< VTX >::has_vertex_normal(), and INLINE. Referenced by BuilderPrimTempl< VTX >::get_num_components(). |
|
Returns true if the primitive is well-defined and has the right number of vertices for its primitive type, and all of its vertices are valid.
Definition at line 1057 of file builderPrimTempl.I. |
|
Returns true if this primitive should come before the other one, in the bin ordering. This is used to sort polygons into groups which can be tristripped together, similar to the same operation on the BuilderBucket, except that this works at a finer level of detail (i.e. on prims within the same bucket). Definition at line 936 of file builderPrimTempl.I. References BuilderPrimTempl< VTX >::DAttrib. |
|
Definition at line 63 of file builderPrimTempl.I. References INLINE. Referenced by BuilderPrim::BuilderPrim(). |
|
Formats the prim for output in some sensible way.
Definition at line 1101 of file builderPrimTempl.I. |
|
Removes consecutive identical vertices from the prim definition. These are meaningless and only confuse polygon subdividing and meshing. If closed is true, this also removes vertices doubled at the beginning and end (as if the list of vertices were implicitly closed, as it is for a polygon). Definition at line 1024 of file builderPrimTempl.I. References BuilderPrimTempl< VTX >::_overall, and BAF_overall_pixel_size. |
|
Copies the polygon attributes, color and normal, from the indicated attribute structure (which might be another BuilderPrim).
Definition at line 531 of file builderPrimTempl.I. |
|
Sets the flat color associated with the primitive. If each of the primitive's vertices also has a color set, the vertex colors will override. Definition at line 674 of file builderPrimTempl.I. References BuilderPrimTempl< VTX >::get_pixel_size(), BuilderPrimTempl< VTX >::has_pixel_size(), INLINE, and BuilderPrimTempl< VTX >::sort_value(). |
|
Sets the flat normal associated with the primitive. If each of the primitive's vertices also has a normal set, the vertex normals will override. Definition at line 634 of file builderPrimTempl.I. |
|
Sets the line thickness (for a polygon or line) or size (for a point) in pixels.
Definition at line 715 of file builderPrimTempl.I. |
|
Indicates the type of primitive represented by the BuilderPrim. Normally, the user should set this to one of BPT_poly, BPT_point, or BPT_line. However, other types are possible, and are created by the mesher, including triangle strips, quad strips, and triangle fans. Setting this value changes the interpretation of the vertices, for instance, a triangle strip is defined by vertices that zigzag back and forth between the triangles. Note that when defining a composite primitive such as a triangle strip, it is also necessary to call add_component() the correct number of times to match the calls to add_vertex(), according to the primitive type. See add_component(). Definition at line 595 of file builderPrimTempl.I. References BuilderPrimTempl< VTX >::_overall, and INLINE. |
|
Returns a number for grouping primitives, such that only primitives that share the same number can be tristripped together.
Definition at line 966 of file builderPrimTempl.I. References BuilderPrimTempl< VTX >::DAttrib. Referenced by BuilderPrimTempl< VTX >::set_color(). |
|
Examines the primitive and all of its vertices and components to determine the amount of commonality of each attribute, and updates the bits in _overall to indicate this. If an overall attribute is found, the primitive attribute value is set to that common value. Definition at line 1143 of file builderPrimTempl.I. |
|
Definition at line 152 of file builderPrimTempl.h. Referenced by BuilderPrimTempl< VTX >::BuilderPrimTempl(), BuilderPrimTempl< VTX >::get_color(), and BuilderPrimTempl< VTX >::get_normal(). |
|
|
Definition at line 153 of file builderPrimTempl.h. Referenced by BuilderPrimTempl< VTX >::BuilderPrimTempl(), BuilderPrimTempl< VTX >::has_any_color(), BuilderPrimTempl< VTX >::has_any_normal(), and BuilderPrimTempl< VTX >::has_component_color(). |
|
Definition at line 151 of file builderPrimTempl.h. Referenced by BuilderPrimTempl< VTX >::BuilderPrimTempl(), BuilderPrimTempl< VTX >::get_num_verts(), and BuilderPrimTempl< VTX >::get_type(). |