Jo Engine 2026.11.6
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_FS_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{
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)
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;
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)
84
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
113
114#endif /* !JO_COMPILE_WITH_FS_SUPPORT && JO_COMPILE_WITH_3D_SUPPORT */
115
116#endif /* !__JO_VEHICLE_H__ */
117
118/*
119** END OF FILE
120*/
Entities: the things of a level that live (barrels that explode, trigger zones, relays,...
int height
Definition entity.h:4
struct __jo_entity jo_entity
Definition entity.h:81
Data of an actor (the first member of the data of a class of actors).
Definition entity.h:417
3D model loaded from a JOM file
Definition model.h:242
int jo_fixed
Fixed point Q16.16 number.
Definition types.h:59
3D position using fixed numbers
Definition types.h:103
int max_speed
Definition vehicle.h:75
int braking
Definition vehicle.h:77
int track
Definition vehicle.h:72
jo_actor actor
Definition vehicle.h:58
int roll
Definition vehicle.h:62
int impact
Definition vehicle.h:78
short steering_tilt_bone
Definition vehicle.h:69
jo_fixed lift_speed
Definition vehicle.h:65
int wheel_angle
Definition vehicle.h:63
int wheelbase
Definition vehicle.h:71
int wheel_radius
Definition vehicle.h:73
bool driven
Definition vehicle.h:81
void jo_vehicles_set_ground_callback(const jo_vehicle_ground_callback callback)
Give the ground to the vehicles.
void jo_vehicle_to_world(const jo_entity *const entity, const jo_pos3D_fixed *const local, jo_pos3D_fixed *const world)
A point of the vehicle in the world (the seat of the driver, the door...).
int pitch
Definition vehicle.h:61
short wheel_bones[4]
Definition vehicle.h:66
short steering_tilt
Definition vehicle.h:70
short steering_bone
Definition vehicle.h:68
int max_steer
Definition vehicle.h:74
jo_fixed speed
Definition vehicle.h:59
short steer_bones[2]
Definition vehicle.h:67
jo_3d_model * cockpit
Definition vehicle.h:79
jo_fixed lift
Definition vehicle.h:64
void jo_vehicle_drive(jo_entity *const entity, const int throttle, const int steering, const bool brake, const int elapsed)
Drive a vehicle (each frame while the player is in it).
jo_vehicle * jo_vehicle_get(jo_entity *const entity)
Get the vehicle data of an entity.
int acceleration
Definition vehicle.h:76
bool hit
Definition vehicle.h:82
int steer
Definition vehicle.h:60
bool(*) jo_vehicle_ground_callback(const jo_fixed x, const jo_fixed z, int *const height)
Height of the ground for the vehicles (given by the game).
Definition vehicle.h:53
Data of a vehicle (the data of the class vehicle: an actor first).
Definition vehicle.h:57