public static int FloatCountFromFormat(VRTF.ElementFormat format) { switch (format) { case ElementFormat.Float1: return(1); case ElementFormat.Float2: case ElementFormat.UShort2N: case ElementFormat.Short2: return(2); case ElementFormat.Short4: case ElementFormat.Short4N: case ElementFormat.UByte4N: case ElementFormat.UShort4N: case ElementFormat.Float3: return(3); case ElementFormat.ColorUByte4: case ElementFormat.Float4: case ElementFormat.Short4_DropShadow: return(4); default: throw new NotImplementedException(); } }
static float[] GetFloats(VRTF.ElementFormat format, int line, float[] source) { float[] res = new float[VRTF.FloatCountFromFormat(format)]; Array.Copy(source, res, Math.Min(source.Length, res.Length)); return(res); }