|
@@ -41,49 +41,54 @@ namespace SharpGLTF.Schema2
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// Gets the <see cref="BufferView"/> buffer that contains the items as an encoded byte array.
|
|
/// Gets the <see cref="BufferView"/> buffer that contains the items as an encoded byte array.
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
- public BufferView SourceBufferView => this._bufferView.HasValue ? this.LogicalParent.LogicalBufferViews[this._bufferView.Value] : null;
|
|
|
|
|
|
|
+ public BufferView SourceBufferView => this._bufferView.HasValue ? this.LogicalParent.LogicalBufferViews[this._bufferView.Value] : null;
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// Gets the number of items.
|
|
/// Gets the number of items.
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
- public int Count => this._count;
|
|
|
|
|
|
|
+ public int Count => this._count;
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// Gets the starting byte offset within <see cref="SourceBufferView"/>.
|
|
/// Gets the starting byte offset within <see cref="SourceBufferView"/>.
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
- public int ByteOffset => this._byteOffset.AsValue(0);
|
|
|
|
|
|
|
+ public int ByteOffset => this._byteOffset.AsValue(0);
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// Gets the number of bytes, starting at <see cref="ByteOffset"/> use by this <see cref="Accessor"/>
|
|
/// Gets the number of bytes, starting at <see cref="ByteOffset"/> use by this <see cref="Accessor"/>
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
- public int ByteLength => SourceBufferView.GetAccessorByteLength(Format, Count);
|
|
|
|
|
|
|
+ public int ByteLength => SourceBufferView.GetAccessorByteLength(Format, Count);
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// Gets the <see cref="DimensionType"/> of an item.
|
|
/// Gets the <see cref="DimensionType"/> of an item.
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
- public DimensionType Dimensions => this._type;
|
|
|
|
|
|
|
+ public DimensionType Dimensions => _GetDimensions();
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// Gets the <see cref="EncodingType"/> of an item.
|
|
/// Gets the <see cref="EncodingType"/> of an item.
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
- public EncodingType Encoding => this._componentType;
|
|
|
|
|
|
|
+ public EncodingType Encoding => this._componentType;
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// Gets a value indicating whether the items values are normalized.
|
|
/// Gets a value indicating whether the items values are normalized.
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
- public Boolean Normalized => this._normalized.AsValue(false);
|
|
|
|
|
|
|
+ public Boolean Normalized => this._normalized.AsValue(false);
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// Gets a value indicating whether this <see cref="Accessor"/> has a sparse structure.
|
|
/// Gets a value indicating whether this <see cref="Accessor"/> has a sparse structure.
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
- public Boolean IsSparse => this._sparse != null;
|
|
|
|
|
|
|
+ public Boolean IsSparse => this._sparse != null;
|
|
|
|
|
|
|
|
- public AttributeFormat Format => new AttributeFormat(_type, _componentType, this._normalized.AsValue(false));
|
|
|
|
|
|
|
+ public AttributeFormat Format => new AttributeFormat(this.Dimensions, _componentType, this._normalized.AsValue(false));
|
|
|
|
|
|
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
|
|
#region API
|
|
#region API
|
|
|
|
|
|
|
|
|
|
+ private DimensionType _GetDimensions()
|
|
|
|
|
+ {
|
|
|
|
|
+ return Enum.TryParse<DimensionType>(this._type, out var r) ? r : DimensionType.CUSTOM;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
internal MemoryAccessor _GetMemoryAccessor(string name = null)
|
|
internal MemoryAccessor _GetMemoryAccessor(string name = null)
|
|
|
{
|
|
{
|
|
|
var view = SourceBufferView;
|
|
var view = SourceBufferView;
|
|
@@ -165,13 +170,23 @@ namespace SharpGLTF.Schema2
|
|
|
this._byteOffset = bufferByteOffset.AsNullable(_byteOffsetDefault, _byteOffsetMinimum, int.MaxValue);
|
|
this._byteOffset = bufferByteOffset.AsNullable(_byteOffsetDefault, _byteOffsetMinimum, int.MaxValue);
|
|
|
this._count = itemCount;
|
|
this._count = itemCount;
|
|
|
|
|
|
|
|
- this._type = dimensions;
|
|
|
|
|
|
|
+ this._type = Enum.GetName(typeof(DimensionType), dimensions);
|
|
|
this._componentType = encoding;
|
|
this._componentType = encoding;
|
|
|
this._normalized = normalized.AsNullable(_normalizedDefault);
|
|
this._normalized = normalized.AsNullable(_normalizedDefault);
|
|
|
|
|
|
|
|
UpdateBounds();
|
|
UpdateBounds();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public Matrix2x2Array AsMatrix2x2Array()
|
|
|
|
|
+ {
|
|
|
|
|
+ return _GetMemoryAccessor().AsMatrix2x2Array();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public Matrix3x3Array AsMatrix3x3Array()
|
|
|
|
|
+ {
|
|
|
|
|
+ return _GetMemoryAccessor().AsMatrix3x3Array();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public Matrix4x4Array AsMatrix4x4Array()
|
|
public Matrix4x4Array AsMatrix4x4Array()
|
|
|
{
|
|
{
|
|
|
return _GetMemoryAccessor().AsMatrix4x4Array();
|
|
return _GetMemoryAccessor().AsMatrix4x4Array();
|