Locking and Manual Drawing
Sub VoxVolumeLock()
Prevents drawing commands on the selected volume from updating OpenGl managed memory or triggering hidden surface removal until the corresponding call to VoxVolumeUnlock is made.
Function VoxVolumePtr() As UInteger Ptr
Returns a pointer to volume memory but only if the current volume is locked. If the current volume is not locked 0 (NULL) will be returned. Volume memory is organized logically into planes by Z, rows by Y and individual voxels by X. However the red and blue bytes are in opposite positions relative to FreeBASIC colors.
For example to draw a red voxel at (1, 2, 3) you might use:
#Define SwapRB(C) (CUInt(C) Shr 16 And &HFF Or (CUInt(C) And &HFF) Shl 16 Or CUInt(C) And &HFF00FF00)
Dim As Vec3I V = Vec3I(1, 2, 3), Size = VoxGetVolumeSize
VoxVolumeLock
Dim Voxels As UInteger Ptr = VoxVolumePtr
Voxels[V.X + Size.X*(V.Y + Size.Y*V.Z)] = SwapRB(RGB(255, 0, 0))
VoxVolumeUnlock
Sub VoxVolumeUnlock()
Will update OpenGl memory and perform hidden surface removal but only on the final call corresponding to the first VoxVolumeLock call made for the current volume.
Drawing Commands
Sub VoxCls()
Clears the volume, setting every voxel to the transparent color value 0.
Sub VSet(Voxel As Vec3I)
Sub VSet(Voxel As Vec3I, Col As UInteger)
Sets a single voxel to the color Col, or to the current color if Col isn't specified. Ignored if the Voxel is outside the current volume.
Sub VoxLine(A As Vec3I, B As Vec3I)
Sets A, B and every voxel on a line connecting A and B to the selected color, clipped to the current Volume.
Sub VoxLineTo(B As Vec3I)
Draws a line from the drawing position to B using the selected color. Also sets the drawing position for the next command to B. The drawing position is also affected by VSet and VoxLine.
Sub VoxBlit(ByVal DestV As Vec3I, ByVal SrcV As Vec3I, ByVal Size As Vec3I)
Copies a rectangular solid region of voxels from the source volume to the current volume.
DestV specifies the coordinates of the current volume where the voxels will be copied to.
SrcV specifies the coordinates of the source volume where the copying will start from.
Size specifies the size of the region to copy in untransformed source coordinates. Negative values in Size will change the source and destination solid rectangles but will not perform any extra transformation.
The specified region will be clipped against the source and current volumes.
VoxBlit will also perform the Blit transformation set up by the commands VoxSetBlitDefault, VoxBlitRightRotate, and VoxBlitReflect.