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

This describes the structure of a single array within a Geom data. See GeomVertexFormat for the parent class which collects together all of the individual GeomVertexArrayFormat objects. More...

Inheritance diagram for GeomVertexArrayFormat:
TypedWritableReferenceCount GeomEnums TypedWritable ReferenceCount TypedObject MemoryBase MemoryBase

Public Member Functions

 __init__ ()
 
 __init__ (const InternalName name0, int num_components0, GeomEnums::NumericType numeric_type0, GeomEnums::Contents contents0)
 
 __init__ (const InternalName name0, int num_components0, GeomEnums::NumericType numeric_type0, GeomEnums::Contents contents0, const InternalName name1, int num_components1, GeomEnums::NumericType numeric_type1, GeomEnums::Contents contents1)
 
 __init__ (const InternalName name0, int num_components0, GeomEnums::NumericType numeric_type0, GeomEnums::Contents contents0, const InternalName name1, int num_components1, GeomEnums::NumericType numeric_type1, GeomEnums::Contents contents1, const InternalName name2, int num_components2, GeomEnums::NumericType numeric_type2, GeomEnums::Contents contents2)
 
 __init__ (const InternalName name0, int num_components0, GeomEnums::NumericType numeric_type0, GeomEnums::Contents contents0, const InternalName name1, int num_components1, GeomEnums::NumericType numeric_type1, GeomEnums::Contents contents1, const InternalName name2, int num_components2, GeomEnums::NumericType numeric_type2, GeomEnums::Contents contents2, const InternalName name3, int num_components3, GeomEnums::NumericType numeric_type3, GeomEnums::Contents contents3)
 
 __init__ (const GeomVertexArrayFormat copy)
 
int addColumn (const InternalName name, int num_components, GeomEnums::NumericType numeric_type, GeomEnums::Contents contents, int start, int column_alignment)
 Adds a new column to the specification. This is a table of per-vertex floating-point numbers such as "vertex" or "normal"; you must specify where in each record the table starts, and how many components (dimensions) exist per vertex. More...
 
int addColumn (const GeomVertexColumn column)
 Adds a new column to the specification. This is a table of per-vertex floating-point numbers such as "vertex" or "normal"; you must specify where in each record the table starts, and how many components (dimensions) exist per vertex. 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...
 
 clearColumns ()
 Removes all columns previously added, sets the stride to zero, and prepares to start over. More...
 
int countUnusedSpace ()
 Returns the number of bytes per row that are not assigned to any 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 array. More...
 
const GeomVertexColumn getColumn (int start_byte, int num_bytes)
 Returns the first specification that overlaps with any of the indicated bytes in the range, or NULL if none do. More...
 
list getColumns ()
 
int getDivisor ()
 Returns the divisor attribute for the data in this array. If 0, it contains per-vertex data. If 1, it contains per-instance data. If higher than 1, the read row is advanced for each n instances. More...
 
str getFormatString (bool pad)
 Returns a string with format codes representing the exact memory layout of the columns in memory, as understood by Python's struct module. If pad is true, extra padding bytes are added to the end as 'x' characters as needed. More...
 
int getNumColumns ()
 Returns the number of different columns in the array. More...
 
int getPadTo ()
 Returns the byte divisor to which the data record must be padded to meet hardware limitations. For instance, if this is 4, the stride will be automatically rounded up to the next multiple of 4 bytes. This value is automatically increased as needed to ensure the individual numeric components in the array are word-aligned. More...
 
int getStride ()
 Returns the total number of bytes reserved in the array for each vertex. More...
 
int getTotalBytes ()
 Returns the total number of bytes used by the data types within the format, including gaps between elements. More...
 
bool hasColumn (const InternalName name)
 Returns true if the array has the named column, false otherwise. More...
 
bool isDataSubsetOf (const GeomVertexArrayFormat other)
 Returns true if all of the fields in this array format are also present and equivalent in the other array format, and in the same byte positions, and the stride is the same. That is, true if this format can share the same data pointer as the other format (with possibly some unused gaps). More...
 
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. More...
 
GeomVertexArrayFormat operator= (const GeomVertexArrayFormat copy)
 
 output (Ostream out)
 
 packColumns ()
 Removes wasted space between columns. More...
 
 removeColumn (const InternalName name)
 Removes the column with the indicated name, if any. This leaves a gap in the byte structure. More...
 
 setDivisor (int divisor)
 Set this to 0 to indicate that this array contains per-vertex data, or to 1 to indicate that it contains per-instance data. If higher than 1, the read row is advanced for each n instances. More...
 
 setPadTo (int pad_to)
 Explicitly sets the byte divisor to which the data record must be padded to meet hardware limitations. See get_pad_to(). Normally it is not necessary to call this unless you have some specific requirements for row-to-row data alignment. Note that this value may be automatically increased at each subsequent call to add_column(). More...
 
 setStride (int stride)
 Changes the total number of bytes reserved in the array for each vertex. You may not reduce this below get_total_bytes(), but you may increase it arbitrarily. 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 GeomVertexArrayData array_data)
 
- Public Member Functions inherited from TypedWritable
object __reduce__ ()
 
object __reduce_persist__ (object pickler)
 
str encodeToBamStream ()
 Converts the TypedWritable object into a single stream of data using a BamWriter, and returns that data as a string string. Returns empty string on failure. More...
 
bool encodeToBamStream (String data, BamWriter writer)
 Converts the TypedWritable object into a single stream of data using a BamWriter, and stores that data in the indicated string. Returns true on success, false on failure. More...
 
UpdateSeq getBamModified ()
 Returns the current bam_modified counter. This counter is normally incremented automatically whenever the object is modified. More...
 
 markBamModified ()
 Increments the bam_modified counter, so that this object will be invalidated and retransmitted on any open bam streams. This should normally not need to be called by user code; it should be called internally when the object has been changed in a way that legitimately requires its retransmission to any connected clients. More...
 
- Public Member Functions inherited from TypedObject
TypeHandle getType ()
 Derived classes should override this function to return get_class_type(). More...
 
int getTypeIndex ()
 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(). 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. 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. More...
 
bool testRefCountIntegrity ()
 Does some easy checks to make sure that the reference count isn't completely bogus. Returns true if ok, false otherwise. More...
 
bool testRefCountNonzero ()
 Does some easy checks to make sure that the reference count isn't zero, or completely bogus. Returns true if ok, false otherwise. More...
 
bool unref ()
 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.) However, see the helper function unref_delete(). More...
 

Static Public Member Functions

static TypeHandle getClassType ()
 
static const GeomVertexArrayFormat registerFormat (const GeomVertexArrayFormat 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 (str data, BamReader reader)
 Reads the string created by a previous call to encode_to_bam_stream(), and extracts and returns the single object on that string. Returns NULL on error. 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 ()
 

Additional Inherited Members

- Public Types inherited from GeomEnums
enum  AnimationType { AT_none = 0, AT_panda = 1, AT_hardware = 2 }
 The type of animation data that is represented by a particular GeomVertexFormat. More...
 
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
}
 The contents determine the semantic meaning of a numeric value within the vertex data. This is also used to determine what automatic transforms might be applied to the various columns. More...
 
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
}
 This type specifies a number of bits that are used to represent the rendering requirements of a particular Geom, as well as the rendering capabilities of the GSG. The difference between the two indicates whether the Geom needs to be munged for the GSG. More...
 
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
}
 The numeric type determines what physical representation is used to encode a numeric value within the vertex data. More...
 
enum  PrimitiveType {
  PT_none = 0, PT_polygons = 1, PT_lines = 2, PT_points = 3,
  PT_patches = 4
}
 The primitive type represents the core primitive type of a particular GeomPrimitive. It's used for determining what kind of antialiasing should be enabled. More...
 
enum  ShadeModel { SM_uniform = 0, SM_smooth = 1, SM_flat_first_vertex = 2, SM_flat_last_vertex = 3 }
 The shade model specifies whether the per-vertex colors and normals indexed by a given primitive truly represent per-vertex colors and normals, or whether they actually represent per-triangle flat-shaded colors and normals. More...
 
enum  UsageHint {
  UH_client = 0, UH_stream = 1, UH_dynamic = 2, UH_static = 3,
  UH_unspecified = 4
}
 

Detailed Description

This describes the structure of a single array within a Geom data. See GeomVertexFormat for the parent class which collects together all of the individual GeomVertexArrayFormat objects.

A particular array may include any number of standard or user-defined columns. All columns consist of a sequence of one or more numeric values, packed in any of a variety of formats; the semantic meaning of each column is defined in general with its contents member, and in particular by its name. The standard array types used most often are named "vertex", "normal", "texcoord", and "color"; other kinds of data may be piggybacked into the data record simply by choosing a unique name.

Member Function Documentation

◆ __init__() [1/6]

__init__ ( )

◆ __init__() [2/6]

__init__ ( const InternalName  name0,
int  num_components0,
GeomEnums::NumericType  numeric_type0,
GeomEnums::Contents  contents0 
)

◆ __init__() [3/6]

__init__ ( const InternalName  name0,
int  num_components0,
GeomEnums::NumericType  numeric_type0,
GeomEnums::Contents  contents0,
const InternalName  name1,
int  num_components1,
GeomEnums::NumericType  numeric_type1,
GeomEnums::Contents  contents1 
)

◆ __init__() [4/6]

__init__ ( const InternalName  name0,
int  num_components0,
GeomEnums::NumericType  numeric_type0,
GeomEnums::Contents  contents0,
const InternalName  name1,
int  num_components1,
GeomEnums::NumericType  numeric_type1,
GeomEnums::Contents  contents1,
const InternalName  name2,
int  num_components2,
GeomEnums::NumericType  numeric_type2,
GeomEnums::Contents  contents2 
)

◆ __init__() [5/6]

__init__ ( const InternalName  name0,
int  num_components0,
GeomEnums::NumericType  numeric_type0,
GeomEnums::Contents  contents0,
const InternalName  name1,
int  num_components1,
GeomEnums::NumericType  numeric_type1,
GeomEnums::Contents  contents1,
const InternalName  name2,
int  num_components2,
GeomEnums::NumericType  numeric_type2,
GeomEnums::Contents  contents2,
const InternalName  name3,
int  num_components3,
GeomEnums::NumericType  numeric_type3,
GeomEnums::Contents  contents3 
)

◆ __init__() [6/6]

__init__ ( const GeomVertexArrayFormat  copy)

◆ addColumn() [1/2]

int addColumn ( const InternalName  name,
int  num_components,
GeomEnums::NumericType  numeric_type,
GeomEnums::Contents  contents,
int  start,
int  column_alignment 
)

Adds a new column to the specification. This is a table of per-vertex floating-point numbers such as "vertex" or "normal"; you must specify where in each record the table starts, and how many components (dimensions) exist per vertex.

The return value is the index number of the new data type.

◆ addColumn() [2/2]

int addColumn ( const GeomVertexColumn  column)

Adds a new column to the specification. This is a table of per-vertex floating-point numbers such as "vertex" or "normal"; you must specify where in each record the table starts, and how many components (dimensions) exist per vertex.

Adding a column with the same name as a previous type, or that overlaps with one or more previous types, quietly removes the previous type(s).

The return value is the index number of the new data type.

◆ 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).

The caller is responsible for testing vertex_animation_align_16 to decide whether to call this method.

◆ clearColumns()

clearColumns ( )

Removes all columns previously added, sets the stride to zero, and prepares to start over.

◆ countUnusedSpace()

int countUnusedSpace ( )

Returns the number of bytes per row that are not assigned to any column.

◆ getClassType()

static TypeHandle getClassType ( )
static

◆ getColumn() [1/3]

const GeomVertexColumn getColumn ( const InternalName  name)

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

◆ getColumn() [2/3]

const GeomVertexColumn getColumn ( int  i)

Returns the ith column of the array.

◆ getColumn() [3/3]

const GeomVertexColumn getColumn ( int  start_byte,
int  num_bytes 
)

Returns the first specification that overlaps with any of the indicated bytes in the range, or NULL if none do.

◆ getColumns()

list getColumns ( )

◆ getDivisor()

int getDivisor ( )

Returns the divisor attribute for the data in this array. If 0, it contains per-vertex data. If 1, it contains per-instance data. If higher than 1, the read row is advanced for each n instances.

◆ getFormatString()

str getFormatString ( bool  pad)

Returns a string with format codes representing the exact memory layout of the columns in memory, as understood by Python's struct module. If pad is true, extra padding bytes are added to the end as 'x' characters as needed.

◆ getNumColumns()

int getNumColumns ( )

Returns the number of different columns in the array.

◆ getPadTo()

int getPadTo ( )

Returns the byte divisor to which the data record must be padded to meet hardware limitations. For instance, if this is 4, the stride will be automatically rounded up to the next multiple of 4 bytes. This value is automatically increased as needed to ensure the individual numeric components in the array are word-aligned.

◆ getStride()

int getStride ( )

Returns the total number of bytes reserved in the array for each vertex.

◆ getTotalBytes()

int getTotalBytes ( )

Returns the total number of bytes used by the data types within the format, including gaps between elements.

◆ hasColumn()

bool hasColumn ( const InternalName  name)

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

◆ isDataSubsetOf()

bool isDataSubsetOf ( const GeomVertexArrayFormat  other)

Returns true if all of the fields in this array format are also present and equivalent in the other array format, and in the same byte positions, and the stride is the same. That is, true if this format can share the same data pointer as the other format (with possibly some unused gaps).

◆ 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.

◆ operator=()

GeomVertexArrayFormat operator= ( const GeomVertexArrayFormat  copy)

◆ output()

output ( Ostream  out)

◆ packColumns()

packColumns ( )

Removes wasted space between columns.

◆ registerFormat()

static const GeomVertexArrayFormat registerFormat ( const GeomVertexArrayFormat  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 is similar to GeomVertexFormat::register_format(), except that you generally need not call it explicitly. Calling GeomVertexFormat::register_format() automatically registers all of the nested array formats.

◆ removeColumn()

removeColumn ( const InternalName  name)

Removes the column with the indicated name, if any. This leaves a gap in the byte structure.

◆ setDivisor()

setDivisor ( int  divisor)

Set this to 0 to indicate that this array contains per-vertex data, or to 1 to indicate that it contains per-instance data. If higher than 1, the read row is advanced for each n instances.

◆ setPadTo()

setPadTo ( int  pad_to)

Explicitly sets the byte divisor to which the data record must be padded to meet hardware limitations. See get_pad_to(). Normally it is not necessary to call this unless you have some specific requirements for row-to-row data alignment. Note that this value may be automatically increased at each subsequent call to add_column().

◆ setStride()

setStride ( int  stride)

Changes the total number of bytes reserved in the array for each vertex. You may not reduce this below get_total_bytes(), but you may increase it arbitrarily.

◆ 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 GeomVertexArrayData  array_data 
)