public static MeshPrimitive WithIndicesAutomatic(this MeshPrimitive primitive, PrimitiveType primitiveType) { var root = primitive.LogicalParent.LogicalParent; primitive.DrawPrimitiveType = primitiveType; primitive.SetIndexAccessor(null); return(primitive); }
public static MeshPrimitive WithIndicesAccessor(this MeshPrimitive primitive, PrimitiveType primitiveType, MemoryAccessor memAccessor) { Guard.NotNull(primitive, nameof(primitive)); var root = primitive.LogicalParent.LogicalParent; var accessor = root.CreateAccessor(); accessor.SetIndexData(memAccessor); primitive.DrawPrimitiveType = primitiveType; primitive.SetIndexAccessor(accessor); return(primitive); }
public static MeshPrimitive WithIndicesAccessor(this MeshPrimitive primitive, PrimitiveType primitiveType, IReadOnlyList <Int32> values) { var root = primitive.LogicalParent.LogicalParent; // create an index buffer and fill it var view = root.UseBufferView(new Byte[4 * values.Count], 0, null, 0, BufferMode.ELEMENT_ARRAY_BUFFER); var array = new IntegerArray(view.Content); array.FillFrom(0, values); var accessor = root.CreateAccessor(); accessor.SetIndexData(view, 0, values.Count, IndexEncodingType.UNSIGNED_INT); primitive.DrawPrimitiveType = primitiveType; primitive.SetIndexAccessor(accessor); return(primitive); }