Jo Engine 2026.11.1
Jo Sega Saturn Engine
Loading...
Searching...
No Matches
vehicle.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*/
39
40#ifndef __JO_VEHICLE_H__
41# define __JO_VEHICLE_H__
42
43#if defined(JO_COMPILE_WITH_LEVEL_SUPPORT) && defined(JO_COMPILE_WITH_3D_SUPPORT)
44
45# include "entity.h"
46
53typedef bool (*jo_vehicle_ground_callback)(const jo_fixed x, const jo_fixed z, int * const height);
54
56typedef struct
57{
58 jo_actor actor;
59 jo_fixed speed; // World units per second (< 0: backward)
60 int steer; // Angle of the front wheels (degrees, > 0: to the right)
61 int pitch; // The front up (degrees x 16)
62 int roll; // The left side up (degrees x 16)
63 int wheel_angle; // Turn of the wheels (degrees)
64 jo_fixed lift; // Suspension: the body above the mean of the wheels (Q16.16)
65 jo_fixed lift_speed;
66 short wheel_bones[4]; // Front left, front right, rear left, rear right (-1: none)
67 short steer_bones[2]; // Front left, front right
68 short steering_bone; // The steering wheel (turns around its column, see steering_tilt)
69 short steering_tilt_bone; // The parent of the steering wheel: its tilt (-1: none)
70 short steering_tilt; // The tilt toward the driver (degrees, around X): the model of the wheel is flat
71 int wheelbase; // Properties (world units, degrees, world units per second)
72 int track;
73 int wheel_radius;
74 int max_steer;
75 int max_speed;
76 int acceleration;
77 int braking;
78 int impact; // Damage of a hit at the full speed
79 jo_3d_model *cockpit; // Drawn when the player drives (property cockpit_model: what the
80 // driver sees, the same skeleton), JO_NULL: the model
81 bool driven; // The player drives it
82 bool hit; // It hit something (this frame)
83} jo_vehicle;
84
88void jo_vehicles_set_ground_callback(const jo_vehicle_ground_callback callback);
89
97void jo_vehicle_drive(jo_entity * const entity, const int throttle, const int steering, const bool brake,
98 const int elapsed);
99
105void jo_vehicle_to_world(const jo_entity * const entity, const jo_pos3D_fixed * const local,
106 jo_pos3D_fixed * const world);
107
109extern const jo_entity_class __jo_vehicle_class;
110
115jo_vehicle *jo_vehicle_get(jo_entity * const entity);
116
117#endif /* !JO_COMPILE_WITH_LEVEL_SUPPORT && JO_COMPILE_WITH_3D_SUPPORT */
118
119#endif /* !__JO_VEHICLE_H__ */
120
121/*
122** END OF FILE
123*/
Entities: the things of a level that live (barrels that explode, trigger zones, relays,...
3D model loaded from a JOM file
Definition model.h:195
int jo_fixed
Fixed point Q16.16 number.
Definition types.h:48
3D position using fixed numbers
Definition types.h:92