Jo Engine 2026.11.6
Jo Sega Saturn Engine
Loading...
Searching...
No Matches
vehicle.h File Reference

Vehicles: entities of the class vehicle (a jeep, a truck), driven by the player. An actor (a model with a rigid skeleton, see jo_3d_model_draw_pose()): the bones of the wheels turn, the bones of the front wheels and of the steering wheel steer. A simple physics: the speed (engine, brakes, drag), the steering (the turn radius comes from the wheelbase), the 4 wheels on the ground (the height, the pitch and the roll of the body follow the ground under them, with a little suspension), the collisions (the ground says where it can't go, the solid entities stop it: a hit at speed damages them). More...

#include "entity.h"

Go to the source code of this file.

Data Structures

struct  jo_vehicle
 Data of a vehicle (the data of the class vehicle: an actor first). More...

Typedefs

typedef 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).

Functions

void jo_vehicles_set_ground_callback (const jo_vehicle_ground_callback callback)
 Give the ground to the vehicles.
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).
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...).
jo_vehicle * jo_vehicle_get (jo_entity *const entity)
 Get the vehicle data of an entity.

Detailed Description

Vehicles: entities of the class vehicle (a jeep, a truck), driven by the player. An actor (a model with a rigid skeleton, see jo_3d_model_draw_pose()): the bones of the wheels turn, the bones of the front wheels and of the steering wheel steer. A simple physics: the speed (engine, brakes, drag), the steering (the turn radius comes from the wheelbase), the 4 wheels on the ground (the height, the pitch and the roll of the body follow the ground under them, with a little suspension), the collisions (the ground says where it can't go, the solid entities stop it: a hit at speed damages them).

Author
Johannes Fetz
Remarks
The ground of the game is given by a callback (jo_vehicles_set_ground_callback())

Data Structure Documentation

◆ jo_vehicle

struct jo_vehicle

Data of a vehicle (the data of the class vehicle: an actor first).

Data Fields
int acceleration
jo_actor actor
int braking
jo_3d_model * cockpit
bool driven
bool hit
int impact
jo_fixed lift
jo_fixed lift_speed
int max_speed
int max_steer
int pitch
int roll
jo_fixed speed
int steer
short steer_bones[2]
short steering_bone
short steering_tilt
short steering_tilt_bone
int track
int wheel_angle
short wheel_bones[4]
int wheel_radius
int wheelbase

Typedef Documentation

◆ jo_vehicle_ground_callback

typedef 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).

Parameters
xPoint (world space)
zPoint
heightHeight of the ground (world units, Y up: the opposite of the Saturn Y), output
Returns
false if a vehicle can't go there (deep water, a wall)

Function Documentation

◆ jo_vehicle_drive()

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).

Parameters
entityEntity of the class vehicle
throttle-256 (backward) to 256 (forward), 0: the engine is idle (it slows down)
steering-256 (left) to 256 (right)
brakeThe brakes
elapsedMilliseconds

◆ jo_vehicle_get()

jo_vehicle * jo_vehicle_get ( jo_entity *const entity)

Get the vehicle data of an entity.

Parameters
entityEntity
Returns
Its data, JO_NULL if it is not a vehicle

◆ jo_vehicle_to_world()

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...).

Parameters
entityEntity of the class vehicle
localPoint in the space of the model (Saturn axes: Y down, the vehicle looks toward +Z)
worldPoint in the world (output): turned by the yaw, the pitch and the roll of the vehicle

◆ jo_vehicles_set_ground_callback()

void jo_vehicles_set_ground_callback ( const jo_vehicle_ground_callback callback)

Give the ground to the vehicles.

Parameters
callbackGround (JO_NULL: flat ground at 0, everywhere)