Panda3D
|
This class defines the physical layout of the vertex data stored within a Geom. More...
Public Types | |
enum | AnimationType { ATNone = 0, ATPanda = 1, ATHardware = 2 } |
enum | Contents { COther = 0, CPoint = 1, CClipPoint = 2, CVector = 3, CTexcoord = 4, CColor = 5, CIndex = 6, CMorphDelta = 7 } |
enum | GeomRendering { GRIndexedPoint = 1, GRIndexedOther = 65536, GRIndexedBits = 65537, GRPoint = 2, GRPointUniformSize = 4, GRPerPointSize = 8, GRPointPerspective = 16, GRPointAspectRatio = 32, GRPointScale = 64, GRPointRotate = 128, GRPointSprite = 256, GRPointSpriteTexMatrix = 512, GRPointBits = 1022, GRTriangleStrip = 1024, GRTriangleFan = 2048, GRLineStrip = 4096, GRCompositeBits = 7168, GRFlatFirstVertex = 8192, GRFlatLastVertex = 16384, GRShadeModelBits = 24576, GRTexcoordLightVector = 32768 } |
enum | NumericType { NTUint8 = 0, NTUint16 = 1, NTUint32 = 2, NTPackedDcba = 3, NTPackedDabc = 4, NTFloat32 = 5 } |
enum | PrimitiveType { PTNone = 0, PTPolygons = 1, PTLines = 2, PTPoints = 3 } |
enum | ShadeModel { SMUniform = 0, SMSmooth = 1, SMFlatFirstVertex = 2, SMFlatLastVertex = 3 } |
enum | UsageHint { UHClient = 0, UHStream = 1, UHDynamic = 2, UHStatic = 3, UHUnspecified = 4 } |
Public Member Functions | |
GeomVertexFormat () | |
GeomVertexFormat (GeomVertexArrayFormat const array_format) | |
GeomVertexFormat (GeomVertexFormat const copy) | |
int | addArray (GeomVertexArrayFormat const array_format) |
Adds the indicated array definition to the list of arrays included within this vertex format definition. | |
clearArrays () | |
Removes all of the array definitions from the format and starts over. | |
string | encodeToBamStream () |
Converts the TypedWritable object into a single stream of data using a BamWriter, and returns that data as a string string. | |
bool | encodeToBamStream (basic_stringchar data, BamWriter writer) |
Converts the TypedWritable object into a single stream of data using a BamWriter, and stores that data in the indicated string. | |
bool | encodeToBamStream (basic_stringchar data) |
Converts the TypedWritable object into a single stream of data using a BamWriter, and stores that data in the indicated string. | |
GeomVertexAnimationSpec const | getAnimation () |
Returns the GeomVertexAnimationSpec that indicates how this format's vertices are set up for animation. | |
GeomVertexArrayFormat const | getArray (int array) |
Returns the description of the nth array used by the format. | |
list | getArrays () |
int | getArrayWith (InternalName const name) |
Returns the index number of the array with the indicated column, or -1 if no arrays contained that name. | |
int | getArrayWith (int i) |
Returns the index number of the array with the ith column. | |
UpdateSeq | getBamModified () |
Returns the current bam_modified counter. | |
GeomVertexColumn const | getColumn (InternalName const name) |
Returns the specification with the indicated name, or NULL if the name is not used. | |
GeomVertexColumn const | getColumn (int i) |
Returns the ith column of the specification, across all arrays. | |
list | getColumns () |
InternalName const | getMorphBase (int n) |
Returns the name of the base column that the nth morph modifies. | |
list | getMorphBases () |
InternalName const | getMorphDelta (int n) |
Returns the name of the column that defines the nth morph. | |
list | getMorphDeltas () |
InternalName const | getMorphSlider (int n) |
Returns the slider name associated with the nth morph column. | |
list | getMorphSliders () |
int | getNumArrays () |
Returns the number of individual arrays required by the format. | |
int | getNumColumns () |
Returns the total number of different columns in the specification, across all arrays. | |
int | getNumMorphs () |
Returns the number of columns within the format that represent morph deltas. | |
int | getNumPoints () |
Returns the number of columns within the format that represent points in space. | |
int | getNumTexcoords () |
Returns the number of columns within the format that represent texture coordinates. | |
int | getNumVectors () |
Returns the number of columns within the format that represent directional vectors. | |
InternalName const | getPoint (int n) |
Returns the name of the nth point column. | |
list | getPoints () |
GeomVertexFormat const | getPostAnimatedFormat () |
Returns a suitable vertex format for sending the animated vertices to the graphics backend. | |
int | getRefCount () |
Returns the current reference count. | |
InternalName const | getTexcoord (int n) |
Returns the name of the nth texcoord column. | |
list | getTexcoords () |
TypeHandle | getType () |
int | getTypeIndex () |
Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. | |
GeomVertexFormat const | getUnionFormat (GeomVertexFormat const other) |
Returns a new GeomVertexFormat that includes all of the columns defined in either this GeomVertexFormat or the other one. | |
InternalName const | getVector (int n) |
Returns the name of the nth vector column. | |
list | getVectors () |
bool | hasColumn (InternalName const name) |
Returns true if the format has the named column, false otherwise. | |
insertArray (int array, GeomVertexArrayFormat const array_format) | |
Adds the indicated array definition to the list of arrays at the indicated position. | |
bool | isExactType (TypeHandle handle) |
Returns true if the current object is the indicated type exactly. | |
bool | isOfType (TypeHandle handle) |
Returns true if the current object is or derives from the indicated type. | |
bool | isRegistered () |
Returns true if this format has been registered, false if it has not. | |
markBamModified () | |
Increments the bam_modified counter, so that this object will be invalidated and retransmitted on any open bam streams. | |
GeomVertexArrayFormat | modifyArray (int array) |
Returns a modifiable pointer to the indicated array. | |
GeomVertexFormat | operator= (GeomVertexFormat const copy) |
output (ostream out) | |
packColumns () | |
Removes wasted space between columns. | |
PyObject | reduce (PyObject self) |
This special Python method is implement to provide support for the pickle module. | |
PyObject | reducePersist (PyObject self, PyObject pickler) |
This special Python method is implement to provide support for the pickle module. | |
ref () | |
Explicitly increments the reference count. | |
removeArray (int array) | |
Removes the nth array from the format. | |
removeColumn (InternalName const name) | |
Removes the named column from the format, from whichever array it exists in. | |
setAnimation (GeomVertexAnimationSpec const animation) | |
Resets the GeomVertexAnimationSpec that indicates how this format's vertices are set up for animation. | |
setArray (int array, GeomVertexArrayFormat const format) | |
Replaces the definition of the indicated array. | |
bool | testRefCountIntegrity () |
Does some easy checks to make sure that the reference count isn't completely bogus. | |
bool | testRefCountNonzero () |
Does some easy checks to make sure that the reference count isn't zero, or completely bogus. | |
bool | unref () |
This method overrides ReferenceCount.unref() to unregister the object when its reference count goes to zero. | |
write (ostream out) | |
write (ostream out, int indent_level) | |
writeWithData (ostream out, int indent_level, GeomVertexData const data) | |
Static Public Member Functions | |
static TypedWritableReferenceCount | decodeFromBamStream (string 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. | |
static TypedWritableReferenceCount | decodeFromBamStream (string data) |
Reads the string created by a previous call to encode_to_bam_stream(), and extracts and returns the single object on that string. | |
static TypeHandle | getClassType () |
static GeomVertexFormat const | getV3 () |
Returns a standard vertex format with just a 3-component vertex position. | |
static GeomVertexFormat const | getV3c4 () |
Returns a standard vertex format with a 4-component color and a 3-component vertex position. | |
static GeomVertexFormat const | getV3c4t2 () |
Returns a standard vertex format with a 2-component texture coordinate pair, a 4-component color, and a 3-component vertex position. | |
static GeomVertexFormat const | getV3cp () |
Returns a standard vertex format with a packed color and a 3-component vertex position. | |
static GeomVertexFormat const | getV3cpt2 () |
Returns a standard vertex format with a 2-component texture coordinate pair, a packed color, and a 3-component vertex position. | |
static GeomVertexFormat const | getV3n3 () |
Returns a standard vertex format with a 3-component normal and a 3-component vertex position. | |
static GeomVertexFormat const | getV3n3c4 () |
Returns a standard vertex format with a 4-component color, a 3-component normal, and a 3-component vertex position. | |
static GeomVertexFormat const | 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. | |
static GeomVertexFormat const | getV3n3cp () |
Returns a standard vertex format with a packed color, a 3-component normal, and a 3-component vertex position. | |
static GeomVertexFormat const | 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. | |
static GeomVertexFormat const | getV3n3t2 () |
Returns a standard vertex format with a 2-component texture coordinate pair, a 3-component normal, and a 3-component vertex position. | |
static GeomVertexFormat const | getV3t2 () |
Returns a standard vertex format with a 2-component texture coordinate pair and a 3-component vertex position. | |
static GeomVertexFormat const | registerFormat (GeomVertexArrayFormat const format) |
This flavor of register_format() implicitly creates a one-array vertex format from the array definition. | |
static GeomVertexFormat const | registerFormat (GeomVertexFormat const 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. |
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.
enum AnimationType [inherited] |
enum Contents [inherited] |
enum GeomRendering [inherited] |
enum NumericType [inherited] |
enum PrimitiveType [inherited] |
enum ShadeModel [inherited] |
enum UsageHint [inherited] |
GeomVertexFormat | ( | ) |
GeomVertexFormat | ( | GeomVertexArrayFormat const | array_format | ) |
GeomVertexFormat | ( | GeomVertexFormat const | copy | ) |
int addArray | ( | GeomVertexArrayFormat const | 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.
clearArrays | ( | ) |
Removes all of the array definitions from the format and starts over.
This may not be called once the format has been registered.
static TypedWritableReferenceCount decodeFromBamStream | ( | string | data, |
BamReader | reader | ||
) | [static, inherited] |
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.
This method is intended to replace decode_raw_from_bam_stream() when you know the stream in question returns an object of type TypedWritableReferenceCount, allowing for easier reference count management. Note that the caller is still responsible for maintaining the reference count on the return value.
static TypedWritableReferenceCount decodeFromBamStream | ( | string | data | ) | [static, inherited] |
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.
This method is intended to replace decode_raw_from_bam_stream() when you know the stream in question returns an object of type TypedWritableReferenceCount, allowing for easier reference count management. Note that the caller is still responsible for maintaining the reference count on the return value.
string encodeToBamStream | ( | ) | [inherited] |
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.
This is a convenience method particularly useful for cases when you are only serializing a single object. If you have many objects to process, it is more efficient to use the same BamWriter to serialize all of them together.
bool encodeToBamStream | ( | basic_stringchar | data, |
BamWriter | writer | ||
) | [inherited] |
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.
This is a convenience method particularly useful for cases when you are only serializing a single object. If you have many objects to process, it is more efficient to use the same BamWriter to serialize all of them together.
bool encodeToBamStream | ( | basic_stringchar | data | ) | [inherited] |
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.
This is a convenience method particularly useful for cases when you are only serializing a single object. If you have many objects to process, it is more efficient to use the same BamWriter to serialize all of them together.
GeomVertexAnimationSpec const getAnimation | ( | ) |
Returns the GeomVertexAnimationSpec that indicates how this format's vertices are set up for animation.
GeomVertexArrayFormat const getArray | ( | int | array | ) |
Returns the description of the nth array used by the format.
list getArrays | ( | ) |
int getArrayWith | ( | InternalName const | 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.
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.
UpdateSeq getBamModified | ( | ) | [inherited] |
Returns the current bam_modified counter.
This counter is normally incremented automatically whenever the object is modified.
static TypeHandle getClassType | ( | ) | [static] |
Reimplemented from TypedWritableReferenceCount.
GeomVertexColumn const getColumn | ( | InternalName const | 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.
GeomVertexColumn const getColumn | ( | int | i | ) |
Returns the ith column of the specification, across all arrays.
list getColumns | ( | ) |
InternalName const 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.
list getMorphBases | ( | ) |
InternalName const 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.
list getMorphDeltas | ( | ) |
InternalName const 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.
list getMorphSliders | ( | ) |
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.
int getNumColumns | ( | ) |
Returns the total number of different columns in the specification, across all arrays.
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.
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.
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.
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.
InternalName const 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.
list getPoints | ( | ) |
GeomVertexFormat const 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.
int getRefCount | ( | ) | [inherited] |
Returns the current reference count.
InternalName const 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.
list getTexcoords | ( | ) |
TypeHandle getType | ( | ) | [inherited] |
Reimplemented in AnimChannelBase.
int getTypeIndex | ( | ) | [inherited] |
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().
GeomVertexFormat const getUnionFormat | ( | GeomVertexFormat const | 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.
static GeomVertexFormat const getV3 | ( | ) | [static] |
Returns a standard vertex format with just a 3-component vertex position.
static GeomVertexFormat const getV3c4 | ( | ) | [static] |
Returns a standard vertex format with a 4-component color and a 3-component vertex position.
static GeomVertexFormat const getV3c4t2 | ( | ) | [static] |
Returns a standard vertex format with a 2-component texture coordinate pair, a 4-component color, and a 3-component vertex position.
static GeomVertexFormat const getV3cp | ( | ) | [static] |
Returns a standard vertex format with a packed color and a 3-component vertex position.
static GeomVertexFormat const getV3cpt2 | ( | ) | [static] |
Returns a standard vertex format with a 2-component texture coordinate pair, a packed color, and a 3-component vertex position.
static GeomVertexFormat const getV3n3 | ( | ) | [static] |
Returns a standard vertex format with a 3-component normal and a 3-component vertex position.
static GeomVertexFormat const getV3n3c4 | ( | ) | [static] |
Returns a standard vertex format with a 4-component color, a 3-component normal, and a 3-component vertex position.
static GeomVertexFormat const 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.
static GeomVertexFormat const getV3n3cp | ( | ) | [static] |
Returns a standard vertex format with a packed color, a 3-component normal, and a 3-component vertex position.
static GeomVertexFormat const 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.
static GeomVertexFormat const getV3n3t2 | ( | ) | [static] |
Returns a standard vertex format with a 2-component texture coordinate pair, a 3-component normal, and a 3-component vertex position.
static GeomVertexFormat const getV3t2 | ( | ) | [static] |
Returns a standard vertex format with a 2-component texture coordinate pair and a 3-component vertex position.
InternalName const 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.
list getVectors | ( | ) |
bool hasColumn | ( | InternalName const | name | ) |
Returns true if the format has the named column, false otherwise.
insertArray | ( | int | array, |
GeomVertexArrayFormat const | 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.
bool isExactType | ( | TypeHandle | handle | ) | [inherited] |
Returns true if the current object is the indicated type exactly.
bool isOfType | ( | TypeHandle | handle | ) | [inherited] |
Returns true if the current object is or derives from the indicated type.
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.
markBamModified | ( | ) | [inherited] |
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.
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.
GeomVertexFormat operator= | ( | GeomVertexFormat const | copy | ) |
output | ( | ostream | out | ) |
packColumns | ( | ) |
Removes wasted space between columns.
PyObject reduce | ( | PyObject | self | ) | [inherited] |
This special Python method is implement to provide support for the pickle module.
This hooks into the native pickle and cPickle modules, but it cannot properly handle self-referential BAM objects.
PyObject reducePersist | ( | PyObject | self, |
PyObject | pickler | ||
) | [inherited] |
This special Python method is implement to provide support for the pickle module.
This is similar to __reduce__, but it provides additional support for the missing persistent-state object needed to properly support self-referential BAM objects written to the pickle stream. This hooks into the pickle and cPickle modules implemented in direct/src/stdpy.
ref | ( | ) | [inherited] |
Explicitly increments the reference count.
User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically.
This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it.
static GeomVertexFormat const registerFormat | ( | GeomVertexArrayFormat const | format | ) | [static] |
This flavor of register_format() implicitly creates a one-array vertex format from the array definition.
static GeomVertexFormat const registerFormat | ( | GeomVertexFormat const | 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 | ( | int | array | ) |
Removes the nth array from the format.
This may not be called once the format has been registered.
removeColumn | ( | InternalName const | name | ) |
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.
This may not be called once the format has been registered.
setAnimation | ( | GeomVertexAnimationSpec const | 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 | ( | int | array, |
GeomVertexArrayFormat const | format | ||
) |
Replaces the definition of the indicated array.
This may not be called once the format has been registered.
bool testRefCountIntegrity | ( | ) | [inherited] |
Does some easy checks to make sure that the reference count isn't completely bogus.
Returns true if ok, false otherwise.
Reimplemented in NodeReferenceCount, CachedTypedWritableReferenceCount, and NodeCachedReferenceCount.
bool testRefCountNonzero | ( | ) | [inherited] |
Does some easy checks to make sure that the reference count isn't zero, or completely bogus.
Returns true if ok, false otherwise.
bool unref | ( | ) |
This method overrides ReferenceCount.unref() to unregister the object when its reference count goes to zero.
Reimplemented from ReferenceCount.
write | ( | ostream | out | ) |
writeWithData | ( | ostream | out, |
int | indent_level, | ||
GeomVertexData const | data | ||
) |