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

This class defines the physical layout of the vertex data stored within a Geom. More...

Inheritance diagram for GeomVertexFormat:
TypedWritableReferenceCount GeomEnums TypedWritable ReferenceCount TypedObject

Public Member Functions

 __init__ ()
 
 __init__ (const GeomVertexArrayFormat array_format)
 
 __init__ (const GeomVertexFormat copy)
 
int addArray (const GeomVertexArrayFormat array_format)
 Adds the indicated array definition to the list of arrays included within this vertex format definition. More...
 
 alignColumnsForAnimation ()
 Reprocesses the columns in the format to align the C_point and C_vector columns to 16-byte boundaries to allow for the more efficient SSE2 operations (assuming SSE2 is enabled in the build). More...
 
 clearArrays ()
 Removes all of the array definitions from the format and starts over. More...
 
const GeomVertexAnimationSpec getAnimation ()
 Returns the GeomVertexAnimationSpec that indicates how this format's vertices are set up for animation. More...
 
const GeomVertexArrayFormat getArray (int array)
 Returns the description of the nth array used by the format. More...
 
list getArrays ()
 
int getArrayWith (const InternalName name)
 Returns the index number of the array with the indicated column, or -1 if no arrays contained that name. More...
 
int getArrayWith (int i)
 Returns the index number of the array with the ith column. More...
 
const GeomVertexColumn getColumn (const InternalName name)
 Returns the specification with the indicated name, or NULL if the name is not used. More...
 
const GeomVertexColumn getColumn (int i)
 Returns the ith column of the specification, across all arrays. More...
 
const InternalName getColumnName (int i)
 Returns the name of the ith column, across all arrays. More...
 
list getColumns ()
 
const InternalName getMorphBase (int n)
 Returns the name of the base column that the nth morph modifies. More...
 
list getMorphBases ()
 
const InternalName getMorphDelta (int n)
 Returns the name of the column that defines the nth morph. More...
 
list getMorphDeltas ()
 
const InternalName getMorphSlider (int n)
 Returns the slider name associated with the nth morph column. More...
 
list getMorphSliders ()
 
int getNumArrays ()
 Returns the number of individual arrays required by the format. More...
 
int getNumColumns ()
 Returns the total number of different columns in the specification, across all arrays. More...
 
int getNumMorphs ()
 Returns the number of columns within the format that represent morph deltas. More...
 
int getNumPoints ()
 Returns the number of columns within the format that represent points in space. More...
 
int getNumTexcoords ()
 Returns the number of columns within the format that represent texture coordinates. More...
 
int getNumVectors ()
 Returns the number of columns within the format that represent directional vectors. More...
 
const InternalName getPoint (int n)
 Returns the name of the nth point column. More...
 
list getPoints ()
 
const GeomVertexFormat getPostAnimatedFormat ()
 Returns a suitable vertex format for sending the animated vertices to the graphics backend. More...
 
const InternalName getTexcoord (int n)
 Returns the name of the nth texcoord column. More...
 
list getTexcoords ()
 
const GeomVertexFormat getUnionFormat (const GeomVertexFormat other)
 Returns a new GeomVertexFormat that includes all of the columns defined in either this GeomVertexFormat or the other one. More...
 
const InternalName getVector (int n)
 Returns the name of the nth vector column. More...
 
list getVectors ()
 
bool hasColumn (const InternalName name)
 Returns true if the format has the named column, false otherwise. More...
 
 insertArray (int array, const GeomVertexArrayFormat array_format)
 Adds the indicated array definition to the list of arrays at the indicated position. More...
 
bool isRegistered ()
 Returns true if this format has been registered, false if it has not. More...
 
 maybeAlignColumnsForAnimation ()
 Calls align_columns_for_animation() if this format's AnimationSpec indicates that it contains animated vertices, and if vertex-animation- align-16 is true. More...
 
GeomVertexArrayFormat modifyArray (int array)
 Returns a modifiable pointer to the indicated array. More...
 
GeomVertexFormat operator= (const GeomVertexFormat copy)
 
 output (Ostream out)
 
 packColumns ()
 Removes wasted space between columns. More...
 
 removeArray (int array)
 Removes the nth array from the format. More...
 
 removeColumn (const InternalName name, bool keep_empty_array)
 Removes the named column from the format, from whichever array it exists in. More...
 
 removeEmptyArrays ()
 Removes the arrays that define no columns. More...
 
 setAnimation (const GeomVertexAnimationSpec animation)
 Resets the GeomVertexAnimationSpec that indicates how this format's vertices are set up for animation. More...
 
 setArray (int array, const GeomVertexArrayFormat format)
 Replaces the definition of the indicated array. More...
 
bool unref ()
 This method overrides ReferenceCount::unref() to unregister the object when its reference count goes to zero. More...
 
 write (Ostream out, int indent_level)
 
 writeWithData (Ostream out, int indent_level, const GeomVertexData data)
 
- Public Member Functions inherited from TypedWritable
object __reduce__ ()
 
object __reduce_persist__ (object pickler)
 
VectorUchar encodeToBamStream ()
 Converts the TypedWritable object into a single stream of data using a BamWriter, and returns that data as a bytes object. More...
 
bool encodeToBamStream (VectorUchar data, BamWriter writer)
 Converts the TypedWritable object into a single stream of data using a BamWriter, and stores that data in the indicated string. More...
 
 fillin (DatagramIterator scan, BamReader manager)
 This internal function is intended to be called by each class's make_from_bam() method to read in all of the relevant data from the BamFile for the new object. More...
 
UpdateSeq getBamModified ()
 Returns the current bam_modified counter. More...
 
 markBamModified ()
 Increments the bam_modified counter, so that this object will be invalidated and retransmitted on any open bam streams. More...
 
- Public Member Functions inherited from TypedObject
TypeHandle getType ()
 
int getTypeIndex ()
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. 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. More...
 
bool testRefCountIntegrity ()
 Does some easy checks to make sure that the reference count isn't completely bogus. More...
 
bool testRefCountNonzero ()
 Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More...
 
bool unref ()
 Explicitly decrements the reference count. More...
 
- Public Member Functions inherited from GeomEnums
 __init__ ()
 
 __init__ (const GeomEnums)
 

Static Public Member Functions

static TypeHandle getClassType ()
 
static const GeomVertexFormat getEmpty ()
 Returns a standard vertex format containing no arrays at all, useful for pull-style vertex rendering. More...
 
static const GeomVertexFormat getV3 ()
 
static const GeomVertexFormat getV3c4 ()
 
static const GeomVertexFormat getV3c4t2 ()
 Returns a standard vertex format with a 2-component texture coordinate pair, a 4-component color, and a 3-component vertex position. More...
 
static const GeomVertexFormat getV3cp ()
 
static const GeomVertexFormat getV3cpt2 ()
 Returns a standard vertex format with a 2-component texture coordinate pair, a packed color, and a 3-component vertex position. More...
 
static const GeomVertexFormat getV3n3 ()
 Returns a standard vertex format with a 3-component normal and a 3-component vertex position. More...
 
static const GeomVertexFormat getV3n3c4 ()
 Returns a standard vertex format with a 4-component color, a 3-component normal, and a 3-component vertex position. More...
 
static const GeomVertexFormat getV3n3c4t2 ()
 Returns a standard vertex format with a 2-component texture coordinate pair, a 4-component color, a 3-component normal, and a 3-component vertex position. More...
 
static const GeomVertexFormat getV3n3cp ()
 Returns a standard vertex format with a packed color, a 3-component normal, and a 3-component vertex position. More...
 
static const GeomVertexFormat getV3n3cpt2 ()
 Returns a standard vertex format with a 2-component texture coordinate pair, a packed color, a 3-component normal, and a 3-component vertex position. More...
 
static const GeomVertexFormat getV3n3t2 ()
 Returns a standard vertex format with a 2-component texture coordinate pair, a 3-component normal, and a 3-component vertex position. More...
 
static const GeomVertexFormat getV3t2 ()
 Returns a standard vertex format with a 2-component texture coordinate pair and a 3-component vertex position. More...
 
static const GeomVertexFormat registerFormat (const GeomVertexArrayFormat format)
 This flavor of register_format() implicitly creates a one-array vertex format from the array definition. More...
 
static const GeomVertexFormat registerFormat (const GeomVertexFormat format)
 Adds the indicated format to the registry, if there is not an equivalent format already there; in either case, returns the pointer to the equivalent format now in the registry. More...
 
- Static Public Member Functions inherited from TypedWritableReferenceCount
static TypedWritableReferenceCount decodeFromBamStream (VectorUchar data, BamReader reader)
 Reads the bytes created by a previous call to encode_to_bam_stream(), and extracts and returns the single object on those bytes. More...
 
static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from TypedWritable
static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from TypedObject
static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from ReferenceCount
static TypeHandle getClassType ()
 

Public Attributes

const GeomVertexAnimationSpec animation
 Returns the GeomVertexAnimationSpec that indicates how this format's vertices are set up for animation. More...
 
const GeomVertexArrayFormat arrays []
 
const GeomVertexColumn columns []
 We also define this as a mapping interface, for lookups by name. More...
 
const InternalName points []
 
bool registered
 Returns true if this format has been registered, false if it has not. More...
 
const InternalName vectors []
 
- Public Attributes inherited from TypedObject
TypeHandle type
 Returns the TypeHandle representing this object's type. More...
 
- Public Attributes inherited from ReferenceCount
int ref_count
 The current reference count. More...
 

Additional Inherited Members

- Public Types inherited from GeomEnums
enum  AnimationType { AT_none = 0, AT_panda = 1, AT_hardware = 2 }
 
enum  Contents {
  C_other = 0, C_point = 1, C_clip_point = 2, C_vector = 3,
  C_texcoord = 4, C_color = 5, C_index = 6, C_morph_delta = 7,
  C_matrix = 8, C_normal = 9
}
 
enum  GeomRendering {
  GR_indexed_point = 1, GR_indexed_other = 65536, GR_indexed_bits = 65537, GR_point = 2,
  GR_point_uniform_size = 4, GR_per_point_size = 8, GR_point_perspective = 16, GR_point_aspect_ratio = 32,
  GR_point_scale = 64, GR_point_rotate = 128, GR_point_sprite = 256, GR_point_sprite_tex_matrix = 512,
  GR_point_bits = 1022, GR_triangle_strip = 1024, GR_triangle_fan = 2048, GR_line_strip = 4096,
  GR_composite_bits = 7168, GR_strip_cut_index = 131072, GR_flat_first_vertex = 8192, GR_flat_last_vertex = 16384,
  GR_shade_model_bits = 24576, GR_render_mode_wireframe = 262144, GR_render_mode_point = 524288, GR_adjacency = 1048576
}
 
enum  NumericType {
  NT_uint8 = 0, NT_uint16 = 1, NT_uint32 = 2, NT_packed_dcba = 3,
  NT_packed_dabc = 4, NT_float32 = 5, NT_float64 = 6, NT_stdfloat = 7,
  NT_int8 = 8, NT_int16 = 9, NT_int32 = 10, NT_packed_ufloat = 11
}
 
enum  PrimitiveType {
  PT_none = 0, PT_polygons = 1, PT_lines = 2, PT_points = 3,
  PT_patches = 4
}
 
enum  ShadeModel { SM_uniform = 0, SM_smooth = 1, SM_flat_first_vertex = 2, SM_flat_last_vertex = 3 }
 
enum  UsageHint {
  UH_client = 0, UH_stream = 1, UH_dynamic = 2, UH_static = 3,
  UH_unspecified = 4
}
 

Detailed Description

This class defines the physical layout of the vertex data stored within a Geom.

The layout consists of a list of named columns, each of which has a numeric type and a size.

The columns are typically interleaved within a single array, but they may also be distributed among multiple different arrays; at the extreme, each column may be alone within its own array (which amounts to a parallel-array definition).

Thus, a GeomVertexFormat is really a list of GeomVertexArrayFormats, each of which contains a list of columns. However, a particular column name should not appear more than once in the format, even between different arrays.

There are a handful of standard pre-defined GeomVertexFormat objects, or you may define your own as needed. You may record any combination of standard and/or user-defined columns in your custom GeomVertexFormat constructions.

Member Function Documentation

◆ __init__() [1/3]

__init__ ( )

◆ __init__() [2/3]

__init__ ( const GeomVertexArrayFormat  array_format)

◆ __init__() [3/3]

__init__ ( const GeomVertexFormat  copy)

◆ addArray()

int addArray ( const GeomVertexArrayFormat  array_format)

Adds the indicated array definition to the list of arrays included within this vertex format definition.

The return value is the index number of the new array.

This may not be called once the format has been registered.

◆ alignColumnsForAnimation()

alignColumnsForAnimation ( )

Reprocesses the columns in the format to align the C_point and C_vector columns to 16-byte boundaries to allow for the more efficient SSE2 operations (assuming SSE2 is enabled in the build).

Also see maybe_align_columns_for_animation().

◆ clearArrays()

clearArrays ( )

Removes all of the array definitions from the format and starts over.

This may not be called once the format has been registered.

◆ getAnimation()

const GeomVertexAnimationSpec getAnimation ( )

Returns the GeomVertexAnimationSpec that indicates how this format's vertices are set up for animation.

◆ getArray()

const GeomVertexArrayFormat getArray ( int  array)

Returns the description of the nth array used by the format.

◆ getArrays()

list getArrays ( )

◆ getArrayWith() [1/2]

int getArrayWith ( const InternalName  name)

Returns the index number of the array with the indicated column, or -1 if no arrays contained that name.

The return value can be passed to get_array_format() to get the format of the array. It may also be passed to GeomVertexData::get_array_data() or get_data() or set_data() to manipulate the actual array data.

This may only be called after the format has been registered.

◆ getArrayWith() [2/2]

int getArrayWith ( int  i)

Returns the index number of the array with the ith column.

The return value can be passed to get_array_format() to get the format of the array. It may also be passed to GeomVertexData::get_array_data() or get_data() or set_data() to manipulate the actual array data.

◆ getClassType()

static TypeHandle getClassType ( )
static

◆ getColumn() [1/2]

const GeomVertexColumn getColumn ( const InternalName  name)

Returns the specification with the indicated name, or NULL if the name is not used.

Use get_array_with() to determine which array this column is associated with.

◆ getColumn() [2/2]

const GeomVertexColumn getColumn ( int  i)

Returns the ith column of the specification, across all arrays.

◆ getColumnName()

const InternalName getColumnName ( int  i)

Returns the name of the ith column, across all arrays.

◆ getColumns()

list getColumns ( )

◆ getEmpty()

static const GeomVertexFormat getEmpty ( )
static

Returns a standard vertex format containing no arrays at all, useful for pull-style vertex rendering.

◆ getMorphBase()

const InternalName getMorphBase ( int  n)

Returns the name of the base column that the nth morph modifies.

This column will also be defined within the format, and can be retrieved via get_array_with() and/or get_column().

This may only be called after the format has been registered.

◆ getMorphBases()

list getMorphBases ( )

◆ getMorphDelta()

const InternalName getMorphDelta ( int  n)

Returns the name of the column that defines the nth morph.

This contains the delta offsets that are to be applied to the column defined by get_morph_base(). This column will be defined within the format, and can be retrieved via get_array_with() and/or get_column().

This may only be called after the format has been registered.

◆ getMorphDeltas()

list getMorphDeltas ( )

◆ getMorphSlider()

const InternalName getMorphSlider ( int  n)

Returns the slider name associated with the nth morph column.

This is the name of the slider that will control the morph, and should be defined within the SliderTable associated with the GeomVertexData.

This may only be called after the format has been registered.

◆ getMorphSliders()

list getMorphSliders ( )

◆ getNumArrays()

int getNumArrays ( )

Returns the number of individual arrays required by the format.

If the array data is completely interleaved, this will be 1; if it is completely parallel, this will be the same as the number of data types.

◆ getNumColumns()

int getNumColumns ( )

Returns the total number of different columns in the specification, across all arrays.

◆ getNumMorphs()

int getNumMorphs ( )

Returns the number of columns within the format that represent morph deltas.

This may only be called after the format has been registered.

◆ getNumPoints()

int getNumPoints ( )

Returns the number of columns within the format that represent points in space.

This may only be called after the format has been registered.

◆ getNumTexcoords()

int getNumTexcoords ( )

Returns the number of columns within the format that represent texture coordinates.

This may only be called after the format has been registered.

◆ getNumVectors()

int getNumVectors ( )

Returns the number of columns within the format that represent directional vectors.

This may only be called after the format has been registered.

◆ getPoint()

const InternalName getPoint ( int  n)

Returns the name of the nth point column.

This represents a point in space, which should be transformed by any spatial transform matrix.

This may only be called after the format has been registered.

◆ getPoints()

list getPoints ( )

◆ getPostAnimatedFormat()

const GeomVertexFormat getPostAnimatedFormat ( )

Returns a suitable vertex format for sending the animated vertices to the graphics backend.

This is the same format as the source format, with the CPU-animation data elements removed.

This may only be called after the format has been registered. The return value will have been already registered.

◆ getTexcoord()

const InternalName getTexcoord ( int  n)

Returns the name of the nth texcoord column.

This represents a texture coordinate.

This may only be called after the format has been registered.

◆ getTexcoords()

list getTexcoords ( )

◆ getUnionFormat()

const GeomVertexFormat getUnionFormat ( const GeomVertexFormat  other)

Returns a new GeomVertexFormat that includes all of the columns defined in either this GeomVertexFormat or the other one.

If any column is defined in both formats with different sizes (for instance, texcoord2 vs. texcoord3), the new format will include the larger of the two definitions.

This may only be called after both source formats have been registered. The return value will also have been already registered.

◆ getV3()

static const GeomVertexFormat getV3 ( )
static

◆ getV3c4()

static const GeomVertexFormat getV3c4 ( )
static

◆ getV3c4t2()

static const GeomVertexFormat getV3c4t2 ( )
static

Returns a standard vertex format with a 2-component texture coordinate pair, a 4-component color, and a 3-component vertex position.

◆ getV3cp()

static const GeomVertexFormat getV3cp ( )
static

◆ getV3cpt2()

static const GeomVertexFormat getV3cpt2 ( )
static

Returns a standard vertex format with a 2-component texture coordinate pair, a packed color, and a 3-component vertex position.

◆ getV3n3()

static const GeomVertexFormat getV3n3 ( )
static

Returns a standard vertex format with a 3-component normal and a 3-component vertex position.

◆ getV3n3c4()

static const GeomVertexFormat getV3n3c4 ( )
static

Returns a standard vertex format with a 4-component color, a 3-component normal, and a 3-component vertex position.

◆ getV3n3c4t2()

static const GeomVertexFormat getV3n3c4t2 ( )
static

Returns a standard vertex format with a 2-component texture coordinate pair, a 4-component color, a 3-component normal, and a 3-component vertex position.

◆ getV3n3cp()

static const GeomVertexFormat getV3n3cp ( )
static

Returns a standard vertex format with a packed color, a 3-component normal, and a 3-component vertex position.

◆ getV3n3cpt2()

static const GeomVertexFormat getV3n3cpt2 ( )
static

Returns a standard vertex format with a 2-component texture coordinate pair, a packed color, a 3-component normal, and a 3-component vertex position.

◆ getV3n3t2()

static const GeomVertexFormat getV3n3t2 ( )
static

Returns a standard vertex format with a 2-component texture coordinate pair, a 3-component normal, and a 3-component vertex position.

◆ getV3t2()

static const GeomVertexFormat getV3t2 ( )
static

Returns a standard vertex format with a 2-component texture coordinate pair and a 3-component vertex position.

◆ getVector()

const InternalName getVector ( int  n)

Returns the name of the nth vector column.

This represents a directional vector, which should be transformed by any spatial transform matrix as a vector.

This may only be called after the format has been registered.

◆ getVectors()

list getVectors ( )

◆ hasColumn()

bool hasColumn ( const InternalName  name)

Returns true if the format has the named column, false otherwise.

◆ insertArray()

insertArray ( int  array,
const GeomVertexArrayFormat  array_format 
)

Adds the indicated array definition to the list of arrays at the indicated position.

This works just like add_array(), except that you can specify which array index the new array should have.

This may not be called once the format has been registered.

◆ isRegistered()

bool isRegistered ( )

Returns true if this format has been registered, false if it has not.

It may not be used for a Geom until it has been registered, but once registered, it may no longer be modified.

◆ maybeAlignColumnsForAnimation()

maybeAlignColumnsForAnimation ( )

Calls align_columns_for_animation() if this format's AnimationSpec indicates that it contains animated vertices, and if vertex-animation- align-16 is true.

◆ modifyArray()

GeomVertexArrayFormat modifyArray ( int  array)

Returns a modifiable pointer to the indicated array.

This means duplicating it if it is shared or registered.

This may not be called once the format has been registered.

◆ operator=()

GeomVertexFormat operator= ( const GeomVertexFormat  copy)

◆ output()

output ( Ostream  out)

◆ packColumns()

packColumns ( )

Removes wasted space between columns.

◆ registerFormat() [1/2]

static const GeomVertexFormat registerFormat ( const GeomVertexArrayFormat  format)
static

This flavor of register_format() implicitly creates a one-array vertex format from the array definition.

◆ registerFormat() [2/2]

static const GeomVertexFormat registerFormat ( const GeomVertexFormat  format)
static

Adds the indicated format to the registry, if there is not an equivalent format already there; in either case, returns the pointer to the equivalent format now in the registry.

This must be called before a format may be used in a Geom. After this call, you should discard the original pointer you passed in (which may or may not now be invalid) and let its reference count decrement normally; you should use only the returned value from this point on.

◆ removeArray()

removeArray ( int  array)

Removes the nth array from the format.

This may not be called once the format has been registered.

◆ removeColumn()

removeColumn ( const InternalName  name,
bool  keep_empty_array 
)

Removes the named column from the format, from whichever array it exists in.

If there are other columns remaining in the array, the array is left with a gap where the column used to be; if this was the only column in the array, the array is removed (unless keep_empty_array is true).

This may not be called once the format has been registered.

◆ removeEmptyArrays()

removeEmptyArrays ( )

Removes the arrays that define no columns.

This may not be called once the format has been registered.

◆ setAnimation()

setAnimation ( const GeomVertexAnimationSpec  animation)

Resets the GeomVertexAnimationSpec that indicates how this format's vertices are set up for animation.

You should also, of course, change the columns in the tables accordingly.

This may not be called once the format has been registered.

◆ setArray()

setArray ( int  array,
const GeomVertexArrayFormat  format 
)

Replaces the definition of the indicated array.

This may not be called once the format has been registered.

◆ unref()

bool unref ( )

This method overrides ReferenceCount::unref() to unregister the object when its reference count goes to zero.

◆ write()

write ( Ostream  out,
int  indent_level 
)

◆ writeWithData()

writeWithData ( Ostream  out,
int  indent_level,
const GeomVertexData  data 
)

Member Data Documentation

◆ animation

const GeomVertexAnimationSpec animation

Returns the GeomVertexAnimationSpec that indicates how this format's vertices are set up for animation.

◆ arrays

const GeomVertexArrayFormat arrays[]

◆ columns

const GeomVertexColumn columns[]

We also define this as a mapping interface, for lookups by name.

◆ points

const InternalName points[]

◆ registered

bool registered

Returns true if this format has been registered, false if it has not.

It may not be used for a Geom until it has been registered, but once registered, it may no longer be modified.

◆ vectors

const InternalName vectors[]