sdk-core v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Loading...
Searching...
No Matches
math3d.h File Reference
#include <tamtypes.h>

Go to the source code of this file.

Macros

#define LIGHT_AMBIENT   0
#define LIGHT_DIRECTIONAL   1

Typedefs

typedef float VECTOR[4] __attribute__((__aligned__(16)))

Functions

void vector_apply (VECTOR output, VECTOR input0, MATRIX input1)
void vector_clamp (VECTOR output, VECTOR input0, float min, float max)
void vector_copy (VECTOR output, VECTOR input0)
float vector_innerproduct (VECTOR input0, VECTOR input1)
void vector_multiply (VECTOR output, VECTOR input0, VECTOR input1)
void vector_normalize (VECTOR output, VECTOR input0)
void vector_outerproduct (VECTOR output, VECTOR input0, VECTOR input1)
void vector_add (VECTOR sum, VECTOR addend, VECTOR summand)
void vector_cross_product (VECTOR product, VECTOR multiplicand, VECTOR multiplier)
void vector_triangle_normal (VECTOR output, VECTOR a, VECTOR b, VECTOR c)
void matrix_copy (MATRIX output, MATRIX input0)
void matrix_inverse (MATRIX output, MATRIX input0)
void matrix_multiply (MATRIX output, MATRIX input0, MATRIX input1)
void matrix_rotate (MATRIX output, MATRIX input0, VECTOR input1)
void matrix_scale (MATRIX output, MATRIX input0, VECTOR input1)
void matrix_translate (MATRIX output, MATRIX input0, VECTOR input1)
void matrix_transpose (MATRIX output, MATRIX input0)
void matrix_unit (MATRIX output)
void create_local_world (MATRIX local_world, VECTOR translation, VECTOR rotation)
void create_local_light (MATRIX local_light, VECTOR rotation)
void create_world_view (MATRIX world_view, VECTOR translation, VECTOR rotation)
void create_view_screen (MATRIX view_screen, float aspect, float left, float right, float bottom, float top, float near, float far)
void create_local_screen (MATRIX local_screen, MATRIX local_world, MATRIX world_view, MATRIX view_screen)
void calculate_normals (VECTOR *output, int count, VECTOR *normals, MATRIX local_light)
void calculate_lights (VECTOR *output, int count, VECTOR *normals, VECTOR *light_directions, VECTOR *light_colours, const int *light_types, int light_count)
void calculate_colours (VECTOR *output, int count, VECTOR *colours, VECTOR *lights)
void calculate_vertices (VECTOR *output, int count, VECTOR *vertices, MATRIX local_screen)

Detailed Description

3D math functions.

Definition in file math3d.h.

Macro Definition Documentation

◆ LIGHT_AMBIENT

#define LIGHT_AMBIENT   0

Ambient light source.

Definition at line 116 of file math3d.h.

◆ LIGHT_DIRECTIONAL

#define LIGHT_DIRECTIONAL   1

Directional light source.

Definition at line 118 of file math3d.h.

Typedef Documentation

◆ __attribute__

typedef float MATRIX[16] __attribute__((__aligned__(16)))

Definition at line 22 of file math3d.h.

Function Documentation

◆ calculate_colours()

void calculate_colours ( VECTOR * output,
int count,
VECTOR * colours,
VECTOR * lights )
extern

Calculate colour values given an array of light intensity values.

Definition at line 646 of file math3d.c.

◆ calculate_lights()

void calculate_lights ( VECTOR * output,
int count,
VECTOR * normals,
VECTOR * light_directions,
VECTOR * light_colours,
const int * light_types,
int light_count )
extern

Calculate the light intensity for an array of lights given an array of normal values.

Definition at line 599 of file math3d.c.

◆ calculate_normals()

void calculate_normals ( VECTOR * output,
int count,
VECTOR * normals,
MATRIX local_light )
extern

Transform an array of normals by applying the specified local_light matrix.

Definition at line 532 of file math3d.c.

◆ calculate_vertices()

void calculate_vertices ( VECTOR * output,
int count,
VECTOR * vertices,
MATRIX local_screen )
extern

Calculate vertex values by applying the specific local_screen matrix.

Definition at line 664 of file math3d.c.

◆ create_local_light()

void create_local_light ( MATRIX local_light,
VECTOR rotation )
extern

Create a local_light matrix given a rotation. Commonly used to transform an object's normals for lighting calculations.

Definition at line 472 of file math3d.c.

◆ create_local_screen()

void create_local_screen ( MATRIX local_screen,
MATRIX local_world,
MATRIX world_view,
MATRIX view_screen )
extern

Create a local_screen matrix given a local_world, world_view and view_screen matrix. Commonly used with vector_apply() to transform vertices for rendering.

Definition at line 520 of file math3d.c.

◆ create_local_world()

void create_local_world ( MATRIX local_world,
VECTOR translation,
VECTOR rotation )
extern

Create a local_world matrix given a translation and rotation. Commonly used to describe an object's position and orientation.

Definition at line 463 of file math3d.c.

◆ create_view_screen()

void create_view_screen ( MATRIX view_screen,
float aspect,
float left,
float right,
float bottom,
float top,
float near,
float far )
extern

Create a view_screen matrix given an aspect and clipping plane values. Functionally similar to the opengl function: glFrustum()

Definition at line 502 of file math3d.c.

◆ create_world_view()

void create_world_view ( MATRIX world_view,
VECTOR translation,
VECTOR rotation )
extern

Create a world_view matrix given a translation and rotation. Commonly used to describe a camera's position and rotation.

Definition at line 480 of file math3d.c.

◆ matrix_copy()

void matrix_copy ( MATRIX output,
MATRIX input0 )
extern

Copy a matrix.

Definition at line 240 of file math3d.c.

◆ matrix_inverse()

void matrix_inverse ( MATRIX output,
MATRIX input0 )
extern

Calculate the inverse of a matrix.

Definition at line 270 of file math3d.c.

◆ matrix_multiply()

void matrix_multiply ( MATRIX output,
MATRIX input0,
MATRIX input1 )
extern

Multiply two matrices together.

Definition at line 288 of file math3d.c.

◆ matrix_rotate()

void matrix_rotate ( MATRIX output,
MATRIX input0,
VECTOR input1 )
extern

Create a rotation matrix and apply it to the specified input matrix.

Definition at line 371 of file math3d.c.

◆ matrix_scale()

void matrix_scale ( MATRIX output,
MATRIX input0,
VECTOR input1 )
extern

Create a scaling matrix and apply it to the specified input matrix.

Definition at line 400 of file math3d.c.

◆ matrix_translate()

void matrix_translate ( MATRIX output,
MATRIX input0,
VECTOR input1 )
extern

Create a translation matrix and apply it to the specified input matrix.

Definition at line 412 of file math3d.c.

◆ matrix_transpose()

void matrix_transpose ( MATRIX output,
MATRIX input0 )
extern

Transpose a matrix.

Definition at line 424 of file math3d.c.

◆ matrix_unit()

void matrix_unit ( MATRIX output)
extern

Create a unit matrix.

Definition at line 450 of file math3d.c.

◆ vector_add()

void vector_add ( VECTOR sum,
VECTOR addend,
VECTOR summand )
extern

Add two vectors

Definition at line 206 of file math3d.c.

◆ vector_apply()

void vector_apply ( VECTOR output,
VECTOR input0,
MATRIX input1 )
extern

Multiply a vector by a matrix, returning a vector.

Definition at line 20 of file math3d.c.

◆ vector_clamp()

void vector_clamp ( VECTOR output,
VECTOR input0,
float min,
float max )
extern

Clamp a vector's values by cutting them off at a minimum and maximum value.

Definition at line 63 of file math3d.c.

◆ vector_copy()

void vector_copy ( VECTOR output,
VECTOR input0 )
extern

Copy a vector.

Definition at line 86 of file math3d.c.

◆ vector_cross_product()

void vector_cross_product ( VECTOR product,
VECTOR multiplicand,
VECTOR multiplier )
extern

Calculate the cross product of two vectors

Definition at line 215 of file math3d.c.

◆ vector_innerproduct()

float vector_innerproduct ( VECTOR input0,
VECTOR input1 )
extern

Calculate the inner product of two vectors. Returns a scalar value.

Definition at line 104 of file math3d.c.

◆ vector_multiply()

void vector_multiply ( VECTOR output,
VECTOR input0,
VECTOR input1 )
extern

Multiply two vectors together.

Definition at line 124 of file math3d.c.

◆ vector_normalize()

void vector_normalize ( VECTOR output,
VECTOR input0 )
extern

Normalize a vector by determining its length and dividing its values by this value.

Definition at line 138 of file math3d.c.

◆ vector_outerproduct()

void vector_outerproduct ( VECTOR output,
VECTOR input0,
VECTOR input1 )
extern

Calculate the outer product of two vectors.

Definition at line 177 of file math3d.c.

◆ vector_triangle_normal()

void vector_triangle_normal ( VECTOR output,
VECTOR a,
VECTOR b,
VECTOR c )
extern

Calculates the normal of 3 vectors

Definition at line 224 of file math3d.c.