Jo Engine  2024.04.28
Jo Sega Saturn Engine
Data Structures | Functions
voxel.h File Reference

Jo Engine Voxel renderer. More...

Go to the source code of this file.

Data Structures

struct  __jo_voxel_computation_cache
 Voxel computation cache (internal engine usage) More...
 
struct  jo_voxel_camera
 Voxel camera definition. More...
 
struct  jo_voxel
 Voxel main definition. More...
 

Functions

void jo_voxel_do_angle_computation (jo_voxel *const voxel_data)
 Do computation linked to camera angle. More...
 
void jo_voxel_redraw (jo_voxel *const voxel_data)
 Draw voxels to gfx. More...
 
void jo_voxel_run (jo_voxel *const voxel_data)
 Draw voxels to gfx. More...
 
static __jo_force_inline void jo_voxel_redraw_and_flush (jo_voxel *const voxel_data)
 Draw voxels and flush the buffer. More...
 
static __jo_force_inline void jo_voxel_increase_view_distance (jo_voxel *const voxel_data, const jo_fixed distance)
 Increase view distance (camera.zfar) More...
 
static __jo_force_inline void jo_voxel_decrease_view_distance (jo_voxel *const voxel_data, const jo_fixed distance)
 Decrease view distance (camera.zfar) More...
 
static __jo_force_inline void jo_voxel_horizon_up (jo_voxel *const voxel_data, const jo_fixed distance)
 Increase horizon height (camera.horizon) More...
 
static __jo_force_inline void jo_voxel_horizon_down (jo_voxel *const voxel_data, const jo_fixed distance)
 Decrease horizon height (camera.horizon) More...
 
static __jo_force_inline void jo_voxel_move_up (jo_voxel *voxel_data, const jo_fixed distance)
 Increase camera height (camera.height) More...
 
static __jo_force_inline void jo_voxel_move_down (jo_voxel *const voxel_data, const jo_fixed distance)
 Decrease camera height (camera.height) More...
 
static __jo_force_inline void jo_voxel_move_forward (jo_voxel *const voxel_data, const jo_fixed distance)
 Move camera forward (camera.x & camera.y) More...
 
static __jo_force_inline void jo_voxel_move_backward (jo_voxel *const voxel_data, const jo_fixed distance)
 Move camera backward (camera.x & camera.y) More...
 
static __jo_force_inline void jo_voxel_rotate_left (jo_voxel *const voxel_data, const jo_fixed angle_rad)
 Rotate camera on the left (camera.angle) More...
 
static __jo_force_inline void jo_voxel_rotate_right (jo_voxel *const voxel_data, const jo_fixed angle_rad)
 Rotate camera on the right (camera.angle) More...
 

Detailed Description

Jo Engine Voxel renderer.

Author
Johannes Fetz
Bug:
No known bugs.

Data Structure Documentation

◆ __jo_voxel_computation_cache

struct __jo_voxel_computation_cache

Voxel computation cache (internal engine usage)

Warning
MC Hammer: don't touch this
Data Fields
int map_width_minus_1
jo_fixed plx
jo_fixed ply
jo_fixed px
jo_fixed py

◆ jo_voxel_camera

struct jo_voxel_camera

Voxel camera definition.

Data Fields
jo_fixed angle
jo_fixed height
jo_fixed horizon
jo_fixed scale
jo_fixed x
jo_fixed y
jo_fixed zfar

◆ jo_voxel

struct jo_voxel

Voxel main definition.

Data Fields
__jo_voxel_computation_cache __cache
jo_voxel_camera camera
jo_software_renderer_gfx * gfx
jo_img_8bits height_img
jo_palette height_pal
jo_img_8bits terrain_img
jo_palette terrain_pal
bool use_zbuffer

Function Documentation

◆ jo_voxel_decrease_view_distance()

static __jo_force_inline void jo_voxel_decrease_view_distance ( jo_voxel *const  voxel_data,
const jo_fixed  distance 
)
static

Decrease view distance (camera.zfar)

Parameters
voxel_dataVoxel
distancefixed distance value (see also jo_int2fixed() or jo_float2fixed())

◆ jo_voxel_do_angle_computation()

void jo_voxel_do_angle_computation ( jo_voxel *const  voxel_data)

Do computation linked to camera angle.

Parameters
voxel_dataVoxel
Remarks
Must be called if you change camera.angle manually.

◆ jo_voxel_horizon_down()

static __jo_force_inline void jo_voxel_horizon_down ( jo_voxel *const  voxel_data,
const jo_fixed  distance 
)
static

Decrease horizon height (camera.horizon)

Parameters
voxel_dataVoxel
distancefixed distance value (see also jo_int2fixed() or jo_float2fixed())

◆ jo_voxel_horizon_up()

static __jo_force_inline void jo_voxel_horizon_up ( jo_voxel *const  voxel_data,
const jo_fixed  distance 
)
static

Increase horizon height (camera.horizon)

Parameters
voxel_dataVoxel
distancefixed distance value (see also jo_int2fixed() or jo_float2fixed())

◆ jo_voxel_increase_view_distance()

static __jo_force_inline void jo_voxel_increase_view_distance ( jo_voxel *const  voxel_data,
const jo_fixed  distance 
)
static

Increase view distance (camera.zfar)

Parameters
voxel_dataVoxel
distancefixed distance value (see also jo_int2fixed() or jo_float2fixed())

◆ jo_voxel_move_backward()

static __jo_force_inline void jo_voxel_move_backward ( jo_voxel *const  voxel_data,
const jo_fixed  distance 
)
static

Move camera backward (camera.x & camera.y)

Parameters
voxel_dataVoxel
distancefixed distance value (see also jo_int2fixed() or jo_float2fixed())

◆ jo_voxel_move_down()

static __jo_force_inline void jo_voxel_move_down ( jo_voxel *const  voxel_data,
const jo_fixed  distance 
)
static

Decrease camera height (camera.height)

Parameters
voxel_dataVoxel
distancefixed distance value (see also jo_int2fixed() or jo_float2fixed())

◆ jo_voxel_move_forward()

static __jo_force_inline void jo_voxel_move_forward ( jo_voxel *const  voxel_data,
const jo_fixed  distance 
)
static

Move camera forward (camera.x & camera.y)

Parameters
voxel_dataVoxel
distancefixed distance value (see also jo_int2fixed() or jo_float2fixed())

◆ jo_voxel_move_up()

static __jo_force_inline void jo_voxel_move_up ( jo_voxel voxel_data,
const jo_fixed  distance 
)
static

Increase camera height (camera.height)

Parameters
voxel_dataVoxel
distancefixed distance value (see also jo_int2fixed() or jo_float2fixed())

◆ jo_voxel_redraw()

void jo_voxel_redraw ( jo_voxel *const  voxel_data)

Draw voxels to gfx.

Parameters
voxel_dataVoxel
Remarks
You should call jo_software_renderer_flush() at some point

◆ jo_voxel_redraw_and_flush()

static __jo_force_inline void jo_voxel_redraw_and_flush ( jo_voxel *const  voxel_data)
static

Draw voxels and flush the buffer.

Parameters
voxel_dataVoxel
Remarks
It's just an helper method

◆ jo_voxel_rotate_left()

static __jo_force_inline void jo_voxel_rotate_left ( jo_voxel *const  voxel_data,
const jo_fixed  angle_rad 
)
static

Rotate camera on the left (camera.angle)

Parameters
voxel_dataVoxel
angle_radfixed rad value (see also jo_int2fixed() or jo_float2fixed())

◆ jo_voxel_rotate_right()

static __jo_force_inline void jo_voxel_rotate_right ( jo_voxel *const  voxel_data,
const jo_fixed  angle_rad 
)
static

Rotate camera on the right (camera.angle)

Parameters
voxel_dataVoxel
angle_radfixed rad value (see also jo_int2fixed() or jo_float2fixed())

◆ jo_voxel_run()

void jo_voxel_run ( jo_voxel *const  voxel_data)

Draw voxels to gfx.

Parameters
voxel_dataVoxel
Warning
Must be call before calling jo_voxel_redraw() or jo_voxel_redraw_and_flush()