Class Mesh
A mesh represents geometry with a single material.
Implements
Inherited Members
Namespace: SharpAssimp
Assembly: SharpAssimp.dll
Syntax
public sealed class Mesh : IMarshalable<Mesh, AiMesh>
Constructors
| Edit this page View SourceMesh()
Constructs a new instance of the Mesh class.
Declaration
public Mesh()
Mesh(PrimitiveType)
Constructs a new instance of the Mesh class.
Declaration
public Mesh(PrimitiveType primType)
Parameters
| Type | Name | Description |
|---|---|---|
| PrimitiveType | primType | Primitive types contained in the mesh. |
Mesh(string)
Constructs a new instance of the Mesh class.
Declaration
public Mesh(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Name of the mesh. |
Mesh(string, PrimitiveType)
Constructs a new instance of the Mesh class.
Declaration
public Mesh(string name, PrimitiveType primType)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Name of the mesh |
| PrimitiveType | primType | Primitive types contained in the mesh. |
Properties
| Edit this page View SourceBiTangents
Gets the vertex bitangent list.
Declaration
public List<Vector3> BiTangents { get; }
Property Value
| Type | Description |
|---|---|
| List<Vector3> |
BoneCount
Gets the number of bones that influence this mesh.
Declaration
public int BoneCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
Bones
Gets the bones that influence this mesh.
Declaration
public List<Bone> Bones { get; }
Property Value
| Type | Description |
|---|---|
| List<Bone> |
BoundingBox
Gets or sets the axis aligned bounding box that contains the extents of the mesh.
Declaration
public BoundingBox BoundingBox { get; set; }
Property Value
| Type | Description |
|---|---|
| BoundingBox |
FaceCount
Gets the number of faces contained in the mesh.
Declaration
public int FaceCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
Faces
Gets the mesh's faces. Each face will contain indices to the vertices.
Declaration
public List<Face> Faces { get; }
Property Value
| Type | Description |
|---|---|
| List<Face> |
HasBones
Gets if this mesh has bones.
Declaration
public bool HasBones { get; }
Property Value
| Type | Description |
|---|---|
| bool |
HasFaces
Gets if the mesh contains faces. If no special scene flags are set, this should always return true.
Declaration
public bool HasFaces { get; }
Property Value
| Type | Description |
|---|---|
| bool |
HasMeshAnimationAttachments
Gets if this mesh has mesh animation attachments.
Declaration
public bool HasMeshAnimationAttachments { get; }
Property Value
| Type | Description |
|---|---|
| bool |
HasNormals
Gets if the mesh as normals. If it does exist, the count should be the same as the vertex count.
Declaration
public bool HasNormals { get; }
Property Value
| Type | Description |
|---|---|
| bool |
HasTangentBasis
Gets if the mesh has tangents and bitangents. It is not possible for one to be without the other. If it does exist, the count should be the same as the vertex count.
Declaration
public bool HasTangentBasis { get; }
Property Value
| Type | Description |
|---|---|
| bool |
HasVertices
Gets if the mesh has a vertex array. This should always return true provided no special scene flags are set.
Declaration
public bool HasVertices { get; }
Property Value
| Type | Description |
|---|---|
| bool |
MaterialIndex
Gets or sets the index of the material associated with this mesh.
Declaration
public int MaterialIndex { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
MeshAnimationAttachmentCount
Gets the number of mesh animation attachments that influence this mesh.
Declaration
public int MeshAnimationAttachmentCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
MeshAnimationAttachments
Gets the mesh animation attachments that influence this mesh.
Declaration
public List<MeshAnimationAttachment> MeshAnimationAttachments { get; }
Property Value
| Type | Description |
|---|---|
| List<MeshAnimationAttachment> |
MorphMethod
Gets or sets the morph method used when animation attachments are used.
Declaration
public MeshMorphingMethod MorphMethod { get; set; }
Property Value
| Type | Description |
|---|---|
| MeshMorphingMethod |
Name
Gets or sets the mesh name. This tends to be used when formats name nodes and meshes independently, vertex animations refer to meshes by their names, or importers split meshes up, each mesh will reference the same (dummy) name.
Declaration
public string Name { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Normals
Gets the vertex normal list.
Declaration
public List<Vector3> Normals { get; }
Property Value
| Type | Description |
|---|---|
| List<Vector3> |
PrimitiveType
Gets or sets the primitive type. This may contain more than one type unless if SortByPrimitiveType option is not set.
Declaration
public PrimitiveType PrimitiveType { get; set; }
Property Value
| Type | Description |
|---|---|
| PrimitiveType |
Tangents
Gets the vertex tangent list.
Declaration
public List<Vector3> Tangents { get; }
Property Value
| Type | Description |
|---|---|
| List<Vector3> |
TextureCoordinateChannelCount
Gets the number of valid texture coordinate channels contained in the mesh (list is not empty/not null). This can be a value between zero and the maximum texture coordinate count. Each individual channel should be the size of VertexCount.
Declaration
public int TextureCoordinateChannelCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
TextureCoordinateChannels
Gets the array that contains each texture coordinate channel, by default all are lists of zero (but can be set to null). Each index in the array corresponds to the texture coordinate channel. The length of the array corresponds to Assimp's maximum UV channel limit.
Declaration
public List<Vector3>[] TextureCoordinateChannels { get; }
Property Value
| Type | Description |
|---|---|
| List<Vector3>[] |
UVComponentCount
Gets the array that contains the count of UV(W) components for each texture coordinate channel, usually 2 (UV) or 3 (UVW). A component value of zero means the texture coordinate channel does not exist. The channel index (index in the array) corresponds to the texture coordinate channel index.
Declaration
public int[] UVComponentCount { get; }
Property Value
| Type | Description |
|---|---|
| int[] |
VertexColorChannelCount
Gets the number of valid vertex color channels contained in the mesh (list is not empty/not null). This can be a value between zero and the maximum vertex color count. Each individual channel should be the size of VertexCount.
Declaration
public int VertexColorChannelCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
VertexColorChannels
Gets the array that contains each vertex color channels, by default all are lists of zero (but can be set to null). Each index in the array corresponds to the texture coordinate channel. The length of the array corresponds to Assimp's maximum vertex color channel limit.
Declaration
public List<Vector4>[] VertexColorChannels { get; }
Property Value
| Type | Description |
|---|---|
| List<Vector4>[] |
VertexCount
Gets the number of vertices in this mesh. This is the count that all per-vertex lists should be the size of.
Declaration
public int VertexCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
Vertices
Gets the vertex position list.
Declaration
public List<Vector3> Vertices { get; }
Property Value
| Type | Description |
|---|---|
| List<Vector3> |
Methods
| Edit this page View SourceFreeNative(nint, bool)
Frees unmanaged memory created by ToNative(nint, out Native).
Declaration
public static void FreeNative(nint nativeValue, bool freeNative)
Parameters
| Type | Name | Description |
|---|---|---|
| nint | nativeValue | Native value to free |
| bool | freeNative | True if the unmanaged memory should be freed, false otherwise. |
GetIndices()
Convenience method for accumulating all face indices into a single index array.
Declaration
public IEnumerable<int> GetIndices()
Returns
| Type | Description |
|---|---|
| IEnumerable<int> | int index array |
GetShortIndices()
Convenience method for accumulating all face indices into a single index array.
Declaration
public IEnumerable<short> GetShortIndices()
Returns
| Type | Description |
|---|---|
| IEnumerable<short> | short index enumerable |
GetUnsignedIndices()
Convenience method for accumulating all face indices into a single index array as unsigned integers (the default from Assimp, if you need them).
Declaration
public IEnumerable<uint> GetUnsignedIndices()
Returns
| Type | Description |
|---|---|
| IEnumerable<uint> | uint index enumerable |
HasTextureCoords(int)
Checks if the mesh has texture coordinates for the specified channel. This returns false if the list is null or empty. The channel, if it exists, should contain the same number of entries as VertexCount.
Declaration
public bool HasTextureCoords(int channelIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| int | channelIndex | Channel index |
Returns
| Type | Description |
|---|---|
| bool | True if texture coordinates are present in the channel. |
HasVertexColors(int)
Checks if the mesh has vertex colors for the specified channel. This returns false if the list is null or empty. The channel, if it exists, should contain the same number of entries as VertexCount.
Declaration
public bool HasVertexColors(int channelIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| int | channelIndex | Channel index |
Returns
| Type | Description |
|---|---|
| bool | True if vertex colors are present in the channel. |
SetIndices(int[], int)
Convienence method for setting this meshe's face list from an index buffer.
Declaration
public bool SetIndices(int[] indices, int indicesPerFace)
Parameters
| Type | Name | Description |
|---|---|---|
| int[] | indices | Index buffer |
| int | indicesPerFace | Indices per face |
Returns
| Type | Description |
|---|---|
| bool | True if the operation succeeded, false otherwise (e.g. not enough data) |