Assimp.Mesh.HasTextureCoords C# (CSharp) Метод

HasTextureCoords() публичный Метод

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.
public HasTextureCoords ( int channelIndex ) : bool
channelIndex int Channel index
Результат bool
        public bool HasTextureCoords(int channelIndex)
        {
            if (channelIndex >= m_texCoords.Length || channelIndex < 0)
                return false;

            List<Vector3D> texCoords = m_texCoords[channelIndex];

            if (texCoords != null)
                return texCoords.Count > 0;

            return false;
        }

Usage Example

        /// <summary>
        /// Gets vertex data from a given <see cref="AssimpMesh"/>.
        /// </summary>
        /// <param name="sceneMesh">The <see cref="AssimpMesh"/> to get vertex information from.</param>
        /// <param name="boneIndexByName">A lookup of bone index by name information.</param>
        /// <returns>An output list of vertices.</returns>
        private Vertex[] GetMeshVertices(AssimpMesh sceneMesh, Dictionary <string, uint> boneIndexByName)
        {
            var positions                = sceneMesh.Vertices;
            var normals                  = sceneMesh.Normals;
            var tangents                 = sceneMesh.Tangents;
            var colors                   = sceneMesh.HasVertexColors(0) ? sceneMesh.VertexColorChannels[0] : null;
            var textureCoordinates       = sceneMesh.HasTextureCoords(0) ? sceneMesh.TextureCoordinateChannels[0] : null;
            var boneWeightsByVertexIndex = GetBoneWeightsByVertexIndex(boneIndexByName, sceneMesh);

            var vertices = new List <Vertex>();

            for (var i = 0; i < positions.Count; i++)
            {
                var position          = positions[i];
                var normal            = normals[i];
                var tangent           = tangents[i];
                var color             = colors?[i];
                var textureCoordinate = textureCoordinates?[i];
                TryGetBoneIndicesAndWeights(boneWeightsByVertexIndex, i, out var boneIndices, out var boneWeights);

                vertices.Add(new Vertex(new Vector3(position.X, position.Y, position.Z),
                                        new Vector3(normal.X, normal.Y, normal.Z),
                                        new Vector3(tangent.X, tangent.Y, tangent.Z),
                                        color != null ? new Color(color.Value.R, color.Value.G, color.Value.B, color.Value.A) : new Color(1.0f, 1.0f, 1.0f, 1.0f),
                                        textureCoordinate != null ? new Vector2(textureCoordinate.Value.X, textureCoordinate.Value.Y) : Vector2.Zero,
                                        new ReadOnlyCollection <uint>(boneIndices),
                                        new ReadOnlyCollection <float>(boneWeights)));
            }

            return(vertices.ToArray());
        }
All Usage Examples Of Assimp.Mesh::HasTextureCoords