Jo Engine 2026.11.6
Jo Sega Saturn Engine
Loading...
Searching...
No Matches
water.h
Go to the documentation of this file.
1/*
2** Jo Sega Saturn Engine
3** Copyright (c) 2012-2026, Johannes Fetz (johannesfetz@gmail.com)
4** All rights reserved.
5**
6** Redistribution and use in source and binary forms, with or without
7** modification, are permitted provided that the following conditions are met:
8** * Redistributions of source code must retain the above copyright
9** notice, this list of conditions and the following disclaimer.
10** * Redistributions in binary form must reproduce the above copyright
11** notice, this list of conditions and the following disclaimer in the
12** documentation and/or other materials provided with the distribution.
13** * Neither the name of the Johannes Fetz nor the
14** names of its contributors may be used to endorse or promote products
15** derived from this software without specific prior written permission.
16**
17** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20** DISCLAIMED. IN NO EVENT SHALL Johannes Fetz BE LIABLE FOR ANY
21** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27*/
28
38
39#ifndef __JO_WATER_H__
40# define __JO_WATER_H__
41
42#if defined(JO_COMPILE_WITH_3D_SUPPORT) && defined(JO_COMPILE_WITH_DUAL_CPU_SUPPORT)
43
44/*
45** Water: a sea with waves around the camera, drawn by the VDP1 (quads with a light per vertex), seen through (the VDP2
46** mixes the water with the screen behind it).
47**
48** - the swell: a sum of waves (jo_water_wave: length, direction, height, period), changed at any time (jo_water_set_waves(),
49** jo_water_set_swell()): calm or rough sea, wind from any direction
50** - the surface: jo_water_sample() gives the height and the slopes at any point, for the objects on the water (a jet ski, a
51** buoy, a crate): the same waves as the drawn surface
52** - events: jo_water_drop() (a ring of waves where an object falls), jo_water_wave_front() (a straight wave that goes away)
53** - the grid: levels of quads around the camera, small quads near it, bigger and bigger farther (jo_water_level), then a flat
54** skirt to the horizon. The first levels are computed by the slave CPU, the far levels every 2 or 4 frames
55** - objects under the water: any model seen through the water, sorted with it (jo_water_add_model(), see below), a floating
56** hull with its part in the water seen through it (jo_water_add_dip())
57**
58** Units: 1 unit = 1/16 m. Y goes down (the calm surface is at y = 0, a crest at y < 0); the heights are up (> 0: a crest).
59** Time: in frames at 60 per second (the frame given to jo_water_update(): jo_core_get_vblank_count()).
60**
61** Usage:
62** jo_water_config config;
63** jo_water_default_config(&config);
64** config.levels = my_levels; ... (change what you need)
65** jo_water *sea = jo_water_create(&config);
66** each frame: jo_water_update(sea, frame, camera position, heading); then after jo_3d_camera_look_at(): jo_water_draw(sea)
67*/
68
70# define JO_WATER_MAX_WAVES (8)
72# define JO_WATER_MAX_LEVELS (6)
74# define JO_WATER_MAX_CELLS (24)
75
77typedef struct
78{
79 int length; // Wavelength (units). At least 4 quads of a level: on bigger quads, it is not drawn
80 int direction; // Where it goes (degrees, 0: toward +z, 90: toward +x). Not along the grid (0, 90...): crests along lines of vertices make bands
81 jo_fixed height; // Height of the crests (jo_fixed, units)
82 int period; // Time of a period (frames), its speed: length / period
84
86typedef struct
87{
88 int cell; // Side of its quads (units): the same as the previous level or a multiple of it
89 int side; // Side of the level (units): a multiple of its quads and of the quads of the next level,
90 // at least the side of the previous level + 4 quads of the next level
92
94typedef struct
95{
96 signed char r;
97 signed char g;
98 signed char b;
100
102typedef struct
103{
104 /* The grid */
105 const jo_water_level *levels; // From the camera (copied)
106 int level_count; // JO_WATER_MAX_LEVELS at most
107 int ahead; // Center of the levels in front of the camera (units)
108 int update_cell; // Levels with bigger quads: updated every 2 frames, bigger than 2 x: every 4 frames
109 int min_cells_per_wave; // A wave is drawn on the levels with at least this many quads per wavelength
110 int fade; // The waves fade out toward the edge of the last level that draws them (units)
111 int skirt; // The flat sea around the levels: up to this distance (units, 32767 at most)
112 int slave_levels; // The first levels drawn by the slave CPU (see jo_water_draw_with(); the others and the
113 // objects by the master CPU)
114 /* The swell */
115 const jo_water_wave *waves; // (copied; JO_NULL: the standard swell JO_WATER_SWELL_CHOPPY, see jo_water_swell())
116 int wave_count; // JO_WATER_MAX_WAVES at most
117 /* The look */
118 jo_color color; // Color of the water (the light of the vertices changes it)
119 jo_water_steps shallow; // Light where the camera looks into the water (the face of a wave toward the camera)
120 jo_water_steps deep; // Light at a low angle (far away, the back of a wave)
121 int sky; // Reflection of the sky at a low angle (steps, pale blue)
122 int slope_light_min;// Light of the slopes away from the sun (steps, < 0)
123 int slope_light_max;// Light of the slopes toward the sun (steps)
124 int glint; // White glints of the slopes toward the sun (steps for a slope of 1)
125 int spot; // Spot of the sun on the sea (steps at its center)
126 int spot_distance; // Distance of the spot from the camera with a sun 45 degrees high (units)
127 int caustics; // Moving light of the waves near the camera (steps, 0: none)
128 int reflection; // White streaks of the clouds reflected by the waves (steps at most, 0: none)
129 int foam_white; // Light of the foam (steps at full foam, see jo_water_foam())
130 jo_color foam_color; // White of the foam texture (the light of the vertices is added: under 31 - 10 per
131 // channel, the VDP1 doesn't saturate the gouraud)
132 jo_water_steps shore; // Light added in the shallow water (see jo_water_set_depth_map(): at depth 0)
133 int shallow_depth; // Depth (0 to 255) where the shallow water starts
134 int surf; // Foam of the waves on the shore (0 to 255 at depth 0, 0: none)
135 int bottom; // The bottom seen in the shallow water: a texture on the quads near the shore (with
136 // textured), its lines of light that move (steps at depth 0, 0: none; set
137 // before jo_water_create(): its tiles are made there)
138 int bottom_depth; // Depth (0 to 255) where the texture of the bottom stops
139 int see_through; // The water shallower than this (0 to 255, 0: none) is half transparent: the VDP1
140 // mixes it with the RGB polygons drawn behind it (the bottom near the shore,
141 // sorted behind the water), not with the rest (the VDP2 mixes the water with
142 // its bottom of the sea)
143 bool textured; // The foam texture on the quads near the camera where there is foam (else the light of
144 // the vertices only)
145 bool grain; // Without the texture: a light grain (hides the steps of the gouraud): GRAIN.TGA at the
146 // root of the CD (with the TGA module)
147 const char *patterns_file; // JO_NULL: the built-in patterns of the foam and of the bottom (in the program, see
148 // tools/make_water_patterns.py); else a level file with them (the section 'foam':
149 // tools/make_water_patterns.py --jol), read when the water is made
150 /* The events */
151 int splash_length; // Wavelength of the rings of jo_water_drop() (units)
152 int splash_speed; // Units per frame
153 int splash_life; // Frames
154 int front_length; // Wavelength of jo_water_wave_front() (units)
155 int front_speed; // Units per frame
156 int front_life; // Frames
158
160typedef struct
161{
162 jo_fixed height; // > 0: above the calm sea (the surface is at y = -height)
163 jo_fixed slope_x; // Height change per unit along x (jo_fixed, the normal is (-slope_x, 1, -slope_z))
164 jo_fixed slope_z; // Along z
166
168typedef struct s_jo_water jo_water;
169
175
176/*
177** Standard looks of the water and standard swells: inline helpers (no table: a constant look or swell costs only its
178** values in the code where it is used, nothing when it is not used).
179**
180** jo_water_default_config(&config);
181** jo_water_config_look(&config, JO_WATER_LOOK_TROPICAL_TEAL);
182** config.wave_count = jo_water_swell(waves, JO_WATER_SWELL_GENTLE); (jo_water_wave waves[JO_WATER_MAX_WAVES]: copied by
183** config.waves = waves; jo_water_create())
184** sea = jo_water_create(&config);
185** jo_water_blend_with_bottom(jo_water_look_blend(JO_WATER_LOOK_TROPICAL_TEAL));
186*/
187
189typedef enum
190{
191 JO_WATER_LOOK_DEFAULT, // Clear blue (jo_water_default_config())
192 JO_WATER_LOOK_MINT_LAGOON, // Pale green lagoon over white sand
193 JO_WATER_LOOK_TROPICAL_TEAL, // Blue green of the tropics
194 JO_WATER_LOOK_MERMAID_BLUE, // Bright blue lagoon
196 JO_WATER_LOOK_FRENCH_BLUE, // Deep saturated blue
197 JO_WATER_LOOK_DEEP_CONTRAST, // Dark blue, strong light on the waves
198 JO_WATER_LOOK_BRIGHT_TURQUOISE, // Bright turquoise, dark slopes
199 JO_WATER_LOOK_CARIBBEAN, // Light blue, very clear
200 JO_WATER_LOOK_DEEP_PACIFIC, // Deep navy blue
201 JO_WATER_LOOK_SUNNY_BEACH, // Turquoise of a sunny beach
204
206static __jo_force_inline void __water_set_look(jo_water_config * const config, const jo_color color, const signed char shallow_r,
207 const signed char shallow_g, const signed char shallow_b, const signed char deep_r,
208 const signed char deep_g, const signed char deep_b, const int sky,
209 const int slope_light_min, const int slope_light_max, const int glint)
210{
211 config->color = color;
212 config->shallow.r = shallow_r;
213 config->shallow.g = shallow_g;
214 config->shallow.b = shallow_b;
215 config->deep.r = deep_r;
216 config->deep.g = deep_g;
217 config->deep.b = deep_b;
218 config->sky = sky;
219 config->slope_light_min = slope_light_min;
220 config->slope_light_max = slope_light_max;
221 config->glint = glint;
222}
223
230{
231 switch (look)
232 {
234 __water_set_look(config, JO_COLOR_RGB(96, 196, 176), 4, 12, 10, 0, 4, 8, 4, -11, 6, 40);
235 break;
237 __water_set_look(config, JO_COLOR_RGB(40, 168, 168), 6, 16, 16, 0, 4, 12, 5, -12, 7, 44);
238 break;
240 __water_set_look(config, JO_COLOR_RGB(32, 148, 192), 6, 16, 18, 0, 2, 12, 5, -12, 7, 44);
241 break;
243 __water_set_look(config, JO_COLOR_RGB(24, 108, 200), 6, 14, 18, 0, 0, 10, 6, -12, 8, 48);
244 break;
246 __water_set_look(config, JO_COLOR_RGB(32, 72, 200), 8, 12, 20, 0, 0, 8, 7, -12, 8, 48);
247 break;
249 __water_set_look(config, JO_COLOR_RGB(24, 88, 168), 6, 18, 22, 0, 2, 10, 6, -14, 10, 60);
250 break;
252 __water_set_look(config, JO_COLOR_RGB(40, 176, 200), 4, 14, 14, 0, 0, 8, 4, -15, 8, 50);
253 break;
255 __water_set_look(config, JO_COLOR_RGB(88, 184, 216), 4, 12, 12, 0, 2, 6, 6, -12, 6, 40);
256 break;
258 __water_set_look(config, JO_COLOR_RGB(16, 64, 128), 8, 18, 24, 2, 4, 14, 7, -10, 10, 56);
259 break;
261 __water_set_look(config, JO_COLOR_RGB(40, 172, 184), 5, 16, 15, 1, 6, 10, 6, -9, 7, 36);
262 break;
263 default:
264 __water_set_look(config, JO_COLOR_RGB(64, 136, 168), 6, 19, 22, 6, 8, 18, 6, -7, 5, 40);
265 break;
266 }
267}
268
274{
275 switch (look)
276 {
280 return (10);
284 return (8);
287 return (6);
289 return (14);
291 return (7);
292 default:
293 return (12);
294 }
295}
296
309
312typedef enum
313{
314 JO_WATER_SWELL_GENTLE, // A sunny bay: a long low swell, small waves (crests of 1 to 3 units)
315 JO_WATER_SWELL_CHOPPY, // A rougher sea (the swell of jo_water_default_config(): crests of 2 to 9 units)
316 JO_WATER_SWELL_STORM, // A storm (crests of 3 to 16 units)
319
321static __jo_force_inline void __water_set_wave(jo_water_wave * const wave, const int length, const int direction, const jo_fixed height,
322 const int period)
323{
324 wave->length = length;
325 wave->direction = direction;
326 wave->height = height;
327 wave->period = period;
328}
329
336{
337 switch (swell)
338 {
340 __water_set_wave(&waves[0], 640, 12, 3 << 16, 320);
341 __water_set_wave(&waves[1], 350, 56, (3 << 16) / 2, 230);
342 __water_set_wave(&waves[2], 190, -36, 1 << 16, 160);
343 __water_set_wave(&waves[3], 150, 78, (3 << 16) / 4, 120);
344 return (4);
346 __water_set_wave(&waves[0], 700, -20, 16 << 16, 280);
347 __water_set_wave(&waves[1], 420, 25, 9 << 16, 200);
348 __water_set_wave(&waves[2], 240, -60, 5 << 16, 150);
349 __water_set_wave(&waves[3], 160, 70, 4 << 16, 110);
350 __water_set_wave(&waves[4], 130, -15, 3 << 16, 90);
351 return (5);
352 default:
353 __water_set_wave(&waves[0], 600, 10, 9 << 16, 300);
354 __water_set_wave(&waves[1], 330, 52, 4 << 16, 220);
355 __water_set_wave(&waves[2], 180, -38, 2 << 16, 160);
356 __water_set_wave(&waves[3], 150, 74, 3 << 16, 110);
357 __water_set_wave(&waves[4], 140, -66, (5 << 16) / 2, 100);
358 return (5);
359 }
360}
361
362
369
378void jo_water_update(jo_water * const w, const int frame, const int x, const int y, const int z, const jo_angle heading);
379
381void jo_water_draw(jo_water * const w);
382
391void jo_water_draw_with(jo_water * const w, void (*objects)(void), void (*objects_on_slave)(void));
392
401int jo_water_quad_side(const jo_water * const w, const int x, const int z);
402
409jo_fixed jo_water_height(const jo_water * const w, const int x, const int z);
410
420jo_fixed jo_water_drawn_height(const jo_water * const w, const int x, const int z);
421
429jo_fixed jo_water_wave_height(const jo_water * const w, const int x, const int z);
430
437void jo_water_sample(const jo_water * const w, const int x, const int z, jo_water_point * const point);
438
440typedef struct
441{
442 int x; // Position (units): moved by the game
443 int z;
444 jo_fixed y; // Height of its middle above the calm sea (jo_fixed units, up)
445 jo_fixed vy; // Vertical speed (jo_fixed units per frame, up)
446 int half; // Half its height (units): it touches the water when y - half reaches the surface
447 int sink; // It floats this much in the water (units, < 2 x half)
448 jo_angle tilt_x; // Its tilt on the slope of the surface (rotate around x, then z, then its heading)
452
461void jo_water_floating_init(jo_water_floating * const f, const int x, const int z, const int height, const int half, const int sink);
462
470void jo_water_float(jo_water * const w, jo_water_floating * const f);
471
477void jo_water_set_waves(jo_water * const w, const jo_water_wave * const waves, const int count);
478
483void jo_water_set_swell(jo_water * const w, const jo_fixed scale);
484
491void jo_water_drop(jo_water * const w, const int x, const int z, const int height);
492
502void jo_water_wave_front(jo_water * const w, const int x, const int z, const jo_angle direction, const int height, const int width);
503
513void jo_water_foam(jo_water * const w, const int x, const int z, const int radius, const int life);
514
525void jo_water_set_depth_map(jo_water * const w, const unsigned char * const map, const int size, const int shift, const int x,
526 const int z);
527
529int jo_water_foam_at(const jo_water * const w, const int x, const int z);
530
536void jo_water_set_sun(jo_water * const w, const jo_angle azimuth, const jo_angle elevation);
537
539void jo_water_set_textured(jo_water * const w, const bool textured);
540
543
551jo_color jo_water_seen_color(const jo_water * const w, const jo_color object, const int amount);
552
557void jo_water_set_look(jo_water * const w, const jo_water_config * const look);
558
559/*
560** Objects under the water: any mesh of the world seen through the water (a rock, a wreck, a fish, the legs of a pier, the
561** part of an object under the surface). The VDP2 mixes the water with the bottom of the sea, not with the polygons drawn
562** before it: an object under the water is drawn over the water, in its colors seen through the water (mixed with the
563** color of the water seen from above, RGB: the VDP2 mixes them with the bottom like the water). The water module sorts
564** each object where the line of sight goes into the water in front of it (the waves as drawn): in front of the water that
565** covers it on the screen, behind the objects above the water in front of it (see jo_water_add_above()), the objects under
566** the water that cover each other on the screen from the farthest. Its polygons keep their own order (their sort, as
567** made: any shape). Drawn by the slave CPU after the water (see jo_water_draw_with()), a draw per object.
568**
569** Usage:
570** jo_3d_model *rocks = jo_3d_load_model("ROCKS.JOM"); (a group per rock: OBJ o or g)
571** jo_water_add_model(sea, rocks, 192, 1500, JO_NULL); (once: the colors of the model become its colors seen
572** through the water, draw it only this way)
573** each frame, before jo_water_draw_with(): jo_water_add_above(sea, jet ski...), jo_water_place() / jo_water_show() /
574** jo_water_reshape() of the objects that move
575**
576** A floating object (a hull): see jo_water_add_dip().
577*/
578
580typedef struct s_jo_water_object jo_water_object;
581
583# define JO_WATER_MAX_OBJECTS (48)
585# define JO_WATER_MAX_ABOVE (24)
586
599int jo_water_add_model(jo_water * const w, jo_3d_model * const model, const int amount, const int far, jo_water_object ** const objects);
600
611jo_water_object *jo_water_add_mesh(jo_water * const w, jo_3d_mesh * const mesh, const int first, const int count, const int amount,
612 const int far);
613
621void jo_water_place(jo_water_object * const o, const int x, const int y, const int z, const jo_angle heading);
622
628void jo_water_show(jo_water_object * const o, const bool shown, const unsigned int hidden);
629
633
635void jo_water_set_far(jo_water_object * const o, const int far);
636
647void jo_water_add_above(jo_water * const w, const int x, const int y, const int z, const int radius, const int key_offset);
648
651typedef struct s_jo_water_dip jo_water_dip;
652
654# define JO_WATER_DIP_LEVELS (4)
655
667jo_water_dip *jo_water_add_dip(jo_water * const w, jo_3d_mesh * const mesh, const int levels, const short * const amounts,
668 const jo_fixed * const depths, const int palette_offset);
669
678void jo_water_dip_mesh(jo_water_dip * const d, const jo_fixed surface, const jo_angle pitch, const jo_angle roll);
679
680#endif /* JO_COMPILE_WITH_3D_SUPPORT && JO_COMPILE_WITH_DUAL_CPU_SUPPORT */
681
682#endif /* !__JO_WATER_H__ */
683
684/*
685** END OF FILE
686*/
Mesh structure.
Definition 3d.h:248
#define JO_COLOR_RGB(R, G, B)
Get jo_color type from RGB additive color model.
Definition colors.h:106
jo_3d_mesh * mesh
Definition entity.h:11
int radius
Definition entity.h:3
int height
Definition entity.h:4
3D model loaded from a JOM file
Definition model.h:242
#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
unsigned short jo_color
15 bits color type
Definition types.h:53
int jo_fixed
Fixed point Q16.16 number.
Definition types.h:59
@ JO_SPRITE_SCREEN
Definition types.h:348
@ JO_VDP2_BLEND_RATIO
A part of the color of the screen and a part of the image under it (transparency).
Definition vdp2.h:726
void jo_vdp2_enable_blend(const jo_scroll_screen screens, unsigned char ratio)
Mix screens with the image under them.
void jo_vdp2_blend_rgb_sprites_only(const bool rgb_only)
Mix only the RGB pixels of the sprites (jo_vdp2_enable_blend(JO_SPRITE_SCREEN, ratio)): the palette p...
void jo_vdp2_set_blend_mode(const jo_vdp2_blend_mode mode)
Set how the screens are mixed (jo_vdp2_enable_blend()): the same for all the screens.
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 grow...
int splash_life
Definition water.h:153
int direction
Definition water.h:80
int x
Definition water.h:442
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),...
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,...
int level_count
Definition water.h:106
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).
int splash_speed
Definition water.h:152
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 l...
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,...
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_draw(jo_water *const w)
Draw the water (after jo_3d_camera_look_at()).
int surf
Definition water.h:134
int min_cells_per_wave
Definition water.h:109
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).
Definition water.h:335
jo_fixed slope_x
Definition water.h:163
jo_water_look_kind
The standard looks of the water (its color and the light of its waves, see jo_water_config_look()).
Definition water.h:190
@ JO_WATER_LOOK_BRIGHT_TURQUOISE
Definition water.h:198
@ JO_WATER_LOOK_TROPICAL_TEAL
Definition water.h:193
@ JO_WATER_LOOK_DEFAULT
Definition water.h:191
@ JO_WATER_LOOK_FRENCH_BLUE
Definition water.h:196
@ JO_WATER_LOOK_DEEP_CONTRAST
Definition water.h:197
@ JO_WATER_LOOK_SUNNY_BEACH
Definition water.h:201
@ JO_WATER_LOOK_OCEAN_BLUE
Definition water.h:195
@ JO_WATER_LOOK_DEEP_PACIFIC
Definition water.h:200
@ JO_WATER_LOOK_MINT_LAGOON
Definition water.h:192
@ JO_WATER_LOOK_COUNT
Definition water.h:202
@ JO_WATER_LOOK_MERMAID_BLUE
Definition water.h:194
@ JO_WATER_LOOK_CARIBBEAN
Definition water.h:199
int update_cell
Definition water.h:108
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()).
Definition water.h:206
int cell
Definition water.h:88
signed char g
Definition water.h:97
int spot_distance
Definition water.h:126
int front_length
Definition water.h:154
bool textured
Definition water.h:143
int front_speed
Definition water.h:155
int ahead
Definition water.h:107
int bottom_depth
Definition water.h:138
int sky
Definition water.h:121
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 (...
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,...
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(): onl...
jo_water_swell_kind
The standard swells (see jo_water_swell()): waves of 130 to 700 units, for quads of 16 to 64 units ne...
Definition water.h:313
@ JO_WATER_SWELL_STORM
Definition water.h:316
@ JO_WATER_SWELL_COUNT
Definition water.h:317
@ JO_WATER_SWELL_CHOPPY
Definition water.h:315
@ JO_WATER_SWELL_GENTLE
Definition water.h:314
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...
Definition water.h:303
jo_fixed height
Definition water.h:81
struct s_jo_water_object jo_water_object
An object under the water (see jo_water_add_model()).
Definition water.h:580
int slope_light_min
Definition water.h:122
signed char b
Definition water.h:98
int caustics
Definition water.h:127
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 boa...
Definition water.h:651
bool in_water
Definition water.h:450
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|).
int z
Definition water.h:443
int reflection
Definition water.h:128
int shallow_depth
Definition water.h:133
int period
Definition water.h:82
int half
Definition water.h:446
jo_water_steps shallow
Definition water.h:119
const jo_water_level * levels
Definition water.h:105
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_wi...
Definition water.h:273
jo_color foam_color
Definition water.h:130
void jo_water_set_textured(jo_water *const w, const bool textured)
The foam texture or not (see jo_water_config.textured).
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_up...
int side
Definition water.h:89
jo_fixed vy
Definition water.h:445
int glint
Definition water.h:124
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()).
int sink
Definition water.h:447
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,...
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).
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 wav...
int skirt
Definition water.h:111
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).
jo_angle tilt_z
Definition water.h:449
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,...
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_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).
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,...
bool grain
Definition water.h:145
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,...
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.
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,...
Definition water.h:229
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...
int slope_light_max
Definition water.h:123
int bottom
Definition water.h:135
jo_water_steps shore
Definition water.h:132
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 c...
jo_angle tilt_x
Definition water.h:448
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,...
int spot
Definition water.h:125
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...
int length
Definition water.h:79
jo_water_steps deep
Definition water.h:120
jo_water * jo_water_create(const jo_water_config *const config)
Create the water: load the textures, create the grid.
int see_through
Definition water.h:139
int foam_white
Definition water.h:129
signed char r
Definition water.h:96
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.
int fade
Definition water.h:110
const char * patterns_file
Definition water.h:147
int front_life
Definition water.h:156
jo_fixed slope_z
Definition water.h:164
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()).
Definition water.h:321
int slave_levels
Definition water.h:112
jo_fixed height
Definition water.h:162
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...
int splash_length
Definition water.h:151
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...
struct s_jo_water jo_water
The water (see jo_water_create()).
Definition water.h:168
jo_fixed y
Definition water.h:444
int wave_count
Definition water.h:116
const jo_water_wave * waves
Definition water.h:115
jo_color color
Definition water.h:118
Configuration of the water (jo_water_default_config(), then change what you need).
Definition water.h:103
An object that falls in the water and floats on the waves (a crate, a barrel, a buoy): see jo_water_f...
Definition water.h:441
A level of the grid.
Definition water.h:87
Height and slopes of the surface at a point (see jo_water_sample()).
Definition water.h:161
Gouraud steps per channel (16: the color as it is).
Definition water.h:95
A wave of the swell (a sine along a direction).
Definition water.h:78