from_raw_data method

from_raw_data(, vd, vertices, indices, generate_vertex_mapping)

Create TriMesh from raw data

Returns

The TriMesh instance that encapsulated the input byte array.


@staticmethod
def from_raw_data(vd, vertices, indices, generate_vertex_mapping):
    ...
ParameterTypeDescription
vdaspose.threed.utilities.VertexDeclarationVertex declaration, must contains at least one field.
verticesbytesThe input vertex data, the minimum length of the vertices must be greater or equal to vertex declaration’s size
indiceslistThe triangle indices
generate_vertex_mappingboolGenerate Vertex for each vertex, which is not necessary for just serialization/deserialization.

Remarks

The returned TriMesh will not copy the input byte array for performance, external changes on the array will be reflected to this instance.

Example

The following code shows how to construct a TriMesh from raw bytes, this is useful when build your own 3D format

from aspose.threed.entities import TriMesh
from aspose.threed.utilities import VertexDeclaration, VertexFieldDataType, VertexFieldSemantic

indices = [0, 1, 2 ]
vertices = [                0, 0, 0, 191,                 0, 0, 0, 0,                 0, 0, 0, 191,                 0, 0, 0, 191,                 0, 0, 0, 0,                 0, 0, 0, 63,                 0, 0, 0, 63,                 0, 0, 0, 0,                 0, 0, 0, 63
]
vd = VertexDeclaration()
vd.add_field(VertexFieldDataType.F_VECTOR3, VertexFieldSemantic.POSITION)
triMesh = TriMesh.from_raw_data(vd, vertices, indices, True)

See Also