![]() |
Jo Engine 2026.11.1
Jo Sega Saturn Engine
|
3D models (.JOM files): meshes made with a 3D software, converted by Compiler/COMMON/jo_model.py More...
Go to the source code of this file.
Data Structures | |
| struct | jo_3d_material |
| Material of a model (the same layout as the file: 32 bytes). More... | |
| struct | jo_3d_model_group |
| Group of a model: OBJ o or g (the same layout as the file: 24 bytes). More... | |
| struct | jo_3d_bone |
| Bone of a rigid skeleton (the same layout as the file: 32 bytes). More... | |
| struct | jo_3d_animation |
| Animation of a skeleton (the same layout as the file: 28 bytes). More... | |
| struct | jo_3d_pose |
| Pose of a skeleton: the angles of the bones (see jo_3d_model_get_pose() and jo_3d_model_draw_pose()). More... | |
| struct | jo_3d_model |
| 3D model loaded from a JOM file More... | |
Macros | |
| #define | JO_3D_MODEL_VERSION |
| Version of the JOM files read by this engine. | |
| #define | JO_3D_MATERIAL_DUAL_PLANE |
| Material: drawn on both sides (JO_3D_DUAL_PLANE). | |
| #define | JO_3D_MATERIAL_SORT_MIN |
| Material: sorted with the nearest point (JO_3D_SORT_MIN). | |
| #define | JO_3D_MATERIAL_SORT_MAX |
| Material: sorted with the farthest point (JO_3D_SORT_MAX). | |
| #define | JO_3D_MATERIAL_SORT_PREVIOUS |
| Material: sorted with the depth of the previous polygon of the model (JO_3D_SORT_PREVIOUS): a decal drawn over the face before it (a grille, a sign), whatever their nearest points. | |
| #define | JO_3D_MATERIAL_GOURAUD |
| Material: gouraud shading with the vertex colors ("GOUR" chunk). | |
| #define | JO_3D_MATERIAL_HALF_TRANSPARENT |
| Material: half transparent. | |
| #define | JO_3D_MATERIAL_SCREEN_DOORS |
| Material: screen doors (mesh). | |
| #define | JO_3D_MATERIAL_LIGHT |
| Material: lit by the light of the engine (jo_3d_light()). | |
| #define | JO_3D_MATERIAL_FLIP_H |
| Material: texture flipped horizontally. | |
| #define | JO_3D_MATERIAL_FLIP_V |
| Material: texture flipped vertically. | |
| #define | JO_3D_MATERIAL_END_CODES |
| Material: the texture stops each line after its last visible pixel (jo_sprite_add_end_codes()). | |
| #define | JO_3D_MATERIAL_MIPMAPS |
| Material: smaller copies of the texture far away (jo_3d_set_texture_mipmaps()). | |
| #define | JO_3D_MATERIAL_SUBDIVISION |
| Material: the polygons near the camera are drawn in parts (jo_3d_set_texture_subdivision()). | |
| #define | JO_3D_MATERIAL_SUBDIVISION_NEAR |
| Material: only the polygons that cross the near plane are drawn in parts (jo_3d_set_texture_subdivision_near_only(), MTL: jo_subdivision 2). | |
| #define | JO_3D_MATERIAL_USER(N) |
| First flag of the program (bits 16 to 31, MTL: jo_user). | |
| #define | JO_3D_MAX_BONES |
| Bones of a model at most (jo_3d_pose). | |
| #define | JO_3D_BONE_NO_GROUP |
| jo_3d_bone.group: the bone has no polygons | |
| #define | JO_3D_ANIMATION_LOOP |
| jo_3d_animation.flags: the last key goes back to the first one | |
| #define | JO_3D_ANIMATION_TICKS_PER_SECOND |
| Ticks of the animations per second (the time of jo_3d_model_get_pose()). | |
Typedefs | |
| typedef void(*) | jo_3d_bone_callback(const int bone, void *const param, const jo_fixed(*const matrix)[3]) |
| Called by jo_3d_model_draw_pose() after each bone is drawn, with the matrix of the bone (the program draws a weapon in a hand, a muzzle flash...). | |
Functions | |
| jo_3d_model * | jo_3d_create_model_from_memory (const unsigned char *const data, const unsigned int size) |
| Create a model from the content of a JOM file. | |
| jo_3d_model * | jo_3d_create_model_in_place (const unsigned char *const data, const unsigned int size) |
| Create a model that uses the content of a JOM file in place (like jo_3d_load_model(): the points, the polygons, the materials are not copied): much faster than jo_3d_create_model_from_memory() for many models (a level read in one block: 4 memory blocks per model instead of about 12), and smaller. | |
| jo_3d_model * | jo_3d_load_model (const char *const filename) |
| Load a model (JOM file) from the current directory of the CD. | |
| jo_3d_model * | __jo_3d_load_model_for_lights (const char *const filename) |
| Load a model with a gouraud table per polygon (Internal usage: the cells, lit by the point lights, see jo_3d_point_lights_add_mesh()). jo_3d_load_model() gives one table to the polygons with the same colors. | |
| int | jo_3d_model_texture (const char *const filename) |
| Get the sprite id of a texture of the models (loaded the first time: a texture shared by several models, or by the program, is loaded once). | |
| int | jo_3d_model_loaded_texture (const char *const name) |
| Get the sprite id of a texture already loaded by the models (embedded in a model, or loaded by jo_3d_model_texture()), without loading it. | |
| void | jo_3d_free_model (jo_3d_model *const model) |
| Free a model (the textures stay loaded). | |
| void | jo_3d_model_free_textures_from (const int sprite_id) |
| Free the sprites added since a sprite (the textures of the models loaded since, their tiles and smaller copies, their gouraud tables, the sprites added by the program): the VRAM of the VDP1 is given back. | |
| const jo_3d_model_group * | jo_3d_model_find_group (const jo_3d_model *const model, const char *const name) |
| Find a group of a model. | |
| int | jo_3d_model_find_bone (const jo_3d_model *const model, const char *const name) |
| Find a bone of a model. | |
| int | jo_3d_model_find_animation (const jo_3d_model *const model, const char *const name) |
| Find an animation of a model. | |
| bool | jo_3d_model_is_animation (const jo_3d_model *const model, const int animation, const char *const name) |
| Check if an animation is the one jo_3d_model_find_animation() finds for a name (faster: the name of this one is compared, the ones before it only when it matches). | |
| int | jo_3d_model_animation_duration (const jo_3d_model *const model, const int animation) |
| Duration of an animation. | |
| void | jo_3d_model_get_pose (const jo_3d_model *const model, const int animation, int time, jo_3d_pose *const pose) |
| Pose of a skeleton at a time of an animation (the keys are interpolated). | |
| void | jo_3d_pose_blend (const jo_3d_model *const model, jo_3d_pose *const pose, const jo_3d_pose *const other, const int weight) |
| Blend 2 poses (a smooth change of animation). | |
| void | jo_3d_model_draw_pose (const jo_3d_model *const model, const jo_3d_pose *const pose, const jo_3d_bone_callback callback, void *const param) |
| Draw a model with a skeleton with the current matrix. | |
| void | jo_3d_model_set_hidden_bones (const unsigned int mask) |
| Bones not drawn by the next jo_3d_model_draw_pose() (a hat shot off the head of a character: its bone hidden, the hat drawn alone where it falls: the other bones hidden). | |
| static __jo_force_inline void | jo_3d_model_draw (const jo_3d_model *const model) |
| Draw a model with the current matrix. | |
3D models (.JOM files): meshes made with a 3D software, converted by Compiler/COMMON/jo_model.py
JOM file (all the values are big endian, the chunks are aligned on 4 bytes):
| struct jo_3d_material |
| struct jo_3d_model_group |
| struct jo_3d_bone |
Bone of a rigid skeleton (the same layout as the file: 32 bytes).
| Data Fields | ||
|---|---|---|
| unsigned short | group | |
| char | name[16] | |
| short | parent | |
| jo_pos3D_fixed | pivot | |
| struct jo_3d_animation |
| struct jo_3d_pose |
Pose of a skeleton: the angles of the bones (see jo_3d_model_get_pose() and jo_3d_model_draw_pose()).
| Data Fields | ||
|---|---|---|
| jo_angle | angles[(32)][3] | |
| jo_pos3D_fixed | root | |
| struct jo_3d_model |
3D model loaded from a JOM file
| Data Fields | ||
|---|---|---|
| unsigned int | animation_count | |
| const unsigned char * | animation_data | |
| jo_3d_animation * | animations | |
| signed char * | bone_children | |
| unsigned int | bone_count | |
| jo_3d_bone * | bones | |
| jo_pos3D_fixed | center | |
| unsigned short * | corner_normals | |
| void * | file | |
| bool | file_not_owned | |
| unsigned short | gouraud_tables | |
| unsigned int | group_count | |
| jo_3d_model_group * | groups | |
| unsigned int | material_count | |
| jo_3d_material * | materials | |
| jo_3d_mesh * | mesh | |
| unsigned int | normal_count | |
| jo_pos3D_fixed * | normals | |
| unsigned short * | polygon_materials | |
| jo_fixed | radius | |
| bool | single_block | |
| unsigned int | texture_count | |
| int * | textures | |
| jo_pos3D_fixed * | vertex_colors | |
| #define JO_3D_ANIMATION_LOOP |
jo_3d_animation.flags: the last key goes back to the first one
| #define JO_3D_ANIMATION_TICKS_PER_SECOND |
Ticks of the animations per second (the time of jo_3d_model_get_pose()).
| #define JO_3D_BONE_NO_GROUP |
jo_3d_bone.group: the bone has no polygons
| #define JO_3D_MATERIAL_DUAL_PLANE |
Material: drawn on both sides (JO_3D_DUAL_PLANE).
| #define JO_3D_MATERIAL_END_CODES |
Material: the texture stops each line after its last visible pixel (jo_sprite_add_end_codes()).
| #define JO_3D_MATERIAL_FLIP_H |
Material: texture flipped horizontally.
| #define JO_3D_MATERIAL_FLIP_V |
Material: texture flipped vertically.
| #define JO_3D_MATERIAL_GOURAUD |
Material: gouraud shading with the vertex colors ("GOUR" chunk).
| #define JO_3D_MATERIAL_HALF_TRANSPARENT |
Material: half transparent.
| #define JO_3D_MATERIAL_LIGHT |
Material: lit by the light of the engine (jo_3d_light()).
| #define JO_3D_MATERIAL_MIPMAPS |
Material: smaller copies of the texture far away (jo_3d_set_texture_mipmaps()).
| #define JO_3D_MATERIAL_SCREEN_DOORS |
Material: screen doors (mesh).
| #define JO_3D_MATERIAL_SORT_MAX |
Material: sorted with the farthest point (JO_3D_SORT_MAX).
| #define JO_3D_MATERIAL_SORT_MIN |
Material: sorted with the nearest point (JO_3D_SORT_MIN).
| #define JO_3D_MATERIAL_SORT_PREVIOUS |
Material: sorted with the depth of the previous polygon of the model (JO_3D_SORT_PREVIOUS): a decal drawn over the face before it (a grille, a sign), whatever their nearest points.
| #define JO_3D_MATERIAL_SUBDIVISION |
Material: the polygons near the camera are drawn in parts (jo_3d_set_texture_subdivision()).
| #define JO_3D_MATERIAL_SUBDIVISION_NEAR |
Material: only the polygons that cross the near plane are drawn in parts (jo_3d_set_texture_subdivision_near_only(), MTL: jo_subdivision 2).
| #define JO_3D_MATERIAL_USER | ( | N | ) |
First flag of the program (bits 16 to 31, MTL: jo_user).
| #define JO_3D_MAX_BONES |
Bones of a model at most (jo_3d_pose).
| #define JO_3D_MODEL_VERSION |
Version of the JOM files read by this engine.
| typedef void(*) jo_3d_bone_callback(const int bone, void *const param, const jo_fixed(*const matrix)[3]) |
Called by jo_3d_model_draw_pose() after each bone is drawn, with the matrix of the bone (the program draws a weapon in a hand, a muzzle flash...).
| bone | Index of the bone |
| param | Parameter of jo_3d_model_draw_pose() |
| matrix | Matrix of the bone (4 rows of 3, see jo_3d_transform_point_by()); the current matrix is not the one of the bone |
| jo_3d_model * __jo_3d_load_model_for_lights | ( | const char *const | filename | ) |
Load a model with a gouraud table per polygon (Internal usage: the cells, lit by the point lights, see jo_3d_point_lights_add_mesh()). jo_3d_load_model() gives one table to the polygons with the same colors.
| filename | File name |
| jo_3d_model * jo_3d_create_model_from_memory | ( | const unsigned char *const | data, |
| const unsigned int | size ) |
Create a model from the content of a JOM file.
| data | Content of the file (4 bytes aligned) |
| size | Size in bytes |
| jo_3d_model * jo_3d_create_model_in_place | ( | const unsigned char *const | data, |
| const unsigned int | size ) |
Create a model that uses the content of a JOM file in place (like jo_3d_load_model(): the points, the polygons, the materials are not copied): much faster than jo_3d_create_model_from_memory() for many models (a level read in one block: 4 memory blocks per model instead of about 12), and smaller.
| data | Content of the file (4 bytes aligned), kept by the caller as long as the model exists |
| size | Size in bytes |
| void jo_3d_free_model | ( | jo_3d_model *const | model | ) |
Free a model (the textures stay loaded).
| model | Model |
| jo_3d_model * jo_3d_load_model | ( | const char *const | filename | ) |
Load a model (JOM file) from the current directory of the CD.
| filename | File name (example: "MODEL.JOM") |
| int jo_3d_model_animation_duration | ( | const jo_3d_model *const | model, |
| const int | animation ) |
Duration of an animation.
| model | Model |
| animation | Index of the animation |
|
static |
Draw a model with the current matrix.
| model | Model |
| void jo_3d_model_draw_pose | ( | const jo_3d_model *const | model, |
| const jo_3d_pose *const | pose, | ||
| const jo_3d_bone_callback | callback, | ||
| void *const | param ) |
Draw a model with a skeleton with the current matrix.
| model | Model |
| pose | Pose (JO_NULL: the pose of the OBJ) |
| callback | Called after each bone is drawn, with the matrix of the bone (JO_NULL: none) |
| param | Parameter of the callback |
| int jo_3d_model_find_animation | ( | const jo_3d_model *const | model, |
| const char *const | name ) |
Find an animation of a model.
| model | Model |
| name | Name of the animation |
| int jo_3d_model_find_bone | ( | const jo_3d_model *const | model, |
| const char *const | name ) |
Find a bone of a model.
| model | Model |
| name | Name of the bone |
| const jo_3d_model_group * jo_3d_model_find_group | ( | const jo_3d_model *const | model, |
| const char *const | name ) |
Find a group of a model.
| model | Model |
| name | Name of the group (OBJ o or g) |
| void jo_3d_model_free_textures_from | ( | const int | sprite_id | ) |
Free the sprites added since a sprite (the textures of the models loaded since, their tiles and smaller copies, their gouraud tables, the sprites added by the program): the VRAM of the VDP1 is given back.
| sprite_id | First sprite to free (jo_sprite_count() before the models were loaded) |
| void jo_3d_model_get_pose | ( | const jo_3d_model *const | model, |
| const int | animation, | ||
| int | time, | ||
| jo_3d_pose *const | pose ) |
Pose of a skeleton at a time of an animation (the keys are interpolated).
| model | Model |
| animation | Index of the animation, -1: the bones don't turn (the pose of the OBJ) |
| time | Ticks (1/60 s) from the start of the animation |
| pose | Pose |
| bool jo_3d_model_is_animation | ( | const jo_3d_model *const | model, |
| const int | animation, | ||
| const char *const | name ) |
Check if an animation is the one jo_3d_model_find_animation() finds for a name (faster: the name of this one is compared, the ones before it only when it matches).
| model | Model |
| animation | Index of the animation |
| name | Name (case insensitive) |
| int jo_3d_model_loaded_texture | ( | const char *const | name | ) |
Get the sprite id of a texture already loaded by the models (embedded in a model, or loaded by jo_3d_model_texture()), without loading it.
| name | Name of the texture (its file name, or its name in the model) |
| void jo_3d_model_set_hidden_bones | ( | const unsigned int | mask | ) |
Bones not drawn by the next jo_3d_model_draw_pose() (a hat shot off the head of a character: its bone hidden, the hat drawn alone where it falls: the other bones hidden).
| mask | Bit k: the bone k (and its children) hidden, 0: all drawn |
| int jo_3d_model_texture | ( | const char *const | filename | ) |
Get the sprite id of a texture of the models (loaded the first time: a texture shared by several models, or by the program, is loaded once).
| filename | File name on the CD (.BIN: jo_sprite_add_bin(), .TGA: jo_sprite_add_tga()) |
| void jo_3d_pose_blend | ( | const jo_3d_model *const | model, |
| jo_3d_pose *const | pose, | ||
| const jo_3d_pose *const | other, | ||
| const int | weight ) |
Blend 2 poses (a smooth change of animation).
| model | Model |
| pose | First pose, the result |
| other | Second pose |
| weight | Weight of the second pose (0 to 256) |