Browse Source

Updated notes

dirkson 3 years ago
  1. 2
  2. 190
  3. 7
  4. 1


@ -28,7 +28,7 @@ Very early WIP. Nonfunctional.
+ Vulkan
+ Graphene
+ The build script will automatically grab this
+ Eventually Threading (Of some sort)
+ Eventually Threading (Of some sort)
### Build Dependencies
- Vulkan SDK


@ -1,106 +1,90 @@
Can I combine octree/voxtree/objs?
We should have both octree-based top level objects and z-order-curve based top level objects.
We should use a series of graphics-data-bubbles around the player to render. These bubbles ought to contain the damage arrays, the rotations, etc.
Damage arrays should either be on-disk or in a graphics bubble.
We should store a damage array over each lowest level object. The damage array ought to be z-order
One block per block. If you need more resolution, shrink size of block and do multiblock objects
Placed block, graphicdata:
5 24 different rotations possible
3 Unclaimed
12 Material
12 Component
NOTE: This is a rendering engine, not a data-storage engine. If it's not relevant to what's happening on the screen, it shouldn't be handed to the engine
We should have a method to add/remove objects from the various bubbles, as well as a method to add/remove various "distant" objects. (Like "the rest of my ship" and other ships)
Private VoxTree
voxenObj **ParentObj
uint8 ParentObjNum
float Time //For animation. 0 default
voxenObj *ParentObj
ObjTree *ChildObjs
VoxTree **VoxTrees
uint8 VoxTreeNum //For animation
Rotation.xyzw //Quaternion
void *data //User data
uint16 DerivedMaterial //Average of Voxtree or ChildObjs
uint8:1 Changed //Whether the object was touched since last update
int8 voxen_init(uint8 NumberOfWorkerThreads)
Initializes voxen. Tells the engine how many additional threads to utilize for drawing prep.
Returns 1 on success, 0 on failure
Gets a list of objects whose bounding boxes intersect this frame and who had some update performed on them.
Ideal information to hand to a physics engine
void voxen_render(*Obj)
Renders all voxels in object. Call once per frame on rootObj.
voxenObj *voxen_obj_add(*ParentObj, x, y, z)
Creates a new object within the parent object at location x,y,z.
Returns that object, or NULL if allocation failed.
NULL is valid for ParentObj. You will need to manually keep track of the pointer if you pass NULL.
Removes object from parent, frees all allocated data within it, including child objects.
If you have handed out its VoxTree to multiple locations, it will not be deleted
void voxen_obj_rot(*Obj, x, y, z)
Adds rotational speed to the object. Rotational matrixes are internal.
void voxen_obj_mov(*Obj, x, y, z)
Moves directly to the specified location.
void voxen_obj_ani(*Obj, VoxTree *NewAnimationFrame, float Time)
Easiest way to get ahold of a new VoxTree is just to create a fake object, then fill it with voxels.
voxen_vox_add(*Obj, x, y, z, size, mat)
voxen_vox_del(*Obj, x, y, z, size)
voxen_mat_add(red, green, blue, alpha, redspecular, greenspecular, bluespecular, shine)
voxen_MovCam(*Obj, x, y, z)
voxen_RotCam(x, y, z, w)
Export/Import - #define VOXEN_IMPORT_EXPORT
unsigned char *voxen_export_mat(*Size)
unsigned char *voxen_export_obj(*Obj, *Size)
unsigned char *voxen_export_voxtree(*VoxTree, *Size)
voxen_import_mat(unsigned char *data)
voxen_import_obj(unsigned char *data,
voxen_ObjImp(unsigned char *data, *Obj)
Core concepts
These are core concepts for voxen, not for scrumbleship
A voxject is a separate, self-contained clump of voxels.
A voxject has
XYZ Location
XYZW Rotation (Quaternion)
XYZ*2 BoundingBox (Derived)
octree octree
ptr AnimationInfo
uint16 LightsNum
Light[v] Lights
uint16 ChildrenNum
ptr[v] Children
Array of sub-voxjects.
Their Location is relative to this thing's location
A light has:
XYZ Location
XYZ Color
float Brightness
Each level has:
uint16 Material (Derived)
//uint8 Info
bool Solid
xyz Offset
ptr[4] Lights, brightest(Distance/brightness)
ptr ParentNode
union {
ptr[8] Zero to eight sub-nodes (if not solid)
ptr Texture (if solid)
ptr Location in bookkeeping list (if any)
If a level has no sub-nodes, it will be rendered as a single voxel
Volumetric pixel, untextured, but may be shaped
Each voxel has
ptr Voxject
ptr octreeNode
xyz octreeLocation (derived from position in octree)
Ok, so what do we actually hand the GPU?
A giant list of potentially-renderable voxels. (2^32 should be enough)
A smaller list of currently-rendering voxels, uploaded solely as offsets into the larger list
A list of voxjects (2^16 should be enough)
A list of lights (2^16 should be enough)
A list of materials (2^16 should be enough)
Bookkeeping lists
We need to keep the GPU voxel lists in system ram as well, in the following format:
Voxel Bookkeeping List
If a voxel is item X in this list, it's also item X in the Potentially Renderable list
ptr Voxel System location
float CameraDistance
Bool UpdatedThisRound
Voxel Potentially Renderable List
uint16 Material
XYZ Location
ptr Voxject
ptr octreeNode
Voxel ToBeAdded List
ptr Voxel System Location
float CameraDistance
Voxel CurrentlyRendering List
uint32 PositionInPotentiallyRenderable
Once per frame, we have to go through the scene and find all voxels that are potentially renderable.
If we find a voxel that's potentially renderable, and it already has a potentially-rednerable pointer...
We set "AlreadyChecked" to true.
If it's not...
We add it to the ToBeAdded list
Then we go through the BookKeeping list, pulling out any voxels that have "AlreadyChecked" set to false
If the voxel has "AlreadyChecked" set to false, it's replaced with the first available item from ToBeAdded
If there are no more available items, nop
Then, if "AlreadyChecked" is set to true, we set it back to false
Then, we test if the voxel should be rendered
If it is, we add it to the CurrentlyRendering list
Then, we sort the CurrentlyRendering list by distance
Then, we upload the new CurrentlyRendering list in its entirety
Occasionally taking the time to order the Bookkeeping/Potentially Renderable lists by distance may help ordering speed


@ -0,0 +1,7 @@
Voxen_tools time functions
Switch to using callback
Make debug-only
Debug callback
Put in main data structure, rather than global
Maybe add trace level?


@ -34,6 +34,7 @@ char *voxen_read_file(const char *filename, size_t *size)
return buffer;
#include <time.h>