public BufferAccessor(ArraySegment <byte> bytes, AccessorValueType componentType, AccessorVectorType accessorType, int count) { Bytes = bytes; ComponentType = componentType; AccessorType = accessorType; Count = count; }
public static int TypeCount(this AccessorVectorType type) { switch (type) { case AccessorVectorType.SCALAR: return(1); case AccessorVectorType.VEC2: return(2); case AccessorVectorType.VEC3: return(3); case AccessorVectorType.VEC4: case AccessorVectorType.MAT2: return(4); case AccessorVectorType.MAT3: return(9); case AccessorVectorType.MAT4: return(16); default: throw new NotImplementedException(); } }
public BufferAccessor(INativeArrayManager arrayManager, NativeArray <byte> bytes, AccessorValueType componentType, AccessorVectorType accessorType, int count) { ArrayManager = arrayManager; Bytes = bytes; ComponentType = componentType; AccessorType = accessorType; Count = count; }
public static BufferAccessor Create <T>(T[] list) where T : struct { var t = typeof(T); var bytes = new byte[list.Length * Marshal.SizeOf(t)]; var span = SpanLike.Wrap <T>(new ArraySegment <byte>(bytes)); for (int i = 0; i < list.Length; ++i) { span[i] = list[i]; } AccessorValueType componentType = default(AccessorValueType); AccessorVectorType accessorType = default(AccessorVectorType); if (t == typeof(Vector2)) { componentType = AccessorValueType.FLOAT; accessorType = AccessorVectorType.VEC2; } else if (t == typeof(Vector3)) { componentType = AccessorValueType.FLOAT; accessorType = AccessorVectorType.VEC3; } else if (t == typeof(Vector4)) { componentType = AccessorValueType.FLOAT; accessorType = AccessorVectorType.VEC4; } else if (t == typeof(Quaternion)) { componentType = AccessorValueType.FLOAT; accessorType = AccessorVectorType.VEC4; } else if (t == typeof(SkinJoints)) { componentType = AccessorValueType.UNSIGNED_SHORT; accessorType = AccessorVectorType.VEC4; } else if (t == typeof(int)) { componentType = AccessorValueType.UNSIGNED_INT; accessorType = AccessorVectorType.SCALAR; } else { throw new NotImplementedException(); } return(new BufferAccessor( new ArraySegment <byte>(bytes), componentType, accessorType, list.Length)); }
private static BufferAccessor ToBufferAccessor <T>(INativeArrayManager arrayManager, T[] value, AccessorValueType valueType, AccessorVectorType vectorType) where T : struct { return(new BufferAccessor(arrayManager, arrayManager.CreateNativeArray(value).Reinterpret <byte>(Marshal.SizeOf <T>()), valueType, vectorType, value.Length )); }