![]() |
Jo Engine 2026.11.6
Jo Sega Saturn Engine
|
Jo Engine water: a sea with waves around the camera (see below), objects seen through it, floating hulls. More...
Go to the source code of this file.
Data Structures | |
| struct | jo_water_wave |
| A wave of the swell (a sine along a direction). More... | |
| struct | jo_water_level |
| A level of the grid. More... | |
| struct | jo_water_steps |
| Gouraud steps per channel (16: the color as it is). More... | |
| struct | jo_water_config |
| Configuration of the water (jo_water_default_config(), then change what you need). More... | |
| struct | jo_water_point |
| Height and slopes of the surface at a point (see jo_water_sample()). More... | |
| struct | jo_water_floating |
| An object that falls in the water and floats on the waves (a crate, a barrel, a buoy): see jo_water_float(). More... | |
Macros | |
| #define | JO_WATER_MAX_WAVES |
| Waves at most in the swell. | |
| #define | JO_WATER_MAX_LEVELS |
| Levels at most. | |
| #define | JO_WATER_MAX_CELLS |
| Quads on a side of a level at most. | |
| #define | JO_WATER_MAX_OBJECTS |
| Objects under the water at most. | |
| #define | JO_WATER_MAX_ABOVE |
| Objects above the water given in a frame at most (see jo_water_add_above()). | |
| #define | JO_WATER_DIP_LEVELS |
| Depth levels of a jo_water_dip at most. | |
Typedefs | |
| typedef struct s_jo_water | jo_water |
| The water (see jo_water_create()). | |
| typedef struct s_jo_water_object | jo_water_object |
| An object under the water (see jo_water_add_model()). | |
| typedef struct s_jo_water_dip | jo_water_dip |
| An object on the water whose polygons under the surface are seen through the water (the hull of a boat, of a jet ski: see jo_water_add_dip()). | |
Enumerations | |
| enum | jo_water_look_kind { JO_WATER_LOOK_DEFAULT , JO_WATER_LOOK_MINT_LAGOON , JO_WATER_LOOK_TROPICAL_TEAL , JO_WATER_LOOK_MERMAID_BLUE , JO_WATER_LOOK_OCEAN_BLUE , JO_WATER_LOOK_FRENCH_BLUE , JO_WATER_LOOK_DEEP_CONTRAST , JO_WATER_LOOK_BRIGHT_TURQUOISE , JO_WATER_LOOK_CARIBBEAN , JO_WATER_LOOK_DEEP_PACIFIC , JO_WATER_LOOK_SUNNY_BEACH , JO_WATER_LOOK_COUNT } |
| The standard looks of the water (its color and the light of its waves, see jo_water_config_look()). More... | |
| enum | jo_water_swell_kind { JO_WATER_SWELL_GENTLE , JO_WATER_SWELL_CHOPPY , JO_WATER_SWELL_STORM , JO_WATER_SWELL_COUNT } |
| The standard swells (see jo_water_swell()): waves of 130 to 700 units, for quads of 16 to 64 units near the camera (jo_water_config.levels: a wave is drawn on the levels with min_cells_per_wave quads per wavelength). More... | |
Functions | |
| void | jo_water_default_config (jo_water_config *const config) |
| A configuration that works: 4 levels (quads of 8, 16, 32, 64 units), the swell JO_WATER_SWELL_CHOPPY, the look JO_WATER_LOOK_DEFAULT. | |
| static __jo_force_inline void | __water_set_look (jo_water_config *const config, const jo_color color, const signed char shallow_r, const signed char shallow_g, const signed char shallow_b, const signed char deep_r, const signed char deep_g, const signed char deep_b, const int sky, const int slope_light_min, const int slope_light_max, const int glint) |
| Set the values of a look (see jo_water_config_look()). | |
| static __jo_force_inline void | jo_water_config_look (jo_water_config *const config, const jo_water_look_kind look) |
| Set a standard look in a configuration: color, shallow, deep, sky, slope_light_min, slope_light_max, glint (the rest as it is; for a water already made: then jo_water_set_look()). | |
| static __jo_force_inline int | jo_water_look_blend (const jo_water_look_kind look) |
| The mix of the water with the bottom of the sea that goes with a standard look (see jo_water_blend_with_bottom()). | |
| static __jo_force_inline void | jo_water_blend_with_bottom (const int blend) |
| The water seen through: the VDP2 mixes the RGB pixels of the sprites (the water, the objects under it, see jo_water_add_model()) with the screen behind them (the bottom of the sea: RBG0 for instance); the pixels of the palette stay opaque (the objects above the water: their colors in the color RAM with the MSB at 0). | |
| static __jo_force_inline void | __water_set_wave (jo_water_wave *const wave, const int length, const int direction, const jo_fixed height, const int period) |
| Set a wave (see jo_water_swell()). | |
| static __jo_force_inline int | jo_water_swell (jo_water_wave *const waves, const jo_water_swell_kind swell) |
| A standard swell (its directions not along the grid of the water). | |
| jo_water * | jo_water_create (const jo_water_config *const config) |
| Create the water: load the textures, create the grid. | |
| void | jo_water_update (jo_water *const w, const int frame, const int x, const int y, const int z, const jo_angle heading) |
| Move the waves to the time of the frame and the grid around the camera, compute the heights and the light. | |
| void | jo_water_draw (jo_water *const w) |
| Draw the water (after jo_3d_camera_look_at()). | |
| void | jo_water_draw_with (jo_water *const w, void(*objects)(void), void(*objects_on_slave)(void)) |
| Draw the water and the objects on it: the master CPU draws some objects while the slave CPU draws the water near the camera, then other objects (the time of the drawing on both CPUs: the slave CPU computes fewer waves, see the balance of jo_water_update()). | |
| int | jo_water_quad_side (const jo_water *const w, const int x, const int z) |
| Side of the quads of the water drawn at a point (the finest level that covers it, see jo_water_config.levels): an object seen through the water (under it) is sorted nearer than the point where it is seen by about half of it (a quad is sorted at its center). | |
| jo_fixed | jo_water_height (const jo_water *const w, const int x, const int z) |
| Height of the surface at a point (the waves, the splashes, the wave fronts at the time of jo_water_update()). | |
| jo_fixed | jo_water_drawn_height (const jo_water *const w, const int x, const int z) |
| Height of the surface as it is drawn at a point (the vertices of the finest level that covers it, interpolated): cheap (no sine), for many points (along a line of sight); the waves (jo_water_wave_height()) outside of the levels. | |
| jo_fixed | jo_water_wave_height (const jo_water *const w, const int x, const int z) |
| Height of the waves at a point, without the splashes and the wave fronts (faster than jo_water_height(): many points, for instance along a line of sight). | |
| void | jo_water_sample (const jo_water *const w, const int x, const int z, jo_water_point *const point) |
| Height and slopes of the surface at a point: for an object on the water (its height, its tilt). | |
| void | jo_water_floating_init (jo_water_floating *const f, const int x, const int z, const int height, const int half, const int sink) |
| Start an object above the water (it falls, see jo_water_float()). | |
| void | jo_water_float (jo_water *const w, jo_water_floating *const f) |
| Move a floating object (once per frame, after jo_water_update()): it falls (gravity), splashes in the water (a ring of waves as high as its speed, see jo_water_drop()), then floats: a damped spring toward the surface under it, tilted with the slope of the surface (jo_water_sample()). | |
| void | jo_water_set_waves (jo_water *const w, const jo_water_wave *const waves, const int count) |
| Change the swell (a calm sea, a storm, the wind turns). | |
| void | jo_water_set_swell (jo_water *const w, const jo_fixed scale) |
| Strength of the swell: the heights of the waves x scale (a storm that grows, a calm that comes). | |
| void | jo_water_drop (jo_water *const w, const int x, const int z, const int height) |
| An object falls in the water: a ring of waves goes away from the point (near the camera only). | |
| void | jo_water_wave_front (jo_water *const w, const int x, const int z, const jo_angle direction, const int height, const int width) |
| A straight wave (2 crests, the second one the highest) that goes from a point in a direction: it grows, then fades out (a half sine over config.front_life frames; near the camera only). | |
| void | jo_water_foam (jo_water *const w, const int x, const int z, const int radius, const int life) |
| Foam on the water (a trail, a wake, a splash): a disc of the foam grid (cells of 8 units around the camera, 1024 units: the foam out of it is lost), white at once, it fades out in life frames (the foam already there and longer is kept). The quads near the camera get the foam texture, more of it with more foam. | |
| void | jo_water_set_depth_map (jo_water *const w, const unsigned char *const map, const int size, const int shift, const int x, const int z) |
| The depth of the water around (a map of bytes: 0 the shore, 255 deep): the shallow water is lighter (config.shore), the waves break on the shore (config.surf). | |
| int | jo_water_foam_at (const jo_water *const w, const int x, const int z) |
| Foam at a point (0 to 255, see jo_water_foam()). | |
| void | jo_water_set_sun (jo_water *const w, const jo_angle azimuth, const jo_angle elevation) |
| Position of the sun (the light, the glints, the spot). | |
| void | jo_water_set_textured (jo_water *const w, const bool textured) |
| The foam texture or not (see jo_water_config.textured). | |
| const jo_water_config * | jo_water_get_config (const jo_water *const w) |
| The configuration of the water (read only: the look can be changed with jo_water_set_look()). | |
| jo_color | jo_water_seen_color (const jo_water *const w, const jo_color object, const int amount) |
| The color of the water seen from above (its color with the light of config.shallow: the face of a wave toward the camera), 5 to 21 steps per channel (a gouraud of 16 +/- 5 stays in 0 to 31): the color of an object under the water is mixed with it. | |
| void | jo_water_set_look (jo_water *const w, const jo_water_config *const look) |
| Change the look (the colors and the light: color, shallow, deep, sky, slope_light_min/max, glint, spot, spot_distance, caustics, reflection, foam_white, foam_color, shore, shallow_depth, surf, bottom, bottom_depth, see_through, grain of the configuration). | |
| int | jo_water_add_model (jo_water *const w, jo_3d_model *const model, const int amount, const int far, jo_water_object **const objects) |
| Put a model under the water: an object per group of the model (OBJ o or g: a rock, the foot of a pillar, a part of a wreck; the whole model if it has no group). Its colors become its colors seen through the water: RGB colors, colors of the palette, textures of 16 colors (a color lookup table of 32 bytes each, the pixels are not copied) and RGB textures (copied); its gouraud shading stays, not lit (the light of the sun under the water is diffuse). | |
| jo_water_object * | jo_water_add_mesh (jo_water *const w, jo_3d_mesh *const mesh, const int first, const int count, const int amount, const int far) |
| Put polygons of a mesh under the water (see jo_water_add_model()): a mesh made by the program, its points changed in any frame (see jo_water_reshape()). | |
| void | jo_water_place (jo_water_object *const o, const int x, const int y, const int z, const jo_angle heading) |
| Place the space of an object (the space of the points of its mesh): the world by default. | |
| void | jo_water_show (jo_water_object *const o, const bool shown, const unsigned int hidden) |
| Show or hide an object, hide some of its polygons. | |
| void | jo_water_reshape (jo_water_object *const o) |
| The points of the mesh of an object changed: its size and its depth again (after jo_water_show(): only the polygons drawn). | |
| void | jo_water_set_far (jo_water_object *const o, const int far) |
| Change the distance where an object is not drawn any more (units: |dx| + |dz|). | |
| void | jo_water_add_above (jo_water *const w, const int x, const int y, const int z, const int radius, const int key_offset) |
| An object above the water in front of which the objects under the water stay (a jet ski, a buoy, a boat): an object under the water that it covers on the screen is sorted behind it. Call it each frame before jo_water_draw_with() (forgotten after it). | |
| jo_water_dip * | jo_water_add_dip (jo_water *const w, jo_3d_mesh *const mesh, const int levels, const short *const amounts, const jo_fixed *const depths, const int palette_offset) |
| Prepare a floating object: its polygons under the surface take their colors seen through the water, deeper: more of the water (see jo_water_dip_mesh()); its own attributes are kept for the polygons above the jo_water. | |
| void | jo_water_dip_mesh (jo_water_dip *const d, const jo_fixed surface, const jo_angle pitch, const jo_angle roll) |
| Set the colors of the polygons of a floating object from the depth of their middles under the surface (call it before it is drawn). | |
Jo Engine water: a sea with waves around the camera (see below), objects seen through it, floating hulls.
| struct jo_water_wave |
A wave of the swell (a sine along a direction).
| Data Fields | ||
|---|---|---|
| int | direction | |
| jo_fixed | height | |
| int | length | |
| int | period | |
| struct jo_water_steps |
| struct jo_water_config |
Configuration of the water (jo_water_default_config(), then change what you need).
| Data Fields | ||
|---|---|---|
| int | ahead | |
| int | bottom | |
| int | bottom_depth | |
| int | caustics | |
| jo_color | color | |
| jo_water_steps | deep | |
| int | fade | |
| jo_color | foam_color | |
| int | foam_white | |
| int | front_length | |
| int | front_life | |
| int | front_speed | |
| int | glint | |
| bool | grain | |
| int | level_count | |
| const jo_water_level * | levels | |
| int | min_cells_per_wave | |
| const char * | patterns_file | |
| int | reflection | |
| int | see_through | |
| jo_water_steps | shallow | |
| int | shallow_depth | |
| jo_water_steps | shore | |
| int | skirt | |
| int | sky | |
| int | slave_levels | |
| int | slope_light_max | |
| int | slope_light_min | |
| int | splash_length | |
| int | splash_life | |
| int | splash_speed | |
| int | spot | |
| int | spot_distance | |
| int | surf | |
| bool | textured | |
| int | update_cell | |
| int | wave_count | |
| const jo_water_wave * | waves | |
| struct jo_water_point |
Height and slopes of the surface at a point (see jo_water_sample()).
| Data Fields | ||
|---|---|---|
| jo_fixed | height | |
| jo_fixed | slope_x | |
| jo_fixed | slope_z | |
| struct jo_water_floating |
An object that falls in the water and floats on the waves (a crate, a barrel, a buoy): see jo_water_float().
| Data Fields | ||
|---|---|---|
| int | half | |
| bool | in_water | |
| int | sink | |
| jo_angle | tilt_x | |
| jo_angle | tilt_z | |
| jo_fixed | vy | |
| int | x | |
| jo_fixed | y | |
| int | z | |
| #define JO_WATER_DIP_LEVELS |
Depth levels of a jo_water_dip at most.
| #define JO_WATER_MAX_ABOVE |
Objects above the water given in a frame at most (see jo_water_add_above()).
| #define JO_WATER_MAX_CELLS |
Quads on a side of a level at most.
| #define JO_WATER_MAX_LEVELS |
Levels at most.
| #define JO_WATER_MAX_OBJECTS |
Objects under the water at most.
| #define JO_WATER_MAX_WAVES |
Waves at most in the swell.
| typedef struct s_jo_water jo_water |
The water (see jo_water_create()).
| typedef struct s_jo_water_dip jo_water_dip |
An object on the water whose polygons under the surface are seen through the water (the hull of a boat, of a jet ski: see jo_water_add_dip()).
| typedef struct s_jo_water_object jo_water_object |
An object under the water (see jo_water_add_model()).
| enum jo_water_look_kind |
The standard looks of the water (its color and the light of its waves, see jo_water_config_look()).
| enum jo_water_swell_kind |
The standard swells (see jo_water_swell()): waves of 130 to 700 units, for quads of 16 to 64 units near the camera (jo_water_config.levels: a wave is drawn on the levels with min_cells_per_wave quads per wavelength).
| Enumerator | |
|---|---|
| JO_WATER_SWELL_GENTLE | |
| JO_WATER_SWELL_CHOPPY | |
| JO_WATER_SWELL_STORM | |
| JO_WATER_SWELL_COUNT | |
|
static |
Set the values of a look (see jo_water_config_look()).
|
static |
Set a wave (see jo_water_swell()).
| void jo_water_add_above | ( | jo_water *const | w, |
| const int | x, | ||
| const int | y, | ||
| const int | z, | ||
| const int | radius, | ||
| const int | key_offset ) |
An object above the water in front of which the objects under the water stay (a jet ski, a buoy, a boat): an object under the water that it covers on the screen is sorted behind it. Call it each frame before jo_water_draw_with() (forgotten after it).
| w | Water (jo_water_create()) |
| x | Its center (units) |
| y | Its center (units, y down) |
| z | Its center (units) |
| radius | Its size (units) |
| key_offset | Its farthest sort key from the depth of its center (units: its depth bias, its size) |
| jo_water_dip * jo_water_add_dip | ( | jo_water *const | w, |
| jo_3d_mesh *const | mesh, | ||
| const int | levels, | ||
| const short *const | amounts, | ||
| const jo_fixed *const | depths, | ||
| const int | palette_offset ) |
Prepare a floating object: its polygons under the surface take their colors seen through the water, deeper: more of the water (see jo_water_dip_mesh()); its own attributes are kept for the polygons above the jo_water.
| w | Water (jo_water_create()) |
| mesh | Mesh (its polygons as drawn above the water) |
| levels | Depth levels (JO_WATER_DIP_LEVELS at most) |
| amounts | Of the color of the water at each level (/ 256) |
| depths | Under the surface where each level starts (jo_fixed units of the mesh, the first one usually 0) |
| palette_offset | Added to the colors of the palette before they are read (a mesh lit by the palette light: its colors are its darkest shade, see jo_3d_set_palette_light(): + shade x stride, the shade seen under the water) |
| jo_water_object * jo_water_add_mesh | ( | jo_water *const | w, |
| jo_3d_mesh *const | mesh, | ||
| const int | first, | ||
| const int | count, | ||
| const int | amount, | ||
| const int | far ) |
Put polygons of a mesh under the water (see jo_water_add_model()): a mesh made by the program, its points changed in any frame (see jo_water_reshape()).
| w | Water (jo_water_create()) |
| mesh | Mesh |
| first | First polygon of the object |
| count | Polygons |
| amount | Of the color of the water (/ 256) |
| far | Not drawn farther from the camera (units: |dx| + |dz|) |
| int jo_water_add_model | ( | jo_water *const | w, |
| jo_3d_model *const | model, | ||
| const int | amount, | ||
| const int | far, | ||
| jo_water_object **const | objects ) |
Put a model under the water: an object per group of the model (OBJ o or g: a rock, the foot of a pillar, a part of a wreck; the whole model if it has no group). Its colors become its colors seen through the water: RGB colors, colors of the palette, textures of 16 colors (a color lookup table of 32 bytes each, the pixels are not copied) and RGB textures (copied); its gouraud shading stays, not lit (the light of the sun under the water is diffuse).
| w | Water (jo_water_create()) |
| model | Model (jo_3d_load_model(); its points in the world, or in the space of each object: see jo_water_place()) |
| amount | Of the color of the water seen from above in its colors (/ 256: 0 its own colors) |
| far | Not drawn farther from the camera (units: |dx| + |dz|) |
| objects | The objects, a group each (output, JO_NULL: not needed) |
|
static |
The water seen through: the VDP2 mixes the RGB pixels of the sprites (the water, the objects under it, see jo_water_add_model()) with the screen behind them (the bottom of the sea: RBG0 for instance); the pixels of the palette stay opaque (the objects above the water: their colors in the color RAM with the MSB at 0).
| blend | Of the bottom: 0 (the water only) to 31 (almost only the bottom), see jo_water_look_blend() |
|
static |
Set a standard look in a configuration: color, shallow, deep, sky, slope_light_min, slope_light_max, glint (the rest as it is; for a water already made: then jo_water_set_look()).
| config | Configuration (jo_water_default_config() first) |
| look | The look |
| jo_water * jo_water_create | ( | const jo_water_config *const | config | ) |
Create the water: load the textures, create the grid.
| config | Configuration (copied) |
| void jo_water_default_config | ( | jo_water_config *const | config | ) |
A configuration that works: 4 levels (quads of 8, 16, 32, 64 units), the swell JO_WATER_SWELL_CHOPPY, the look JO_WATER_LOOK_DEFAULT.
| config | Configuration (output) |
| void jo_water_dip_mesh | ( | jo_water_dip *const | d, |
| const jo_fixed | surface, | ||
| const jo_angle | pitch, | ||
| const jo_angle | roll ) |
Set the colors of the polygons of a floating object from the depth of their middles under the surface (call it before it is drawn).
| d | Floating object (jo_water_add_dip()) |
| surface | The surface in the space of the mesh (jo_fixed units, y down: the height of the object - the height of the water) |
| pitch | Its pitch (jo_angle: turned around x after its roll, as drawn) |
| roll | Its roll (jo_angle: turned around z first) |
| void jo_water_draw | ( | jo_water *const | w | ) |
Draw the water (after jo_3d_camera_look_at()).
| void jo_water_draw_with | ( | jo_water *const | w, |
| void(* | objects )(void), | ||
| void(* | objects_on_slave )(void) ) |
Draw the water and the objects on it: the master CPU draws some objects while the slave CPU draws the water near the camera, then other objects (the time of the drawing on both CPUs: the slave CPU computes fewer waves, see the balance of jo_water_update()).
| w | Water (jo_water_create()) |
| objects | Draws objects on the master CPU (jo_3d_mesh_draw()...), JO_NULL: none |
| objects_on_slave | Draws objects on the slave CPU after the water (jo_3d_slave_mesh_draw()..., the matrix of the camera; the slave CPU uses the light set before jo_water_draw_with()), JO_NULL: none |
Height of the surface as it is drawn at a point (the vertices of the finest level that covers it, interpolated): cheap (no sine), for many points (along a line of sight); the waves (jo_water_wave_height()) outside of the levels.
| w | Water (jo_water_create()) |
| x | Position (units) |
| z | Position (units) |
| void jo_water_drop | ( | jo_water *const | w, |
| const int | x, | ||
| const int | z, | ||
| const int | height ) |
An object falls in the water: a ring of waves goes away from the point (near the camera only).
| w | Water (jo_water_create()) |
| x | Position (units) |
| z | Position (units) |
| height | Height of the first wave (units) |
| void jo_water_float | ( | jo_water *const | w, |
| jo_water_floating *const | f ) |
Move a floating object (once per frame, after jo_water_update()): it falls (gravity), splashes in the water (a ring of waves as high as its speed, see jo_water_drop()), then floats: a damped spring toward the surface under it, tilted with the slope of the surface (jo_water_sample()).
| w | Water (jo_water_create()) |
| f | Object |
| void jo_water_floating_init | ( | jo_water_floating *const | f, |
| const int | x, | ||
| const int | z, | ||
| const int | height, | ||
| const int | half, | ||
| const int | sink ) |
Start an object above the water (it falls, see jo_water_float()).
| f | Object |
| x | Position (units) |
| z | Position (units) |
| height | Height of its middle above the calm sea (units) |
| half | Half its height (units) |
| sink | It floats this much in the water (units) |
| void jo_water_foam | ( | jo_water *const | w, |
| const int | x, | ||
| const int | z, | ||
| const int | radius, | ||
| const int | life ) |
Foam on the water (a trail, a wake, a splash): a disc of the foam grid (cells of 8 units around the camera, 1024 units: the foam out of it is lost), white at once, it fades out in life frames (the foam already there and longer is kept). The quads near the camera get the foam texture, more of it with more foam.
| w | Water (jo_water_create()) |
| x | Center (units) |
| z | Center (units) |
| radius | Units (8 at least: a cell) |
| life | Frames (60 per second, 1020 at most); the edge of the disc lives half as long (a soft edge) |
| int jo_water_foam_at | ( | const jo_water *const | w, |
| const int | x, | ||
| const int | z ) |
Foam at a point (0 to 255, see jo_water_foam()).
| const jo_water_config * jo_water_get_config | ( | const jo_water *const | w | ) |
The configuration of the water (read only: the look can be changed with jo_water_set_look()).
Height of the surface at a point (the waves, the splashes, the wave fronts at the time of jo_water_update()).
| w | Water (jo_water_create()) |
| x | Position (units) |
| z | Position (units) |
|
static |
The mix of the water with the bottom of the sea that goes with a standard look (see jo_water_blend_with_bottom()).
| look | The look |
| void jo_water_place | ( | jo_water_object *const | o, |
| const int | x, | ||
| const int | y, | ||
| const int | z, | ||
| const jo_angle | heading ) |
Place the space of an object (the space of the points of its mesh): the world by default.
| o | Object (jo_water_add_model(), jo_water_add_mesh()) |
| x | Position (units) |
| y | Position (units, y down) |
| z | Position (units) |
| heading | Turned around y (jo_angle, as jo_3d_rotate_matrix_angle_y()) |
| int jo_water_quad_side | ( | const jo_water *const | w, |
| const int | x, | ||
| const int | z ) |
Side of the quads of the water drawn at a point (the finest level that covers it, see jo_water_config.levels): an object seen through the water (under it) is sorted nearer than the point where it is seen by about half of it (a quad is sorted at its center).
| w | Water (jo_water_create()) |
| x | Position (units) |
| z | Position (units) |
| void jo_water_reshape | ( | jo_water_object *const | o | ) |
The points of the mesh of an object changed: its size and its depth again (after jo_water_show(): only the polygons drawn).
| void jo_water_sample | ( | const jo_water *const | w, |
| const int | x, | ||
| const int | z, | ||
| jo_water_point *const | point ) |
Height and slopes of the surface at a point: for an object on the water (its height, its tilt).
| w | Water (jo_water_create()) |
| x | Position (units) |
| z | Position (units) |
| point | Height and slopes (output) |
The color of the water seen from above (its color with the light of config.shallow: the face of a wave toward the camera), 5 to 21 steps per channel (a gouraud of 16 +/- 5 stays in 0 to 31): the color of an object under the water is mixed with it.
| w | Water (jo_water_create()) |
| object | The color of the object |
| amount | Of the water (/ 256) |
| void jo_water_set_depth_map | ( | jo_water *const | w, |
| const unsigned char *const | map, | ||
| const int | size, | ||
| const int | shift, | ||
| const int | x, | ||
| const int | z ) |
The depth of the water around (a map of bytes: 0 the shore, 255 deep): the shallow water is lighter (config.shore), the waves break on the shore (config.surf).
| w | Water (jo_water_create()) |
| map | size x size bytes, the row z then the column x (JO_NULL: no map, deep everywhere) |
| size | Cells on a side (a power of 2) |
| shift | A cell is 1 << shift units |
| x | Corner of the map (units) |
| z | Corner of the map (units) |
| void jo_water_set_far | ( | jo_water_object *const | o, |
| const int | far ) |
Change the distance where an object is not drawn any more (units: |dx| + |dz|).
| void jo_water_set_look | ( | jo_water *const | w, |
| const jo_water_config *const | look ) |
Change the look (the colors and the light: color, shallow, deep, sky, slope_light_min/max, glint, spot, spot_distance, caustics, reflection, foam_white, foam_color, shore, shallow_depth, surf, bottom, bottom_depth, see_through, grain of the configuration).
Position of the sun (the light, the glints, the spot).
| w | Water (jo_water_create()) |
| azimuth | Direction (jo_angle, 0 = toward +z) |
| elevation | Height above the horizon (jo_angle) |
Strength of the swell: the heights of the waves x scale (a storm that grows, a calm that comes).
| w | Water (jo_water_create()) |
| scale | jo_fixed (JO_FIXED_1: the heights of the waves as they are) |
| void jo_water_set_textured | ( | jo_water *const | w, |
| const bool | textured ) |
The foam texture or not (see jo_water_config.textured).
| void jo_water_set_waves | ( | jo_water *const | w, |
| const jo_water_wave *const | waves, | ||
| const int | count ) |
Change the swell (a calm sea, a storm, the wind turns).
| w | Water (jo_water_create()) |
| waves | Waves (copied) |
| count | JO_WATER_MAX_WAVES at most |
| void jo_water_show | ( | jo_water_object *const | o, |
| const bool | shown, | ||
| const unsigned int | hidden ) |
Show or hide an object, hide some of its polygons.
| o | Object (jo_water_add_model(), jo_water_add_mesh()) |
| shown | Drawn (when it is in the view and near enough) |
| hidden | Polygons not drawn: bit k for the polygon k of the object (the first 32) |
|
static |
A standard swell (its directions not along the grid of the water).
| waves | The waves (output: JO_WATER_MAX_WAVES; jo_water_create() and jo_water_set_waves() copy them) |
| swell | The swell |
| void jo_water_update | ( | jo_water *const | w, |
| const int | frame, | ||
| const int | x, | ||
| const int | y, | ||
| const int | z, | ||
| const jo_angle | heading ) |
Move the waves to the time of the frame and the grid around the camera, compute the heights and the light.
| w | Water (jo_water_create()) |
| frame | Time (frames, 60 per second: jo_core_get_vblank_count(), the waves move at the same speed at any frame rate) |
| x | Camera position (units) |
| y | Camera position (units, y down) |
| z | Camera position (units) |
| heading | Direction of the camera (jo_angle, 0 = toward +z) |
| void jo_water_wave_front | ( | jo_water *const | w, |
| const int | x, | ||
| const int | z, | ||
| const jo_angle | direction, | ||
| const int | height, | ||
| const int | width ) |
A straight wave (2 crests, the second one the highest) that goes from a point in a direction: it grows, then fades out (a half sine over config.front_life frames; near the camera only).
| w | Water (jo_water_create()) |
| x | Start (units) |
| z | Start (units) |
| direction | Direction (jo_angle, 0 = toward +z) |
| height | Height of the crests (units) |
| width | Width of the wave (units) |
Height of the waves at a point, without the splashes and the wave fronts (faster than jo_water_height(): many points, for instance along a line of sight).
| w | Water (jo_water_create()) |
| x | Position (units) |
| z | Position (units) |