public static int ExtendBufferAndGetAccessorIndex <T>(this glTF gltf, int bufferIndex, T[] array, glBufferTarget target = glBufferTarget.NONE, float[] min = null, float[] max = null) where T : struct { return(gltf.ExtendBufferAndGetAccessorIndex(bufferIndex, new ArraySegment <T>(array), target, min, max)); }
public glTFBufferView Extend(IntPtr p, int bytesLength, int stride, glBufferTarget 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, glBufferTarget target) where T : struct { var view = Storage.Extend(segment, target); byteLength = Storage.GetBytes().Count; return(view); }
public static int ExtendSparseBufferAndGetAccessorIndex <T>(this glTF gltf, int bufferIndex, int accessorCount, ArraySegment <T> sparseValues, int[] sparseIndices, int sparseIndicesViewIndex, glBufferTarget target = glBufferTarget.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 = glComponentType.UNSIGNED_INT }, values = new glTFSparseValues { bufferView = sparseValuesViewIndex, } } }); return(accessorIndex); }
public static int ExtendBufferAndGetAccessorIndex <T>(this glTF gltf, int bufferIndex, ArraySegment <T> array, glBufferTarget target = glBufferTarget.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 Append <T>(ArraySegment <T> segment, glBufferTarget target) where T : struct { var view = m_buffer.Extend(segment, target); byteLength = m_buffer.Bytes.Count; return(view); }
public glTFBufferView ExtendBufferAndGetView <T>(ArraySegment <T> segment, glBufferTarget target) where T : struct { var view = _buffer.Extend(segment, target); Gltf.buffers[0].byteLength = _buffer.Bytes.Count; return(view); }
public glTFBufferView Extend <T>(ArraySegment <T> array, glBufferTarget target) where T : struct { using (var pin = Pin.Create(array)) { var elementSize = Marshal.SizeOf(typeof(T)); var view = Extend(pin.Ptr, array.Count * elementSize, elementSize, target); return(view); } }
public static int ExtendSparseBufferAndGetAccessorIndex <T>(this glTF gltf, int bufferIndex, int accessorCount, T[] sparseValues, int[] sparseIndices, int sparseViewIndex, glBufferTarget target = glBufferTarget.NONE) where T : struct { return(ExtendSparseBufferAndGetAccessorIndex(gltf, bufferIndex, accessorCount, new ArraySegment <T>(sparseValues), sparseIndices, sparseViewIndex, target)); }
/// <summary> /// Copies a region between buffers. /// </summary> /// <param name="readTarget">A <see cref="glBufferTarget"/> specifying the read target.</param> /// <param name="writeTarget">A <see cref="glBufferTarget"/> specifying the write target.</param> /// <param name="readOffset">The offset into the read buffer.</param> /// <param name="writeOffset">The offset into the write buffer.</param> /// <param name="size">The size of the region.</param> public static void CopyBufferSubData(glBufferTarget readTarget, glBufferTarget writeTarget, int readOffset, int writeOffset, int size) { if (IntPtr.Size == 4) { CopyBufferSubData_32(readTarget, writeTarget, readOffset, writeOffset, size); } else { CopyBufferSubData_64(readTarget, writeTarget, readOffset, writeOffset, size); } }
public static int ExtendBufferAndGetViewIndex <T>(this glTF gltf, int bufferIndex, ArraySegment <T> array, glBufferTarget target = glBufferTarget.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 int ExtendBufferAndGetViewIndex <T>( ArraySegment <T> array, glBufferTarget target = glBufferTarget.NONE) where T : struct { if (array.Count == 0) { return(-1); } var view = ExtendBufferAndGetView(array, target); var viewIndex = Gltf.bufferViews.Count; Gltf.bufferViews.Add(view); return(viewIndex); }
/// <summary> /// Copies a region between buffers. /// </summary> /// <param name="readTarget">A <see cref="glBufferTarget"/> specifying the read target.</param> /// <param name="writeTarget">A <see cref="glBufferTarget"/> specifying the write target.</param> /// <param name="readOffset">The offset into the read buffer.</param> /// <param name="writeOffset">The offset into the write buffer.</param> /// <param name="size">The size of the region.</param> public static void CopyBufferSubData(glBufferTarget readTarget, glBufferTarget writeTarget, long readOffset, long writeOffset, long size) { if (IntPtr.Size == 4) { if (((long)readOffset >> 32) != 0) { throw new ArgumentOutOfRangeException("readOffset", PlatformErrorString); } if (((long)writeOffset >> 32) != 0) { throw new ArgumentOutOfRangeException("writeOffset", PlatformErrorString); } if (((long)size >> 32) != 0) { throw new ArgumentOutOfRangeException("size", PlatformErrorString); } CopyBufferSubData_32(readTarget, writeTarget, (int)readOffset, (int)writeOffset, (int)size); } else { CopyBufferSubData_64(readTarget, writeTarget, readOffset, writeOffset, size); } }
public glTFBufferView Extend(IntPtr p, int bytesLength, int stride, glBufferTarget target) { if (m_bytes == null) { m_bytes = new byte[bytesLength]; Marshal.Copy(p, m_bytes, 0, bytesLength); return(new glTFBufferView { buffer = 0, byteLength = bytesLength, byteOffset = 0, byteStride = stride, target = target, }); } else { var tmp = m_bytes; // alignment var padding = tmp.Length % stride == 0 ? 0 : stride - tmp.Length % stride; m_bytes = new Byte[m_bytes.Length + padding + bytesLength]; Buffer.BlockCopy(tmp, 0, m_bytes, 0, tmp.Length); if (tmp.Length + padding + bytesLength > m_bytes.Length) { throw new ArgumentOutOfRangeException(); } Marshal.Copy(p, m_bytes, tmp.Length + padding, bytesLength); return(new glTFBufferView { buffer = 0, byteLength = bytesLength, byteOffset = tmp.Length + padding, byteStride = stride, target = target, }); } }
public static int ExtendBufferAndGetAccessorIndex <T>(this glTF gltf, int bufferIndex, ArraySegment <T> array, glBufferTarget target = glBufferTarget.NONE) where T : struct { if (array.Count == 0) { return(-1); } var view = gltf.buffers[bufferIndex].Storage.Extend(array, target); var viewIndex = gltf.bufferViews.Count; gltf.bufferViews.Add(view); 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 static int ExtendBufferAndGetViewIndex <T>(this glTF gltf, int bufferIndex, T[] array, glBufferTarget target = glBufferTarget.NONE) where T : struct { return(ExtendBufferAndGetViewIndex(gltf, bufferIndex, new ArraySegment <T>(array), target)); }
public glTFBufferView Extend <T>(ArraySegment <T> array, glBufferTarget target) where T : struct { throw new NotImplementedException(); }
public glTFBufferView Append <T>(T[] array, glBufferTarget target) where T : struct { return(Append(new ArraySegment <T>(array), target)); }
public int ExtendBufferAndGetAccessorIndex <T>(T[] array, glBufferTarget target = glBufferTarget.NONE) where T : struct { return(ExtendBufferAndGetAccessorIndex(new ArraySegment <T>(array), target)); }
public static glTFBufferView Extend <T>(this IBytesBuffer buffer, T[] array, glBufferTarget target) where T : struct { return(buffer.Extend(new ArraySegment <T>(array), target)); }
public glTFBufferView Extend <T>(NativeArray <T> array, glBufferTarget target = default) where T : struct { return(Extend(new ArraySegment <T>(array.ToArray()), target)); }