public VertexElementInfo(CommonVertexSemantic semantic, int arrayIndex, CommonFormat format, int offset, int stride)
 {
     CommonSemantic = semantic;
     Semantic       = semantic.ToString();
     ArrayIndex     = arrayIndex;
     Format         = format;
     Offset         = offset;
     Stride         = stride;
 }
 public VertexElementInfo(string semantic, int arrayIndex, CommonFormat format, int offset, int stride)
 {
     CommonSemantic = CommonVertexSemantic.Undefined;
     Semantic       = semantic;
     ArrayIndex     = arrayIndex;
     Format         = format;
     Offset         = offset;
     Stride         = stride;
 }
        private static T[] ExtractVertexElements <T>(IFlexibleModelVertexSet vertexSet, CommonVertexSemantic semantic, CommonFormat expectedFormat, Func <IntPtr, T> decode)
        {
            var elementInfo = vertexSet.ElementInfos.FirstOrDefault(x => x.CommonSemantic == semantic);

            if (elementInfo == null)
            {
                return(null);
            }
            if (elementInfo.Format != expectedFormat)
            {
                throw new NotImplementedException($"Only '{expectedFormat}' format is supported for '{typeof(T).Name}' elems at the moment.");
            }

            var arraySubrange = vertexSet.ArraySubranges[elementInfo.ArrayIndex];
            var vertexCount   = arraySubrange.Length / elementInfo.Stride;
            var elements      = new T[vertexCount];
            var pCgVertices   = arraySubrange.RawDataResource.Map() + arraySubrange.StartOffset;
            var pCurrentElem  = pCgVertices + elementInfo.Offset;

            for (int i = 0; i < vertexCount; i++)
            {
                elements[i]   = decode(pCurrentElem);
                pCurrentElem += elementInfo.Stride;
            }
            arraySubrange.RawDataResource.Unmap(false);
            return(elements);
        }