public static int ExtendSparseBufferAndGetAccessorIndex <T>(this GLTFRoot gltf, int bufferIndex, int accessorCount, ArraySegment <T> sparseValues, int[] sparseIndices, int sparseIndicesViewIndex, GLTFBufferTarget target = GLTFBufferTarget.NONE) where T : struct { if (sparseValues.Count == 0) { return(-1); } var sparseValuesViewIndex = ExtendBufferAndGetViewIndex(gltf, bufferIndex, sparseValues, target); var accessorIndex = gltf.accessors.Count; gltf.accessors.Add(new GLTFAccessor { byteOffset = 0, componentType = GetComponentType <T>(), type = GetAccessorType <T>(), count = accessorCount, sparse = new GLTFSparse { count = sparseIndices.Length, indices = new GLTFSparseIndices { bufferView = sparseIndicesViewIndex, componentType = GLTFComponentType.UNSIGNED_INT }, values = new GLTFSparseValues { bufferView = sparseValuesViewIndex, } } }); return(accessorIndex); }
public GLTFBufferView Extend(IntPtr p, int bytesLength, int stride, GLTFBufferTarget target) { var tmp = m_bytes; // alignment var padding = m_used % stride == 0 ? 0 : stride - m_used % stride; if (m_bytes == null || m_used + padding + bytesLength > m_bytes.Length) { // recreate buffer m_bytes = new Byte[m_used + padding + bytesLength]; if (m_used > 0) { Buffer.BlockCopy(tmp, 0, m_bytes, 0, m_used); } } if (m_used + padding + bytesLength > m_bytes.Length) { throw new ArgumentOutOfRangeException(); } Marshal.Copy(p, m_bytes, m_used + padding, bytesLength); var result = new GLTFBufferView { buffer = 0, byteLength = bytesLength, byteOffset = m_used + padding, byteStride = stride, target = target, }; m_used = m_used + padding + bytesLength; return(result); }
public GLTFBufferView Append <T>(ArraySegment <T> segment, GLTFBufferTarget target) where T : struct { var view = _storage.Extend(segment, target); byteLength = _storage.GetBytes().Count; return(view); }
public static int ExtendBufferAndGetAccessorIndex <T>(this GLTFRoot gltf, int bufferIndex, ArraySegment <T> array, GLTFBufferTarget target = GLTFBufferTarget.NONE) where T : struct { if (array.Count == 0) { return(-1); } var viewIndex = ExtendBufferAndGetViewIndex(gltf, bufferIndex, array, target); // index buffer's byteStride is unnecessary gltf.bufferViews[viewIndex].byteStride = 0; var accessorIndex = gltf.accessors.Count; gltf.accessors.Add(new GLTFAccessor { bufferView = viewIndex, byteOffset = 0, componentType = GetComponentType <T>(), type = GetAccessorType <T>(), count = array.Count, }); return(accessorIndex); }
public GLTFBufferView Extend <T>(ArraySegment <T> array, GLTFBufferTarget target) where T : struct { using (var pin = array.ToPin()) { var elementSize = Marshal.SizeOf(typeof(T)); var view = Extend(pin.Ptr, array.Count * elementSize, elementSize, target); return(view); } }
public static int ExtendSparseBufferAndGetAccessorIndex <T>(this GLTFRoot gltf, int bufferIndex, int accessorCount, T[] sparseValues, int[] sparseIndices, int sparseViewIndex, GLTFBufferTarget target = GLTFBufferTarget.NONE) where T : struct { return(ExtendSparseBufferAndGetAccessorIndex(gltf, bufferIndex, accessorCount, new ArraySegment <T>(sparseValues), sparseIndices, sparseViewIndex, target)); }
public static int ExtendBufferAndGetViewIndex <T>(this GLTFRoot gltf, int bufferIndex, ArraySegment <T> array, GLTFBufferTarget target = GLTFBufferTarget.NONE) where T : struct { if (array.Count == 0) { return(-1); } var view = gltf.buffers[bufferIndex].Append(array, target); var viewIndex = gltf.bufferViews.Count; gltf.bufferViews.Add(view); return(viewIndex); }
public GLTFBufferView Extend <T>(ArraySegment <T> array, GLTFBufferTarget target) where T : struct { throw new NotImplementedException(); }
public static GLTFBufferView Extend <T>(this IBytesBuffer buffer, T[] array, GLTFBufferTarget target) where T : struct { return(buffer.Extend(new ArraySegment <T>(array), target)); }
public GLTFBufferView Append <T>(T[] array, GLTFBufferTarget target) where T : struct { return(Append(new ArraySegment <T>(array), target)); }
public static int ExtendBufferAndGetViewIndex <T>(this GLTFRoot gltf, int bufferIndex, T[] array, GLTFBufferTarget target = GLTFBufferTarget.NONE) where T : struct { return(ExtendBufferAndGetViewIndex(gltf, bufferIndex, new ArraySegment <T>(array), target)); }