OxMIndexArray Class
This class holds an array of unsigned shorts (UInt16) suitable for use as triangle indexes. The advantage of this class over a standard REALbasic Array is fast and automatic conversion to Ptr for use in declare statements. The advantage over a standard Memoryblock is a concise API that only deals with one data type.
Note: This class may resemble a Memoryblock in some respects but keep in mind that it lacks a LittleEndian flag, and the data accessors do not perform any sort of byte swapping. The internal data storage always uses the current platform's native endianness, however, a Copy method that accepts a Memoryblock is provided that will byte-swap the Memoryblock's data when necessary.
Constructors
Expand All | Collapse All
-
OxMIndexArray ( numelements As Integer )
Initializes the array to the hold the requested number of indexes. Pass zero to initialize the array without allocating memory.
Important: Although element indexes are zero-based the numelements parameter is the total number of elements required, not the upper-bound as used when initializing a REALbasic array.
Constants
Expand All | Collapse All
-
kElementSize = 2
The byte size of one array element - i.e. one UInt16 (2 bytes). This is provided for advanced users wishing to manipulate the data block with direct Ptr access.
Properties
Expand All | Collapse All
-
Count As Integer
Read or set the number of indexes in the array.
Methods
Expand All | Collapse All
-
Clear
Sets all indexes to zero. -
Copy As OxMIndexArray
Returns a copy of this index array. -
Copy ( source As MemoryBlock )
Copies the byte data in the passed Memoryblock into this array, resizing the index array as needed. The source Memoryblock must be a sized block, not a Ptr, and bytes will be swapped as needed if the Memoryblock's LittleEndian flag does not match the current platform's endianness.
Important: This method is provided to easily copy data loaded from disk into the index array. The data in the Memoryblock is treated as a series UInt16 elements, and will be truncated to a multiple of kElementSize if it overflows. -
Copy ( source As OxMIndexArray )
Copies the data in the passed index array into this index array, resizing this array to match (if needed). -
CopyBestFit ( source As OxMIndexArray )
Copies the data in the passed index array into this index array, without resizing this array. If the passed array is smaller the overflow is left untouched, if the passed array is larger, the overflow is ignored. This method is faster than the regular Copy and doesn't require a memory re-allocation, but is mostly only useful for copying equally sized arrays. -
Index ( idx As Integer ) As Uint16
Read or set the value of the requested index. Note that idx is zero-based, valid in the range from 0 to Count-1.