38#ifdef JO_COMPILE_WITH_3D_SUPPORT
41# define JO_3D_PLANE_VERTICES(SIZE) \
43 { -SIZE, -SIZE, 0 }, \
50# define JO_3D_TRIANGLE_VERTICES(SIZE) \
52 { -SIZE, -SIZE, 0 }, \
58# define JO_3D_CUBE_VERTICES(SIZE) \
60 { -SIZE, -SIZE, SIZE }, \
61 { SIZE, -SIZE, SIZE }, \
62 { SIZE, SIZE, SIZE }, \
63 { -SIZE, SIZE, SIZE }, \
64 { -SIZE, -SIZE, -SIZE }, \
65 { -SIZE, -SIZE, SIZE }, \
66 { -SIZE, SIZE, SIZE }, \
67 { -SIZE, SIZE, -SIZE }, \
68 { SIZE, -SIZE, -SIZE }, \
69 { -SIZE, -SIZE, -SIZE }, \
70 { -SIZE, SIZE, -SIZE }, \
71 { SIZE, SIZE, -SIZE }, \
72 { SIZE, -SIZE, SIZE }, \
73 { SIZE, -SIZE, -SIZE }, \
74 { SIZE, SIZE, -SIZE }, \
75 { SIZE, SIZE, SIZE }, \
76 { -SIZE, -SIZE, -SIZE }, \
77 { SIZE, -SIZE, -SIZE }, \
78 { SIZE, -SIZE, SIZE }, \
79 { -SIZE, -SIZE, SIZE }, \
80 { -SIZE, SIZE, SIZE }, \
81 { SIZE, SIZE, SIZE }, \
82 { SIZE, SIZE, -SIZE }, \
83 { -SIZE, SIZE, -SIZE } \
90# define JO_3D_QUAD_VERTEX_COUNT (4)
105 vertices[0].
x =
center->
x - right->
x - down->
x;
106 vertices[0].
y =
center->
y - right->
y - down->
y;
107 vertices[0].
z =
center->
z - right->
z - down->
z;
108 vertices[1].
x =
center->
x + right->
x - down->
x;
109 vertices[1].
y =
center->
y + right->
y - down->
y;
110 vertices[1].
z =
center->
z + right->
z - down->
z;
111 vertices[2].
x =
center->
x + right->
x + down->
x;
112 vertices[2].
y =
center->
y + right->
y + down->
y;
113 vertices[2].
z =
center->
z + right->
z + down->
z;
114 vertices[3].
x =
center->
x - right->
x + down->
x;
115 vertices[3].
y =
center->
y - right->
y + down->
y;
116 vertices[3].
z =
center->
z - right->
z + down->
z;
120# define JO_3D_DEFAULT_PERSPECTIVE_ANGLE (90)
123# define JO_3D_DEFAULT_DISPLAY_LEVEL (3)
130# define JO_3D_SORT_PREVIOUS (0)
132# define JO_3D_SORT_MIN (1)
134# define JO_3D_SORT_MAX (2)
136# define JO_3D_SORT_CENTER (3)
138# define JO_3D_SORT_MASK (3)
141# define JO_3D_SINGLE_PLANE (0)
143# define JO_3D_DUAL_PLANE (1)
146# define JO_3D_NO_OPTION (0)
148# define JO_3D_USE_TEXTURE (JO_VDP1_OPTION_USE_TEXTURE)
150# define JO_3D_USE_LIGHT (1 << 3)
152# define JO_3D_USE_PALETTE (1 << 5)
154# define JO_3D_NO_TEXTURE (0)
202# define JO_3D_ATTRIBUTE(PLANE, SORT, TEXTURE, COLOR, GOURAUD, DRAW_MODE, DIRECTION, OPTIONS) \
203 {(PLANE), (SORT) | JO_VDP1_DIRECTION_OPTIONS(DIRECTION) | (OPTIONS), (TEXTURE), (DRAW_MODE) | JO_VDP1_DIRECTION_DRAW_MODE(DIRECTION), \
204 (COLOR), (GOURAUD), JO_VDP1_DIRECTION_COMMAND(DIRECTION)}
211# define JO_3D_NORMAL(X, Y, Z) {JO_FLOAT_TO_FIXED(X), JO_FLOAT_TO_FIXED(Y), JO_FLOAT_TO_FIXED(Z)}
219# define JO_3D_VERTICES(A, B, C, D) {(A), (B), (C), (D)}
298# define JO_3D_AXIS_X (0)
300# define JO_3D_AXIS_Y (1)
302# define JO_3D_AXIS_Z (2)
348 const unsigned int point_count,
395 cam->
z_angle = jo_DEGtoANG_int(angle);
583 const int bank,
const unsigned int index);
593 const unsigned int index);
1219 if (*range_count > 0 && ranges[*range_count - 1].first + ranges[*range_count - 1].count == first)
1221 ranges[*range_count - 1].
count += (
unsigned short)count;
1224 ranges[*range_count].
first = (
unsigned short)first;
1225 ranges[*range_count].
count = (
unsigned short)count;
1260 while (--array_size >= 0)
jo_3d_draw(array + array_size);
1297 __internal_jo_sprite_set_position3D(x, y, z);
1315 __internal_jo_sprite_set_position3D(x, y, z);
1343 __jo_3d_scale(jo_float2fixed(x), jo_float2fixed(y), jo_float2fixed(z));
1394static __jo_force_inline bool jo_3d_window(
const int left,
const int top,
const int right,
const int bottom,
const int z_limit,
const int center_x,
const int center_y)
1415# define JO_3D_NEAR_WINDOW (0)
1418# define JO_3D_FAR_WINDOW (1)
1421# define JO_3D_FAR_WINDOW_2 (2)
1424# define JO_3D_LAYER_WINDOW (JO_VDP1_OFF_SCREEN_WINDOW)
1431 __jo_vdp1_select_window(window);
1452 if (angle < 10 || angle > 160)
1477 __jo_vdp1_update_near_clip();
1495# define JO_3D_MAX_GUARD_BAND (512)
1498# define JO_3D_DEFAULT_GUARD_BAND (JO_3D_MAX_GUARD_BAND)
1724# define JO_3D_FADE_LEVELS (3)
1726# define JO_3D_FADE_LEVEL_SHIFT (11)
1850#ifdef JO_COMPILE_WITH_DUAL_CPU_SUPPORT
1933 const unsigned int point_count,
1972 const jo_fixed sway,
const bool flip);
static __jo_force_inline void jo_3d_camera_look_at(jo_camera *const cam)
look at the camera
Definition 3d.h:411
static __jo_force_inline unsigned int jo_3d_get_displayed_polygon_count(void)
Get displayed polygon count.
Definition 3d.h:448
void jo_3d_set_mesh_polygon_screen_doors(jo_3d_mesh *const mesh, const bool enabled, const unsigned int index)
Enable/Disable screen doors transparency on one polygon on the mesh.
bool jo_3d_set_texture_subdivision_fine(const int sprite_id)
Add finer tiles to the tiles of a texture (see jo_3d_set_texture_subdivision()): 8 x 8 and 16 x 16 ti...
static __jo_force_inline void jo_3d_rotate_matrix_x(short x)
Rotate 3D matrix using degree (X axis).
Definition 3d.h:995
static __jo_force_inline void jo_3d_translate_matrix(int x, int y, int z)
Translate 3D matrix.
Definition 3d.h:1124
static __jo_force_inline void jo_3d_set_mesh_vertice(jo_3d_mesh *const mesh, const jo_fixed x, const jo_fixed y, const jo_fixed z, const unsigned int index)
Set vertice position in mesh.
Definition 3d.h:721
unsigned short vertices[4]
Definition 3d.h:160
unsigned short texture_id
Definition 3d.h:168
int jo_3d_slave_get_max_vertices(void)
Points of the biggest object the slave CPU can draw (a bigger object is not drawn).
static __jo_force_inline void jo_3d_set_depth_bias(const int bias)
Set a depth added to the polygons and sprites drawn after this call, to sort them (the farthest are d...
Definition 3d.h:1543
void jo_3d_create_cube(jo_3d_quad *array, jo_vertice *const vertices)
Create a cube.
void jo_3d_set_view_rect(const jo_3d_rect *const rect)
The objects are seen only in a rectangle of the screen: jo_3d_is_sphere_visible() is false for the sp...
static __jo_force_inline void jo_3d_set_wireframe(const bool enabled)
Wireframe mode: the polygons and the standing sprites (distorted sprites) are drawn as their outline,...
Definition 3d.h:1524
int __jo_3d_guard_band
Guard band (internal engine usage, see jo_3d_set_guard_band()).
#define JO_3D_AXIS_Y
Y axis for __jo_3d_rotate().
Definition 3d.h:300
static __jo_force_inline void jo_3d_set_scale_fixed(const jo_fixed x, const jo_fixed y, const jo_fixed z)
Change scale using fixed number.
Definition 3d.h:1361
static __jo_force_inline void jo_3d_rotate_matrix_y(short y)
Rotate 3D matrix using degree (Y axis).
Definition 3d.h:1003
static __jo_force_inline void jo_3d_rotate_matrix_rad_z(float z)
Rotate 3D matrix using radian (Z axis).
Definition 3d.h:1047
static __jo_force_inline unsigned int jo_3d_get_polygon_count(void)
Get polygon count (visible and not visible).
Definition 3d.h:430
unsigned short first
Definition 3d.h:188
static __jo_force_inline void jo_3d_set_transparency(jo_3d_quad *const quad, const bool enabled)
Enable/Disable transparency on the quadrilateral.
Definition 3d.h:851
void __jo_3d_rotate(const int axis, const jo_angle angle)
Rotate the current matrix around an axis (Internal usage).
bool jo_3d_mesh_ray_hit(const jo_3d_mesh *const mesh, const jo_pos3D_fixed *const origin, const jo_pos3D_fixed *const dir, jo_fixed *const best, jo_pos3D_fixed *const normal)
First polygon of a mesh hit by a ray (the bullets: the walls of a building, the rooms of a level....
static __jo_force_inline void jo_3d_window_clip(const bool clip)
The 3D polygons drawn in the current window are clipped by the VDP1 to its rectangle (user clipping: ...
Definition 3d.h:1409
unsigned short jo_3d_get_tint(void)
The tint of the master CPU, packed (see jo_3d_set_tint()): 5 bits per component (signed,...
bool jo_3d_get_view_rect(jo_3d_rect *const rect)
The rectangle of jo_3d_set_view_rect().
void jo_3d_set_mesh_screen_doors(jo_3d_mesh *const mesh, const bool enabled)
Enable/Disable screen doors transparency on the mesh.
void jo_3d_transform_point_by(const jo_fixed(*const m)[3], const jo_pos3D_fixed *const in, jo_pos3D_fixed *const out)
Transform a point by a matrix (see jo_3d_transform_point(): the same result with the current matrix).
static __jo_force_inline void jo_3d_set_guard_band(const int pixels)
Set the guard band around the screen used by the clipping of the polygons drawn after this call.
Definition 3d.h:1514
jo_pos3D_fixed normal
Definition 3d.h:159
void jo_3d_set_mesh_polygon_texture_palette(jo_3d_mesh *const mesh, const int sprite_id, const jo_palette *const palette, const unsigned int index)
Set a texture of 256 colors on one polygon, its colors taken in a palette (its pixel value n: the col...
unsigned int point_count
Definition 3d.h:179
unsigned short __jo_3d_polygon_count
Polygon count of the current frame (Internal usage).
void jo_3d_slave_set_depth_bias(const int bias)
Change the depth bias of the objects drawn by the slave CPU (call it on the slave CPU).
short bottom
Definition 3d.h:1628
static __jo_force_inline void jo_3d_perspective_angle(const int angle)
Set the perspective angle.
Definition 3d.h:1449
static __jo_force_inline void jo_3d_set_windows_apart(const bool apart)
The windows do not overlap (a split screen: a view per player in its window): the commands of each wi...
Definition 3d.h:1441
void jo_3d_set_mesh_polygon_light(jo_3d_mesh *const mesh, const bool enabled, const unsigned int index)
Enable/Disable light on one polygon on the mesh.
void jo_3d_set_fade_distances(const jo_fixed start, const jo_fixed end)
The distances of the fade of the standing sprites (see jo_3d_set_sprite_fade()): opaque up to start,...
short top
Definition 3d.h:1626
static __jo_force_inline void jo_3d_camera_set_target(jo_camera *const cam, const int x, const int y, const int z)
Set the target of the camera (where the scene is located).
Definition 3d.h:382
static __jo_force_inline void jo_3d_rotate_matrix(short x, short y, short z)
Rotate 3D matrix using degree.
Definition 3d.h:985
static __jo_force_inline void jo_3d_translate_matrix_fixed(jo_fixed x, jo_fixed y, jo_fixed z)
Translate 3D matrix.
Definition 3d.h:1114
void __jo_3d_light(const jo_pos3D_fixed *const light)
Set light direction (Internal usage).
void jo_3d_disable_dsp(void)
Stop using the SCU DSP to transform the vertices (see jo_3d_enable_dsp()).
int jo_3d_mesh_get_bounding_sphere(const jo_3d_mesh *const mesh, jo_pos3D_fixed *const center)
Bounding sphere of the points of a mesh (the sphere around their bounding box).
bool jo_3d_set_texture_mipmap_copies(const int sprite_id, const int half_id, const int levels)
Give a texture its smaller copies made beforehand (see jo_3d_set_texture_mipmaps()): for the textures...
static __jo_force_inline jo_fixed jo_3d_get_projection_distance(void)
Get the projection distance (distance of the projection plane, in pixels).
Definition 3d.h:1600
static __jo_force_inline void jo_3d_rotate_matrix_angle(const jo_angle x, const jo_angle y, const jo_angle z)
Rotate 3D matrix using jo_angle (0x10000 = 360 degrees: a fraction of degree, no float).
Definition 3d.h:1058
static __jo_force_inline bool __jo_3d_draw(const jo_3d_polygon_data *const pdata)
Draw polygons using the current matrix (Internal usage).
Definition 3d.h:358
static __jo_force_inline void __jo_poylgon_draw_iterator(jo_node *node)
Internal usage for polygon display.
Definition 3d.h:1241
void jo_3d_free_gouraud_tables(const unsigned short adr, const unsigned int count)
Give back gouraud tables of jo_3d_add_gouraud_tables() (jo_3d_free_model() gives back the tables of a...
static __jo_force_inline void jo_3d_draw_array(jo_3d_quad *const array, int array_size)
Draw an array of quadrilateral.
Definition 3d.h:1258
jo_3d_ray_plane * jo_3d_mesh_create_ray_planes(const jo_3d_mesh *const mesh)
The planes of the polygons of a mesh for jo_3d_mesh_ray_hit_with_planes() (the rays are faster: the m...
static __jo_force_inline void jo_3d_set_mesh_polygon_palette(jo_3d_mesh *const mesh, const int palette_id, const unsigned int index)
Set a palette on the mesh.
Definition 3d.h:626
void jo_3d_set_mesh_polygon_wireframe(jo_3d_mesh *const mesh, const unsigned int index, bool wireframe)
Set wireframe mode on the mesh.
void jo_3d_prepare_tint(const jo_3d_mesh *const mesh)
Make the tinted copy of the gouraud tables of a mesh for the current tint of the master CPU (see jo_3...
bool jo_3d_is_sphere_visible(const jo_pos3D_fixed *const center, const jo_fixed radius, const jo_fixed max_distance)
Check if a sphere (in the view space) can be seen (view frustum of the screen).
static __jo_force_inline void jo_3d_translate_matrixf(float x, float y, float z)
Translate 3D matrix (using floating numbers).
Definition 3d.h:1104
void jo_3d_pop_matrix(void)
Pop 3D matrix.
bool __jo_3d_draw_ranges_from(const jo_3d_polygon_data *const pdata, const unsigned int first_point, const unsigned int point_count, const jo_3d_polygon_range *const ranges, const int range_count)
Draw polygons using the current matrix (Internal usage).
static __jo_force_inline void jo_3d_set_palette(jo_3d_quad *const quad, const int palette_id)
Set a palette on the quadrilateral.
Definition 3d.h:655
void jo_3d_create_triangle(jo_3d_quad *const quad, jo_vertice *const vertices)
Create a triangle.
void jo_3d_set_high_speed_shrink(const bool enabled)
High speed shrink for every textured polygon drawn from now on (models, meshes, levels),...
void jo_3d_set_mesh_polygon_high_speed_shrink(jo_3d_mesh *const mesh, const bool enabled, const unsigned int index)
Enable/Disable High Speed Shrink on one polygon on the mesh.
static __jo_force_inline bool jo_3d_draw_sprite(const int sprite_id)
Draw a sprite.
Definition 3d.h:1267
static __jo_force_inline void jo_3d_set_mesh_palette(jo_3d_mesh *const mesh, const int palette_id)
Set a palette on one polygon on the mesh.
Definition 3d.h:640
bool jo_3d_mesh_ray_hit_with_planes(const jo_3d_mesh *const mesh, const jo_3d_ray_plane *const planes, const jo_pos3D_fixed *const origin, const jo_pos3D_fixed *const dir, jo_fixed *const best, jo_pos3D_fixed *const normal)
jo_3d_mesh_ray_hit() with the planes of the polygons of the mesh (the same result,...
bool jo_3d_draw_standing_sprite(const int sprite_id, const jo_pos3D_fixed *const foot, const jo_fixed width, const jo_fixed height, const jo_fixed sway, const bool flip)
Draw a sprite standing on the ground and facing the camera (trees, grass, characters far away....
void jo_3d_set_mesh_color(jo_3d_mesh *const mesh, const jo_color color)
Set the color on the mesh.
bool jo_3d_create_sprite_quad(const int sprite_id)
static __jo_force_inline bool jo_3d_set_sprite_palette(const int sprite_id, const int palette_id)
Set a palette on a sprite (3D).
Definition 3d.h:669
jo_3d_quad ** __jo_sprite_quad
Sprite quads (internal engine usage): a quad per sprite, the table allocated with the first quad (JO_...
jo_3d_polygon_data data
Definition 3d.h:249
static __jo_force_inline void jo_3d_draw_billboard(const int sprite_id, const int x, const int y, const int z)
Draw billboard.
Definition 3d.h:1294
static __jo_force_inline void jo_3d_set_screen_doors(jo_3d_quad *const quad, const bool enabled)
Enable/Disable screen doors transparency on the quad.
Definition 3d.h:877
static __jo_force_inline void jo_3d_set_perspective(const jo_angle angle)
Set the perspective angle using jo_angle (a fraction of degree, as slPerspective() of the SGL).
Definition 3d.h:1462
static __jo_force_inline void jo_3d_set_light(jo_3d_quad *const quad, const bool enabled)
Enable/Disable light on the quad.
Definition 3d.h:819
void jo_3d_set_palette_light(const int levels, const int stride)
Palette lighting (the light of jo_3d_light() without the RGB colors: the only lighting of the 640 and...
int jo_3d_slave_get_command_count(void)
VDP1 commands used by the slave CPU in the last frame (see jo_3d_slave_end()).
void jo_3d_get_matrix(jo_fixed *m)
Copy the current matrix.
static __jo_force_inline void jo_3d_rotate_matrix_angle_z(const jo_angle z)
Rotate 3D matrix using jo_angle (Z axis).
Definition 3d.h:1084
void jo_3d_slave_select_window(const int window)
Select the window of the next drawings of the slave CPU (call it on the slave CPU; jo_3d_slave_begin(...
void __jo_3d_set_perspective(const jo_angle angle)
Set perspective angle (Internal usage).
void jo_3d_slave_translate_matrix_fixed(const jo_fixed x, const jo_fixed y, const jo_fixed z)
Translate the matrix of the slave CPU (call it on the slave CPU, see jo_3d_translate_matrix_fixed()).
void jo_3d_set_texture_subdivision_depth(const int sprite_id, const jo_fixed depth)
Draw in parts (see jo_3d_set_texture_subdivision()) only the polygons of a texture whose nearest vert...
void jo_3d_slave_rotate_matrix(const int x, const int y, const int z)
Rotate the matrix of the slave CPU (call it on the slave CPU, see jo_3d_rotate_matrix()).
void jo_3d_reflect_matrix(const jo_pos3D_fixed *const normal, const jo_fixed distance)
Multiply the current matrix by a reflection through a plane (a mirror: the camera matrix of the refle...
static __jo_force_inline void jo_3d_set_mesh_polygon_color(jo_3d_mesh *const mesh, const jo_color color, const unsigned int index)
Set the color on one polygon on the mesh.
Definition 3d.h:926
void jo_3d_slave_end(void)
Add the polygons drawn by the slave CPU to the frame (call it on the master CPU, after jo_core_wait_f...
jo_3d_mesh * jo_3d_create_mesh_from_vertices_and_normals(const unsigned int quad_count, jo_vertice *const vertices, jo_vector *const normals)
Create a mesh programmatically from vertices.
void jo_3d_slave_set_fade_distances(const jo_fixed start, const jo_fixed end)
The distances of the fade of the standing sprites of the slave CPU (see jo_3d_set_fade_distances()),...
static __jo_force_inline unsigned int jo_3d_get_mesh_polygon_count(jo_3d_mesh *const mesh)
Get polygon count on the mesh.
Definition 3d.h:1233
void jo_3d_free_mesh(const jo_3d_mesh *const mesh)
Free a mesh created with jo_3d_create_mesh().
bool __jo_3d_slave_draw_ranges_from(const jo_3d_mesh *const mesh, const unsigned int first_point, const unsigned int point_count, const jo_3d_polygon_range *const ranges, const int range_count)
jo_3d_slave_mesh_draw_ranges() with the points of the ranges known (see __jo_3d_draw_ranges_from())
static __jo_force_inline void jo_3d_restore_scale(void)
Scale of 1 (nothing changes): the scale of jo_3d_set_scale() is in the current matrix,...
Definition 3d.h:1369
void jo_3d_set_front_layer(const int shift)
The next 3D polygons (of the master CPU) are a front layer: drawn after (over) all the other polygons...
static __jo_force_inline void jo_3d_rotate_matrix_rad_x(float x)
Rotate 3D matrix using radian (X axis).
Definition 3d.h:1031
static __jo_force_inline void jo_3d_mesh_draw(jo_3d_mesh *const mesh)
Draw a mesh.
Definition 3d.h:1181
static __jo_force_inline void jo_3d_translate_matrix_z(int z)
Translate 3D matrix (Z axis).
Definition 3d.h:1148
static __jo_force_inline void jo_3d_draw_sprite_at(const int sprite_id, const int x, const int y, const int z)
Draw a sprite.
Definition 3d.h:1280
static __jo_force_inline void jo_3d_rotate_matrix_rad_y(float y)
Rotate 3D matrix using radian (Y axis).
Definition 3d.h:1039
short box[6]
Definition 3d.h:1662
static __jo_force_inline bool jo_3d_is_wireframe(void)
Check the wireframe mode (see jo_3d_set_wireframe()).
Definition 3d.h:1532
bool jo_3d_set_texture_mipmaps(const int sprite_id)
Create smaller copies of a texture (half and quarter size, "mipmaps") used when the texture is drawn ...
void jo_3d_set_mesh_polygon_color_ex(jo_3d_mesh *const mesh, const jo_color color, const unsigned int index, bool wireframe)
Set the color on one polygon on the mesh with wireframe option.
static __jo_force_inline void jo_3d_camera_set_viewpoint(jo_camera *const cam, const int x, const int y, const int z)
Set the viewpoint of the camera (where the cameraman is).
Definition 3d.h:369
static __jo_force_inline void jo_3d_display_level(const unsigned short level)
Set the display level of the viewing volume.
Definition 3d.h:1474
void __jo_3d_scale(const jo_fixed x, const jo_fixed y, const jo_fixed z)
Scale the current matrix (Internal usage).
void jo_3d_set_mesh_polygon_texture_bank(jo_3d_mesh *const mesh, const int sprite_id, const jo_palette *const palette, const int bank, const unsigned int index)
Set a texture of 16 colors on one polygon, its colors taken in a bank of 16 colors of a palette (in p...
short nz
Definition 3d.h:1659
jo_3d_polygon_attribute * attributes
Definition 3d.h:182
unsigned short jo_3d_set_mesh_gouraud(jo_3d_mesh *const mesh, const jo_color *const tables)
Gouraud shading of the whole mesh: one table of 4 colors per polygon (a color per vertex,...
bool jo_3d_set_mesh_polygon_environment(jo_3d_mesh *const mesh, const unsigned int index)
A polygon shows the environment map of its mesh (see jo_3d_set_mesh_environment()): its gouraud table...
void jo_3d_slave_begin(void)
Prepare the 3D drawing of the slave CPU (call it on the master CPU, before jo_core_exec_on_slave()).
static __jo_force_inline void jo_3d_set_quad_vertices(jo_vertice *const vertices, const jo_vertice *const center, const jo_vertice *const right, const jo_vertice *const down)
Fill the 4 vertices of a quad (a parallelogram) from its center and 2 half edges, in the order of JO_...
Definition 3d.h:102
static __jo_force_inline void jo_3d_draw(jo_3d_quad *const quad)
Draw a quadrilateral.
Definition 3d.h:1166
bool __jo_3d_draw_ranges(const jo_3d_polygon_data *const pdata, const unsigned int point_count, const jo_3d_polygon_range *const ranges, const int range_count)
int jo_3d_slave_get_current_command_count(void)
Commands drawn by the slave CPU since jo_3d_slave_begin() (0 after jo_3d_slave_end()).
int jo_3d_slave_get_max_commands(void)
Commands the slave CPU can draw in a frame (the others are dropped, jo_3d_slave_mesh_draw() returns f...
static __jo_force_inline void jo_3d_add_polygon_range(jo_3d_polygon_range *const ranges, int *const range_count, const int first, const int count)
Add polygons to a list of ranges (see jo_3d_mesh_draw_ranges()): joined to the last range when they f...
Definition 3d.h:1214
void jo_3d_set_mesh_transparency(jo_3d_mesh *const mesh, const bool enabled)
Enable/Disable transparency on the mesh.
static __jo_force_inline void jo_3d_set_color(jo_3d_quad *const quad, const jo_color color)
Set the color on the quadrilateral.
Definition 3d.h:948
void jo_3d_transform_point(const jo_pos3D_fixed *const in, jo_pos3D_fixed *out)
Transform a point by the current matrix (for instance a world position into the view space,...
jo_3d_mesh * jo_3d_create_indexed_mesh(const unsigned int point_count, const unsigned int polygon_count)
Create an empty mesh made of shared points and polygons (indexes of the points).
unsigned short draw_mode
Definition 3d.h:169
static __jo_force_inline void jo_3d_rotate_matrix_rad(float x, float y, float z)
Rotate 3D matrix using radian.
Definition 3d.h:1021
unsigned short count
Definition 3d.h:189
unsigned short first
Definition 3d.h:331
static __jo_force_inline jo_3d_mesh * jo_3d_create_mesh(const unsigned int quad_count)
Create a mesh programmatically from vertices.
Definition 3d.h:496
short right
Definition 3d.h:1627
void jo_3d_set_mesh_light(jo_3d_mesh *const mesh, const bool enabled)
Enable/Disable light on the mesh.
jo_pos3D_fixed * points
Definition 3d.h:178
void jo_3d_set_mesh_texture(jo_3d_mesh *const mesh, const int sprite_id)
Set a texture on the mesh.
static __jo_force_inline bool jo_3d_window(const int left, const int top, const int right, const int bottom, const int z_limit, const int center_x, const int center_y)
Sets up a window region on the projection surface.
Definition 3d.h:1394
void jo_3d_slave_transform_point(const jo_pos3D_fixed *const in, jo_pos3D_fixed *out)
Transform a point by the matrix of the slave CPU (call it on the slave CPU, see jo_3d_transform_point...
bool jo_3d_set_texture_subdivision_near_only(const int sprite_id)
Like jo_3d_set_texture_subdivision(), but only the polygons that cross the near plane (or go very far...
unsigned short direction
Definition 3d.h:172
static __jo_force_inline void jo_3d_camera_init(jo_camera *const cam)
Initialize the camera with default values.
Definition 3d.h:401
short nx
Definition 3d.h:1657
unsigned char sort
Definition 3d.h:167
static __jo_force_inline void jo_3d_rotate_matrix_angle_x(const jo_angle x)
Rotate 3D matrix using jo_angle (X axis).
Definition 3d.h:1068
bool jo_3d_set_mesh_environment(jo_3d_mesh *const mesh, const int sprite_id, const int tiles)
Environment map of a mesh (a reflection, like the paint of a car): its polygons set by jo_3d_set_mesh...
static __jo_force_inline void jo_3d_rotate_matrix_z(short z)
Rotate 3D matrix using degree (Z axis).
Definition 3d.h:1011
bool jo_3d_set_sprite_fade(const int sprite_id, const jo_palette *const palette, const int bank)
A standing sprite that fades with the distance (see jo_3d_set_fade_distances()): its 16 colors copied...
bool jo_3d_slave_is_sphere_visible(const jo_pos3D_fixed *const center, const jo_fixed radius, const jo_fixed max_distance)
jo_3d_is_sphere_visible() for the slave CPU: with the rectangle of jo_3d_set_view_rect() as it was at...
int d
Definition 3d.h:1661
unsigned short color
Definition 3d.h:170
short ny
Definition 3d.h:1658
static __jo_force_inline bool jo_3d_slave_mesh_draw(const jo_3d_mesh *const mesh)
Draw a mesh on the slave CPU (call it on the slave CPU, between jo_3d_slave_begin() and jo_3d_slave_e...
Definition 3d.h:1940
void jo_3d_slave_set_guard_band(const int pixels)
Change the guard band of the objects drawn by the slave CPU (call it on the slave CPU,...
void __jo_3d_look_at(const jo_fixed *const camera, const jo_fixed *const target, const jo_angle angle)
Multiply the current matrix by a camera matrix (Internal usage).
unsigned short gouraud_table
Definition 3d.h:171
jo_pos3D jo_vertice
Vertice structure.
Definition 3d.h:87
void jo_3d_push_matrix(void)
Push 3D matrix.
unsigned int polygon_count
Definition 3d.h:181
static __jo_force_inline void jo_3d_light_fixed(const jo_fixed x, const jo_fixed y, const jo_fixed z)
Use a light source: its direction as a unit vector.
Definition 3d.h:781
static __jo_force_inline void jo_3d_light(const int x, const int y, const int z)
Use a light source.
Definition 3d.h:765
void jo_3d_slave_set_tint(const unsigned short tint)
Tint the next meshes drawn by the slave CPU (call it on the slave CPU).
void jo_3d_slave_pop_matrix(void)
Pop the matrix of the slave CPU (call it on the slave CPU, see jo_3d_pop_matrix()).
void jo_3d_free_sprite_quad(const int sprite_id)
Delete sprite quad.
static __jo_force_inline void jo_3d_draw_list(jo_list *const list)
Draw a list of quadrilateral.
Definition 3d.h:1249
void jo_3d_set_mirror(const bool mirror)
The next polygons of the master CPU are seen in a mirror: their front faces are counterclockwise on t...
void jo_3d_set_mesh_polygon_gouraud(jo_3d_mesh *const mesh, const unsigned short table, const unsigned int index)
Give a gouraud table to one polygon of the mesh (the color of each of its 4 vertices is added to its ...
bool jo_3d_slave_push_matrix(void)
Push the matrix of the slave CPU (call it on the slave CPU, see jo_3d_push_matrix()).
static __jo_force_inline void jo_3d_camera_set_z_angle(jo_camera *const cam, const int angle)
Set the angle of the camera.
Definition 3d.h:393
void jo_3d_set_mesh_polygon_texture(jo_3d_mesh *const mesh, const int sprite_id, const unsigned int index)
Set a texture on one polygon on the mesh.
static __jo_force_inline void jo_3d_select_window(const int window)
Select the window used by jo_3d_window() and by the next drawings.
Definition 3d.h:1429
bool jo_3d_slave_mesh_draw_ranges(const jo_3d_mesh *const mesh, const unsigned int point_count, const jo_3d_polygon_range *const ranges, const int range_count)
Draw some ranges of polygons of a mesh on the slave CPU, without copying them (see jo_3d_mesh_draw_ra...
void jo_3d_slave_set_scale_fixed(const jo_fixed x, const jo_fixed y, const jo_fixed z)
Scale the matrix of the slave CPU (call it on the slave CPU, see jo_3d_set_scale_fixed()).
void jo_3d_set_texture_subdivision_error(const int sprite_id, const int pixels)
Distortion of a texture over which its polygons are drawn in parts (see jo_3d_set_texture_subdivision...
static __jo_force_inline jo_3d_mesh * jo_3d_create_mesh_from_vertices(const unsigned int quad_count, jo_vertice *const vertices)
Create a mesh programmatically from vertices.
Definition 3d.h:486
jo_fixed(* matrix)[3]
Definition 3d.h:330
void jo_3d_set_mesh_polygon_transparency(jo_3d_mesh *const mesh, const bool enabled, const unsigned int index)
Enable/Disable transparency on one polygon on the mesh.
static __jo_force_inline void jo_3d_set_mesh_normal(jo_3d_mesh *const mesh, const jo_fixed x, const jo_fixed y, const jo_fixed z, const unsigned int index)
Set quad normal in mesh.
Definition 3d.h:739
static __jo_force_inline unsigned int jo_3d_get_vertices_count(void)
Get vertice count.
Definition 3d.h:439
jo_3d_polygon * polygons
Definition 3d.h:180
short left
Definition 3d.h:1625
#define JO_3D_MAX_GUARD_BAND
Biggest guard band around the screen (pixels): the coordinates of the VDP1 are limited.
Definition 3d.h:1495
struct __jo_may_alias jo_3d_quad
Quadrilateral shape structure.
#define JO_3D_AXIS_X
X axis for __jo_3d_rotate().
Definition 3d.h:298
void jo_3d_slave_rotate(const int axis, const jo_angle angle)
Rotate the matrix of the slave CPU around an axis by a precise angle (call it on the slave CPU): a sl...
static __jo_force_inline int jo_3d_get_depth_bias(void)
Get the depth added to the polygons and sprites (see jo_3d_set_depth_bias()).
Definition 3d.h:1551
static __jo_force_inline bool jo_3d_mesh_draw_ranges(const jo_3d_mesh *const mesh, const unsigned int point_count, const jo_3d_polygon_range *const ranges, const int range_count)
Draw some ranges of polygons of a mesh, without copying them (the points are transformed once).
Definition 3d.h:1202
void jo_3d_enable_dsp(const bool slave_cpu)
Transform the vertices with the SCU DSP (the third processor of the Saturn).
unsigned short count
Definition 3d.h:332
static __jo_force_inline void jo_3d_set_scalef(const float x, const float y, const float z)
Change scale using floating number.
Definition 3d.h:1341
bool jo_3d_slave_draw_standing_sprite(const int sprite_id, const jo_pos3D_fixed *const foot, const jo_fixed width, const jo_fixed height, const jo_fixed sway, const bool flip)
Draw a sprite standing on the ground and facing the camera on the slave CPU (see jo_3d_draw_standing_...
#define JO_3D_AXIS_Z
Z axis for __jo_3d_rotate().
Definition 3d.h:302
unsigned short __jo_3d_vertice_count
Vertice count of the current frame (Internal usage).
unsigned char plane
Definition 3d.h:166
void jo_3d_slave_set_kept_commands(const int count)
VDP1 commands kept for what is drawn after jo_3d_slave_end() (the weapon, the HUD): the polygons of t...
void jo_3d_set_packed_tint(const unsigned short tint)
Tint the next meshes drawn by the master CPU (see jo_3d_set_tint()).
void jo_3d_set_fewer_parts(const bool enabled)
Draw the polygons in parts only where it is needed to draw them at all (see jo_3d_set_texture_subdivi...
static __jo_force_inline void jo_3d_set_texture(jo_3d_quad *const quad, const int sprite_id)
Set a texture on the quadrilateral.
Definition 3d.h:605
unsigned short __jo_3d_displayed_polygon_count
Displayed polygon count of the current frame (Internal usage).
bool jo_3d_set_texture_subdivision(const int sprite_id)
Draw the polygons that use a texture in parts when they are near the camera (2 x 2 or 4 x 4 parts,...
jo_3d_mesh * jo_3d_create_sphere(const int radius, const unsigned int slices, const unsigned int stacks)
Create a sphere (UV sphere).
static __jo_force_inline void jo_3d_translate_matrix_x(int x)
Translate 3D matrix (X axis).
Definition 3d.h:1132
static __jo_force_inline void jo_3d_draw_scaled_billboard(const int sprite_id, const int x, const int y, const int z, const int scale)
Draw billboard with a specific scale.
Definition 3d.h:1308
static __jo_force_inline void jo_3d_rotate_matrix_angle_y(const jo_angle y)
Rotate 3D matrix using jo_angle (Y axis).
Definition 3d.h:1076
static __jo_force_inline void jo_3d_translate_matrix_y(int y)
Translate 3D matrix (Y axis).
Definition 3d.h:1140
void jo_3d_set_mesh_color_ex(jo_3d_mesh *const mesh, const jo_color color, bool wireframe)
Set the color on the mesh.
static __jo_force_inline void jo_3d_set_scale(const int x, const int y, const int z)
Change scale.
Definition 3d.h:1351
void jo_3d_set_tint(const int r, const int g, const int b)
Tint the next meshes drawn by the master CPU: added to the colors of their gouraud tables (the light ...
short unused
Definition 3d.h:1660
unsigned short jo_3d_add_gouraud_tables(const jo_color *const tables, const unsigned int count)
Add gouraud tables in the VDP1 VRAM (4 colors per table, one per vertex of a polygon).
void jo_3d_create_plane(jo_3d_quad *const quad, jo_vertice *const vertices)
Create a four vertices polygon (Quadrilateral shape).
void __jo_3d_translate(const jo_fixed x, const jo_fixed y, const jo_fixed z)
Translate the current matrix (Internal usage).
void jo_3d_set_mesh_high_speed_shrink(jo_3d_mesh *const mesh, const bool enabled)
Enable/Disable High Speed Shrink on the mesh.
static __jo_force_inline jo_3d_quad * jo_3d_get_sprite_quad(const int sprite_id)
Get sprite quad.
Definition 3d.h:542
Mesh structure.
Definition 3d.h:248
Points of a mesh transformed by their own matrix (see __jo_3d_draw_parts()).
Definition 3d.h:329
Polygon (quadrilateral, a triangle repeats the last vertex).
Definition 3d.h:158
Polygon attribute.
Definition 3d.h:165
Polygon data (3D model).
Definition 3d.h:177
Range of polygons of a mesh (see jo_3d_mesh_draw_ranges()).
Definition 3d.h:187
Plane of a polygon for the rays (see jo_3d_mesh_create_ray_planes()): the normal and its distance,...
Definition 3d.h:1656
A rectangle of the screen (pixels, the edges are in it).
Definition 3d.h:1624
#define jo_core_error(...)
Definition core.h:47
#define __JO_INDEX_IS_WRONG(INDEX, COUNT, WHAT)
Check an index given to a function of the engine (Internal usage, JO_DEBUG).
Definition core.h:55
jo_3d_mesh * mesh
Definition entity.h:11
jo_pos3D_fixed center
Definition entity.h:13
int radius
Definition entity.h:3
unsigned short tint
Definition entity.h:32
int height
Definition entity.h:4
jo_list_data data
Definition list.h:67
struct __jo_node jo_node
Node type.
Definition list.h:39
void * ptr
Definition list.h:59
void jo_list_foreach(jo_list *const list, jo_node_callback callback)
Iterate on the list.
List struct.
Definition list.h:74
#define JO_MULT_BY_256(X)
Multiply a variable by 256.
Definition math.h:111
#define JO_DEG_TO_ANGLE(X)
Convert a degree to jo_angle.
Definition math.h:481
#define JO_MULT_BY_65536(X)
Multiply a variable by 65536.
Definition math.h:147
#define JO_PALETTE_MAX
Define the maximum of palette (the 256 colors palettes of the color RAM).
Definition sega_saturn.h:157
jo_3d_polygon_data data
Definition 3d.h:242
jo_3d_polygon_attribute attribute
Definition 3d.h:243
Quadrilateral shape structure.
Definition 3d.h:241
void jo_sprite_draw(const int sprite_id, const jo_pos3D *const pos, const bool centered_style_coordinates, const bool billboard)
(internal engine usage)
jo_sprite_attributes __jo_sprite_attributes
Current displayed sprite attribute (internal engine usage).
#define __JO_SPRITE_IS_MISSING(SPRITE_ID)
Check the id of a sprite given to a function of the engine (Internal usage, JO_DEBUG).
Definition sprites.h:102
#define JO_NO_ZOOM
Value used to keep the original scale (1.0 in jo_fixed).
Definition sprites.h:402
Camera structure.
Definition 3d.h:223
jo_angle z_angle
Definition 3d.h:234
jo_fixed z
Definition types.h:106
#define __jo_force_inline
force inline attribute (and prevent Doxygen prototype parsing bug)
Definition types.h:39
short jo_angle
Angle.
Definition types.h:65
int y
Definition types.h:87
unsigned short jo_color
15 bits color type
Definition types.h:53
jo_fixed x
Definition types.h:104
jo_fixed y
Definition types.h:105
jo_fixed fixed_scale_y
Definition types.h:290
int jo_fixed
Fixed point Q16.16 number.
Definition types.h:59
int x
Definition types.h:86
int z
Definition types.h:88
jo_fixed fixed_scale_x
Definition types.h:289
Palette contents struct.
Definition types.h:268
3D position
Definition types.h:85
3D position using fixed numbers
Definition types.h:103
Vector for 3D computation using integer.
Definition types.h:158
void __jo_vdp1_set_window(const short left, const short top, const short right, const short bottom, const short zlimit, const short center_x, const short center_y)
Set the current 3D window (internal usage).
bool __jo_vdp1_wireframe
Wireframe mode (internal usage, see jo_3d_set_wireframe()).
jo_fixed __jo_vdp1_projection_distance
Projection distance in Q16.16 (internal usage, see jo_3d_perspective_angle()).
void __jo_vdp1_set_window_clip(const bool clip)
The 3D polygons of the current window clipped to its rectangle (internal usage, see jo_3d_window_clip...
int __jo_vdp1_depth_bias
Depth added to the keys of the commands (see jo_3d_set_depth_bias()).
unsigned short __jo_vdp1_display_level
Near clipping divisor (internal usage, see jo_3d_display_level()).
bool __jo_vdp1_windows_apart
The windows drawn one after the other (internal usage, see jo_3d_set_windows_apart()).