Enumerate TriMesh vertexes and get data with custom VertexDeclaration

TriMesh and VertexDeclaration classes are really useful for turning Meshes, with their combinations of vertex element mappings and references modes, into a consistent format. It looks like its intended to be used for serialization/buffer purposes.

I’m curious if this class can be expanded so you can enumerate the Vertexes and get the field values for each vertex.

Example code:

    [Test]
    private void Test_mesh_vertex_declaration()
    {
        var mesh = GenerateTestMesh();  
        
        VertexDeclaration layout = new VertexDeclaration();
        var pos = layout.AddField( VertexFieldDataType.Vector3, VertexFieldSemantic.Position );
        var normal = layout.AddField( VertexFieldDataType.Vector3, VertexFieldSemantic.Normal );
        var uv = layout.AddField( VertexFieldDataType.Vector2, VertexFieldSemantic.UV );
        
        TriMesh triMesh = TriMesh.FromMesh( layout, mesh );

        // Cant do this currently
        foreach ( Vertex vertex in triMesh )
        {
            Vector3 vertexPosition = vertex.GetVector3( pos );
            Vector3 vertexNormal = vertex.GetVector3( normal );
            Vector2 vertexUv = vertex.GetVector2( uv );
        }
    }

@bortos,

Thanks for contacting support.

Can you please share source files along with generated result. Also please share complete working sample project to investigate this issue in details.

This is a feature request not an issue

@bortos,

I have observed your requirements and regret to inform that this is not supported yet. A ticket with ID THREEDNET-661 has been created as in our issue tracking system as a new feature request. We will look into the possibility of implementation of the requested feature. This thread has been associated with this new feature request, so that you can be automatically notified as soon as this issue is resolved.