Jo Engine  9
Jo Sega Saturn Engine
Data Structures | Macros | Typedefs | Functions | Variables
3d.h File Reference

Jo Engine 3D basics. More...

Go to the source code of this file.

Data Structures

struct  jo_camera
 Camera structure. More...
 
struct  jo_3d_quad
 Quadrilateral shape structure. More...
 
struct  jo_3d_mesh
 Mesh structure. More...
 

Macros

#define JO_3D_PLANE_VERTICES(SIZE)
 Plane vertice table. More...
 
#define JO_3D_TRIANGLE_VERTICES(SIZE)
 Triangle vertice table. More...
 
#define JO_3D_CUBE_VERTICES(SIZE)
 Cube vertice table. More...
 

Typedefs

typedef jo_pos3D jo_vertice
 Vertice structure. More...
 

Functions

bool jo_3d_create_sprite_quad (const int sprite_id)
 
static __jo_force_inline void jo_3d_camera_set_viewpoint (jo_camera *const cam, const int x, const int y, const int z)
 Set the viewpoint of the camera (where the cameraman is) More...
 
static __jo_force_inline void jo_3d_camera_set_target (jo_camera *const cam, const int x, const int y, const int z)
 Set the target of the camera (where the scene is located) More...
 
static __jo_force_inline void jo_3d_camera_set_z_angle (jo_camera *const cam, const int angle)
 Set the angle of the camera. More...
 
static __jo_force_inline void jo_3d_camera_init (jo_camera *const cam)
 Initialize the camera with default values. More...
 
static __jo_force_inline void jo_3d_camera_look_at (jo_camera *const cam)
 look at the camera More...
 
static __jo_force_inline unsigned int jo_3d_get_polygon_count (void)
 Get polygon count (visible and not visible) More...
 
static __jo_force_inline unsigned int jo_3d_get_vertices_count (void)
 Get vertice count. More...
 
static __jo_force_inline unsigned int jo_3d_get_displayed_polygon_count (void)
 Get displayed polygon count. More...
 
void jo_3d_create_plane (jo_3d_quad *const quad, jo_vertice *const vertices)
 Create a four vertices polygon (Quadrilateral shape) More...
 
void jo_3d_create_cube (jo_3d_quad *array, jo_vertice *const vertices)
 Create a cube. More...
 
void jo_3d_create_triangle (jo_3d_quad *const quad, jo_vertice *const vertices)
 Create a triangle. More...
 
static __jo_force_inline jo_3d_quadjo_3d_get_sprite_quad (const int sprite_id)
 Get sprite quad. More...
 
void jo_3d_free_sprite_quad (const int sprite_id)
 Delete sprite quad. More...
 
static __jo_force_inline unsigned int jo_3d_get_mesh_polygon_count (jo_3d_mesh *const mesh)
 Get polygon count on the mesh. More...
 
void jo_3d_set_mesh_polygon_texture (jo_3d_mesh *const mesh, const int sprite_id, const unsigned int index)
 Set a texture on one polygon on the mesh. More...
 
void jo_3d_set_mesh_texture (jo_3d_mesh *const mesh, const int sprite_id)
 Set a texture on the mesh. More...
 
static __jo_force_inline void jo_3d_set_texture (jo_3d_quad *const quad, const int sprite_id)
 Set a texture on the quadrilateral. More...
 
static __jo_force_inline void jo_3d_light (const int x, const int y, const int z)
 Use a light source. More...
 
void jo_3d_set_mesh_polygon_light (jo_3d_mesh *const mesh, const bool enabled, const unsigned int index)
 Enable/Disable light on one polygon on the mesh. More...
 
void jo_3d_set_mesh_light (jo_3d_mesh *const mesh, const bool enabled)
 Enable/Disable light on the mesh. More...
 
static __jo_force_inline void jo_3d_set_light (jo_3d_quad *const quad, const bool enabled)
 Enable/Disable light on the quad. More...
 
void jo_3d_set_mesh_polygon_screen_doors (jo_3d_mesh *const mesh, const bool enabled, const unsigned int index)
 Enable/Disable screen doors transparency on one polygon on the mesh. More...
 
void jo_3d_set_mesh_screen_doors (jo_3d_mesh *const mesh, const bool enabled)
 Enable/Disable screen doors transparency on the mesh. More...
 
static __jo_force_inline void jo_3d_set_screen_doors (jo_3d_quad *const quad, const bool enabled)
 Enable/Disable screen doors transparency on the quad. More...
 
void jo_3d_set_mesh_polygon_transparency (jo_3d_mesh *const mesh, const bool enabled, const unsigned int index)
 Enable/Disable transparency on one polygon on the mesh. More...
 
void jo_3d_set_mesh_transparency (jo_3d_mesh *const mesh, const bool enabled)
 Enable/Disable transparency on the mesh. More...
 
static __jo_force_inline void jo_3d_set_transparency (jo_3d_quad *const quad, const bool enabled)
 Enable/Disable transparency on the quadrilateral. More...
 
void jo_3d_set_mesh_polygon_color (jo_3d_mesh *const mesh, const jo_color color, const unsigned int index)
 Set the color on one polygon on the mesh. More...
 
void jo_3d_set_mesh_color (jo_3d_mesh *const mesh, const jo_color color)
 Set the color on the mesh. More...
 
static __jo_force_inline void jo_3d_set_color (jo_3d_quad *const quad, const jo_color color)
 Set the color on the quadrilateral. More...
 
static __jo_force_inline void jo_3d_push_matrix (void)
 Push 3D matrix. More...
 
static __jo_force_inline void jo_3d_pop_matrix (void)
 Pop 3D matrix. More...
 
static __jo_force_inline void jo_3d_rotate_matrix (short x, short y, short z)
 Rotate 3D matrix using degree. More...
 
static __jo_force_inline void jo_3d_rotate_matrix_x (short x)
 Rotate 3D matrix using degree (X axis) More...
 
static __jo_force_inline void jo_3d_rotate_matrix_y (short y)
 Rotate 3D matrix using degree (Y axis) More...
 
static __jo_force_inline void jo_3d_rotate_matrix_z (short z)
 Rotate 3D matrix using degree (Z axis) More...
 
static __jo_force_inline void jo_3d_rotate_matrix_rad (float x, float y, float z)
 Rotate 3D matrix using radian. More...
 
static __jo_force_inline void jo_3d_rotate_matrix_rad_x (float x)
 Rotate 3D matrix using radian (X axis) More...
 
static __jo_force_inline void jo_3d_rotate_matrix_rad_y (float y)
 Rotate 3D matrix using radian (Y axis) More...
 
static __jo_force_inline void jo_3d_rotate_matrix_rad_z (float z)
 Rotate 3D matrix using radian (Z axis) More...
 
static __jo_force_inline void jo_3d_translate_matrixf (float x, float y, float z)
 Translate 3D matrix (using floating numbers) More...
 
static __jo_force_inline void jo_3d_translate_matrix (int x, int y, int z)
 Translate 3D matrix. More...
 
static __jo_force_inline void jo_3d_translate_matrix_x (int x)
 Translate 3D matrix (X axis) More...
 
static __jo_force_inline void jo_3d_translate_matrix_y (int y)
 Translate 3D matrix (Y axis) More...
 
static __jo_force_inline void jo_3d_translate_matrix_z (int z)
 Translate 3D matrix (Z axis) More...
 
static __jo_force_inline void jo_3d_draw (jo_3d_quad *const quad)
 Draw a quadrilateral. More...
 
static __jo_force_inline void jo_3d_mesh_draw (jo_3d_mesh *const mesh)
 Draw a mesh. More...
 
static __jo_force_inline void __jo_poylgon_draw_iterator (jo_node *node)
 Internal usage for polygon display. More...
 
static __jo_force_inline void jo_3d_draw_list (jo_list *const list)
 Draw a list of quadrilateral. More...
 
static __jo_force_inline void jo_3d_draw_array (jo_3d_quad *const array, int array_size)
 Draw an array of quadrilateral. More...
 
static __jo_force_inline bool jo_3d_draw_sprite (const int sprite_id)
 Draw a sprite. More...
 
static __jo_force_inline void jo_3d_draw_sprite_at (const int sprite_id, const int x, const int y, const int z)
 Draw a sprite. More...
 
static __jo_force_inline void jo_3d_set_scalef (const float x, const float y, const float z)
 Change scale using floating number. More...
 
static __jo_force_inline void jo_3d_set_scale (const int x, const int y, const int z)
 Change scale. More...
 
static __jo_force_inline bool jo_3d_window (const int left, const int top, const int right, const int bottom, const int z_limit, const int center_x, const int center_y)
 Sets up a window region on the projection surface. More...
 
static __jo_force_inline void jo_3d_perspective_angle (const int angle)
 Set the perspective angle. More...
 
static __jo_force_inline void jo_3d_display_level (const unsigned short level)
 Set the display level of the viewing volume. More...
 
static __jo_force_inline void jo_3d_draw_billboard (const int sprite_id, const int x, const int y, const int z)
 Draw billboard. More...
 
static __jo_force_inline void jo_3d_draw_scaled_billboard (const int sprite_id, const int x, const int y, const int z, const int scale)
 Draw billboard with a specific scale. More...
 

Variables

jo_3d_quad__jo_sprite_quad [JO_MAX_SPRITE]
 Sprite quads (internal engine usage) More...
 

Detailed Description

Jo Engine 3D basics.

Author
Johannes Fetz
Bug:
No known bugs.
Todo:
Mesh loader, Gouraud shading and advanced 3D processing

Data Structure Documentation

struct jo_camera

Camera structure.

Data Fields
FIXED target[XYZ]
FIXED viewpoint[XYZ]
ANGLE z_angle
struct jo_3d_quad

Quadrilateral shape structure.

Data Fields
ATTR attribute
PDATA data
struct jo_3d_mesh

Mesh structure.

Data Fields
PDATA data

Macro Definition Documentation

#define JO_3D_CUBE_VERTICES (   SIZE)

Cube vertice table.

#define JO_3D_PLANE_VERTICES (   SIZE)

Plane vertice table.

#define JO_3D_TRIANGLE_VERTICES (   SIZE)

Triangle vertice table.

Typedef Documentation

Vertice structure.

Function Documentation

static __jo_force_inline void __jo_poylgon_draw_iterator ( jo_node node)
static

Internal usage for polygon display.

Warning
Don't use it
static __jo_force_inline void jo_3d_camera_init ( jo_camera *const  cam)
static

Initialize the camera with default values.

Parameters
camPointer to a camera struct
static __jo_force_inline void jo_3d_camera_look_at ( jo_camera *const  cam)
static

look at the camera

Parameters
camPointer to a camera struct
static __jo_force_inline void jo_3d_camera_set_target ( jo_camera *const  cam,
const int  x,
const int  y,
const int  z 
)
static

Set the target of the camera (where the scene is located)

Parameters
camPointer to a camera struct
xX coord
yY coord
zZ coord
static __jo_force_inline void jo_3d_camera_set_viewpoint ( jo_camera *const  cam,
const int  x,
const int  y,
const int  z 
)
static

Set the viewpoint of the camera (where the cameraman is)

Parameters
camPointer to a camera struct
xX coord
yY coord
zZ coord
static __jo_force_inline void jo_3d_camera_set_z_angle ( jo_camera *const  cam,
const int  angle 
)
static

Set the angle of the camera.

Parameters
camPointer to a camera struct
angleZ-angle in degree
void jo_3d_create_cube ( jo_3d_quad array,
jo_vertice *const  vertices 
)

Create a cube.

Parameters
arrayAddress to a 6 jo_3d_quad allocated struct
verticesVertices coords (table of 24 (6x4) jo_vertice)
void jo_3d_create_plane ( jo_3d_quad *const  quad,
jo_vertice *const  vertices 
)

Create a four vertices polygon (Quadrilateral shape)

Parameters
quadAddress to a jo_3d_quad allocated struct
verticesVertices coords (table of 4 jo_vertice)
bool jo_3d_create_sprite_quad ( const int  sprite_id)
void jo_3d_create_triangle ( jo_3d_quad *const  quad,
jo_vertice *const  vertices 
)

Create a triangle.

Parameters
quadAddress to a jo_3d_quad allocated struct
verticesVertices coords (table of 3 jo_vertice)
static __jo_force_inline void jo_3d_display_level ( const unsigned short  level)
static

Set the display level of the viewing volume.

Parameters
levelDistance from the viewpoint and the projection surface
static __jo_force_inline void jo_3d_draw ( jo_3d_quad *const  quad)
static

Draw a quadrilateral.

Parameters
quadAddress to a jo_3d_quad allocated struct
static __jo_force_inline void jo_3d_draw_array ( jo_3d_quad *const  array,
int  array_size 
)
static

Draw an array of quadrilateral.

Parameters
arrayArray of quadrilateral
array_sizeSize of the array
static __jo_force_inline void jo_3d_draw_billboard ( const int  sprite_id,
const int  x,
const int  y,
const int  z 
)
static

Draw billboard.

Parameters
sprite_idSprite Id returned by jo_sprite_add(), jo_sprite_add_tga() or jo_sprite_add_image_pack()
xX coordinate
yY coordinate
zZ coordinate
static __jo_force_inline void jo_3d_draw_list ( jo_list *const  list)
static

Draw a list of quadrilateral.

Parameters
listList of quadrilateral
static __jo_force_inline void jo_3d_draw_scaled_billboard ( const int  sprite_id,
const int  x,
const int  y,
const int  z,
const int  scale 
)
static

Draw billboard with a specific scale.

Parameters
sprite_idSprite Id returned by jo_sprite_add(), jo_sprite_add_tga() or jo_sprite_add_image_pack()
xX coordinate
yY coordinate
zZ coordinate
scaleScale
static __jo_force_inline bool jo_3d_draw_sprite ( const int  sprite_id)
static

Draw a sprite.

Parameters
sprite_idSprite Id returned by jo_sprite_add(), jo_sprite_add_tga() or jo_sprite_add_image_pack()
Returns
true if succeeded otherwise false
static __jo_force_inline void jo_3d_draw_sprite_at ( const int  sprite_id,
const int  x,
const int  y,
const int  z 
)
static

Draw a sprite.

Parameters
sprite_idSprite Id returned by jo_sprite_add(), jo_sprite_add_tga() or jo_sprite_add_image_pack()
xX coordinate
yY coordinate
zZ coordinate
void jo_3d_free_sprite_quad ( const int  sprite_id)

Delete sprite quad.

Parameters
sprite_idSprite Id returned by jo_sprite_add(), jo_sprite_add_tga() or jo_sprite_add_image_pack()
static __jo_force_inline unsigned int jo_3d_get_displayed_polygon_count ( void  )
static

Get displayed polygon count.

Warning
This function must be called after display polygons
Returns
polygon count
static __jo_force_inline unsigned int jo_3d_get_mesh_polygon_count ( jo_3d_mesh *const  mesh)
static

Get polygon count on the mesh.

Parameters
meshAddress to a jo_3d_mesh allocated struct
Returns
polygon count
static __jo_force_inline unsigned int jo_3d_get_polygon_count ( void  )
static

Get polygon count (visible and not visible)

Warning
This function must be called after display polygons
Returns
polygon count
static __jo_force_inline jo_3d_quad* jo_3d_get_sprite_quad ( const int  sprite_id)
static

Get sprite quad.

Parameters
sprite_idSprite Id returned by jo_sprite_add(), jo_sprite_add_tga() or jo_sprite_add_image_pack()
Returns
Sprite quad
static __jo_force_inline unsigned int jo_3d_get_vertices_count ( void  )
static

Get vertice count.

Warning
This function must be called after display polygons
Returns
vertice count
static __jo_force_inline void jo_3d_light ( const int  x,
const int  y,
const int  z 
)
static

Use a light source.

Parameters
xX position of the light source
yY position of the light source
zZ position of the light source
static __jo_force_inline void jo_3d_mesh_draw ( jo_3d_mesh *const  mesh)
static

Draw a mesh.

Parameters
meshAddress to a jo_3d_mesh allocated struct
static __jo_force_inline void jo_3d_perspective_angle ( const int  angle)
static

Set the perspective angle.

Parameters
angleAngle in degree (from 21 to 159)
static __jo_force_inline void jo_3d_pop_matrix ( void  )
static

Pop 3D matrix.

static __jo_force_inline void jo_3d_push_matrix ( void  )
static

Push 3D matrix.

static __jo_force_inline void jo_3d_rotate_matrix ( short  x,
short  y,
short  z 
)
static

Rotate 3D matrix using degree.

Parameters
xX Angle in degree
yY Angle in degree
zZ Angle in degree
static __jo_force_inline void jo_3d_rotate_matrix_rad ( float  x,
float  y,
float  z 
)
static

Rotate 3D matrix using radian.

Parameters
xX Angle in radian
yY Angle in radian
zZ Angle in radian
static __jo_force_inline void jo_3d_rotate_matrix_rad_x ( float  x)
static

Rotate 3D matrix using radian (X axis)

Parameters
xX Angle in radian
static __jo_force_inline void jo_3d_rotate_matrix_rad_y ( float  y)
static

Rotate 3D matrix using radian (Y axis)

Parameters
yY Angle in radian
static __jo_force_inline void jo_3d_rotate_matrix_rad_z ( float  z)
static

Rotate 3D matrix using radian (Z axis)

Parameters
zZ Angle in radian
static __jo_force_inline void jo_3d_rotate_matrix_x ( short  x)
static

Rotate 3D matrix using degree (X axis)

Parameters
xX Angle in degree
static __jo_force_inline void jo_3d_rotate_matrix_y ( short  y)
static

Rotate 3D matrix using degree (Y axis)

Parameters
yY Angle in degree
static __jo_force_inline void jo_3d_rotate_matrix_z ( short  z)
static

Rotate 3D matrix using degree (Z axis)

Parameters
zZ Angle in degree
static __jo_force_inline void jo_3d_set_color ( jo_3d_quad *const  quad,
const jo_color  color 
)
static

Set the color on the quadrilateral.

Parameters
quadAddress to a jo_3d_quad allocated struct
colorColor
static __jo_force_inline void jo_3d_set_light ( jo_3d_quad *const  quad,
const bool  enabled 
)
static

Enable/Disable light on the quad.

Parameters
quadAddress to a jo_3d_quad allocated struct
enabledtrue to enable light support
void jo_3d_set_mesh_color ( jo_3d_mesh *const  mesh,
const jo_color  color 
)

Set the color on the mesh.

Parameters
meshAddress to a jo_3d_mesh allocated struct
colorColor
void jo_3d_set_mesh_light ( jo_3d_mesh *const  mesh,
const bool  enabled 
)

Enable/Disable light on the mesh.

Parameters
meshAddress to a jo_3d_mesh allocated struct
enabledtrue to enable light support
void jo_3d_set_mesh_polygon_color ( jo_3d_mesh *const  mesh,
const jo_color  color,
const unsigned int  index 
)

Set the color on one polygon on the mesh.

Parameters
meshAddress to a jo_3d_mesh allocated struct
colorColor
indexpolygon index on the mesh
void jo_3d_set_mesh_polygon_light ( jo_3d_mesh *const  mesh,
const bool  enabled,
const unsigned int  index 
)

Enable/Disable light on one polygon on the mesh.

Parameters
meshAddress to a jo_3d_mesh allocated struct
enabledtrue to enable light support
indexpolygon index on the mesh
void jo_3d_set_mesh_polygon_screen_doors ( jo_3d_mesh *const  mesh,
const bool  enabled,
const unsigned int  index 
)

Enable/Disable screen doors transparency on one polygon on the mesh.

Parameters
meshAddress to a jo_3d_mesh allocated struct
enabledtrue to enable screen doors transparency
indexpolygon index on the mesh
void jo_3d_set_mesh_polygon_texture ( jo_3d_mesh *const  mesh,
const int  sprite_id,
const unsigned int  index 
)

Set a texture on one polygon on the mesh.

Parameters
meshAddress to a jo_3d_mesh allocated struct
sprite_idSprite ID
indexpolygon index on the mesh
void jo_3d_set_mesh_polygon_transparency ( jo_3d_mesh *const  mesh,
const bool  enabled,
const unsigned int  index 
)

Enable/Disable transparency on one polygon on the mesh.

Parameters
meshAddress to a jo_3d_mesh allocated struct
enabledtrue to enable transparency
indexpolygon index on the mesh
void jo_3d_set_mesh_screen_doors ( jo_3d_mesh *const  mesh,
const bool  enabled 
)

Enable/Disable screen doors transparency on the mesh.

Parameters
meshAddress to a jo_3d_mesh allocated struct
enabledtrue to enable screen doors transparency
void jo_3d_set_mesh_texture ( jo_3d_mesh *const  mesh,
const int  sprite_id 
)

Set a texture on the mesh.

Parameters
meshAddress to a jo_3d_mesh allocated struct
sprite_idSprite ID
void jo_3d_set_mesh_transparency ( jo_3d_mesh *const  mesh,
const bool  enabled 
)

Enable/Disable transparency on the mesh.

Parameters
meshAddress to a jo_3d_mesh allocated struct
enabledtrue to enable transparency
static __jo_force_inline void jo_3d_set_scale ( const int  x,
const int  y,
const int  z 
)
static

Change scale.

Parameters
xX Scale
yY Scale
zZ Scale
static __jo_force_inline void jo_3d_set_scalef ( const float  x,
const float  y,
const float  z 
)
static

Change scale using floating number.

Parameters
xX Scale
yY Scale
zZ Scale
static __jo_force_inline void jo_3d_set_screen_doors ( jo_3d_quad *const  quad,
const bool  enabled 
)
static

Enable/Disable screen doors transparency on the quad.

Parameters
quadAddress to a jo_3d_quad allocated struct
enabledtrue to enable screen doors transparency
static __jo_force_inline void jo_3d_set_texture ( jo_3d_quad *const  quad,
const int  sprite_id 
)
static

Set a texture on the quadrilateral.

Parameters
quadAddress to a jo_3d_quad allocated struct
sprite_idSprite ID
static __jo_force_inline void jo_3d_set_transparency ( jo_3d_quad *const  quad,
const bool  enabled 
)
static

Enable/Disable transparency on the quadrilateral.

Parameters
quadAddress to a jo_3d_quad allocated struct
enabledtrue to enable transparency
static __jo_force_inline void jo_3d_translate_matrix ( int  x,
int  y,
int  z 
)
static

Translate 3D matrix.

Parameters
xX Position
yY Position
zZ Position
static __jo_force_inline void jo_3d_translate_matrix_x ( int  x)
static

Translate 3D matrix (X axis)

Parameters
xX Position
static __jo_force_inline void jo_3d_translate_matrix_y ( int  y)
static

Translate 3D matrix (Y axis)

Parameters
yY Position
static __jo_force_inline void jo_3d_translate_matrix_z ( int  z)
static

Translate 3D matrix (Z axis)

Parameters
zZ Position
static __jo_force_inline void jo_3d_translate_matrixf ( float  x,
float  y,
float  z 
)
static

Translate 3D matrix (using floating numbers)

Parameters
xX Position
yY Position
zZ Position
static __jo_force_inline bool jo_3d_window ( const int  left,
const int  top,
const int  right,
const int  bottom,
const int  z_limit,
const int  center_x,
const int  center_y 
)
static

Sets up a window region on the projection surface.

Parameters
left
top
right
bottom
z_limit
center_x
center_y
Returns
false if Failed

Variable Documentation

jo_3d_quad* __jo_sprite_quad[JO_MAX_SPRITE]

Sprite quads (internal engine usage)

Warning
MC Hammer: don't touch this