PS2SDK
PS2 Homebrew Libraries
|
#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) |
3D math functions.
Definition in file math3d.h.
typedef float MATRIX[16] __attribute__((__aligned__(16))) |
void vector_apply | ( | VECTOR | output, |
VECTOR | input0, | ||
MATRIX | input1 | ||
) |
Multiply a vector by a matrix, returning a vector.
Definition at line 20 of file math3d.c.
References vector_apply().
Referenced by vector_apply().
void vector_clamp | ( | VECTOR | output, |
VECTOR | input0, | ||
float | min, | ||
float | max | ||
) |
Clamp a vector's values by cutting them off at a minimum and maximum value.
Definition at line 50 of file math3d.c.
References vector_clamp(), and vector_copy().
Referenced by calculate_colours(), and vector_clamp().
void vector_copy | ( | VECTOR | output, |
VECTOR | input0 | ||
) |
Copy a vector.
Definition at line 73 of file math3d.c.
References vector_copy().
Referenced by vector_add(), vector_clamp(), vector_copy(), vector_cross_product(), vector_multiply(), and vector_triangle_normal().
float vector_innerproduct | ( | VECTOR | input0, |
VECTOR | input1 | ||
) |
Calculate the inner product of two vectors. Returns a scalar value.
Definition at line 87 of file math3d.c.
References vector_innerproduct().
Referenced by calculate_lights(), and vector_innerproduct().
void vector_multiply | ( | VECTOR | output, |
VECTOR | input0, | ||
VECTOR | input1 | ||
) |
Multiply two vectors together.
Definition at line 107 of file math3d.c.
References vector_copy(), and vector_multiply().
Referenced by vector_multiply().
void vector_normalize | ( | VECTOR | output, |
VECTOR | input0 | ||
) |
Normalize a vector by determining its length and dividing its values by this value.
Definition at line 121 of file math3d.c.
References vector_normalize().
Referenced by vector_normalize(), and vector_triangle_normal().
void vector_outerproduct | ( | VECTOR | output, |
VECTOR | input0, | ||
VECTOR | input1 | ||
) |
Calculate the outer product of two vectors.
Definition at line 151 of file math3d.c.
References vector_outerproduct().
Referenced by vector_outerproduct().
void vector_add | ( | VECTOR | sum, |
VECTOR | addend, | ||
VECTOR | summand | ||
) |
Add two vectors
Definition at line 173 of file math3d.c.
References vector_add(), and vector_copy().
Referenced by vector_add(), and vector_triangle_normal().
void vector_cross_product | ( | VECTOR | product, |
VECTOR | multiplicand, | ||
VECTOR | multiplier | ||
) |
Calculate the cross product of two vectors
Definition at line 182 of file math3d.c.
References vector_copy(), and vector_cross_product().
Referenced by vector_cross_product(), and vector_triangle_normal().
void vector_triangle_normal | ( | VECTOR | output, |
VECTOR | a, | ||
VECTOR | b, | ||
VECTOR | c | ||
) |
Calculates the normal of 3 vectors
Definition at line 191 of file math3d.c.
References vector_add(), vector_copy(), vector_cross_product(), vector_normalize(), and vector_triangle_normal().
Referenced by vector_triangle_normal().
void matrix_copy | ( | MATRIX | output, |
MATRIX | input0 | ||
) |
Copy a matrix.
Definition at line 207 of file math3d.c.
References matrix_copy().
Referenced by matrix_copy(), matrix_inverse(), and matrix_transpose().
void matrix_inverse | ( | MATRIX | output, |
MATRIX | input0 | ||
) |
Calculate the inverse of a matrix.
Definition at line 233 of file math3d.c.
References matrix_copy(), matrix_inverse(), and matrix_transpose().
Referenced by matrix_inverse().
void matrix_multiply | ( | MATRIX | output, |
MATRIX | input0, | ||
MATRIX | input1 | ||
) |
Multiply two matrices together.
Definition at line 251 of file math3d.c.
References matrix_multiply().
Referenced by create_local_screen(), matrix_multiply(), matrix_rotate(), matrix_scale(), and matrix_translate().
void matrix_rotate | ( | MATRIX | output, |
MATRIX | input0, | ||
VECTOR | input1 | ||
) |
Create a rotation matrix and apply it to the specified input matrix.
Definition at line 317 of file math3d.c.
References matrix_multiply(), matrix_rotate(), and matrix_unit().
Referenced by create_local_light(), create_local_world(), create_world_view(), and matrix_rotate().
void matrix_scale | ( | MATRIX | output, |
MATRIX | input0, | ||
VECTOR | input1 | ||
) |
Create a scaling matrix and apply it to the specified input matrix.
Definition at line 346 of file math3d.c.
References matrix_multiply(), matrix_scale(), and matrix_unit().
Referenced by matrix_scale().
void matrix_translate | ( | MATRIX | output, |
MATRIX | input0, | ||
VECTOR | input1 | ||
) |
Create a translation matrix and apply it to the specified input matrix.
Definition at line 358 of file math3d.c.
References matrix_multiply(), matrix_translate(), and matrix_unit().
Referenced by create_local_world(), create_world_view(), and matrix_translate().
void matrix_transpose | ( | MATRIX | output, |
MATRIX | input0 | ||
) |
Transpose a matrix.
Definition at line 370 of file math3d.c.
References matrix_copy(), and matrix_transpose().
Referenced by matrix_inverse(), and matrix_transpose().
void matrix_unit | ( | MATRIX | output | ) |
Create a unit matrix.
Definition at line 396 of file math3d.c.
References matrix_unit().
Referenced by create_local_light(), create_local_screen(), create_local_world(), create_view_screen(), create_world_view(), matrix_rotate(), matrix_scale(), matrix_translate(), and matrix_unit().
void create_local_world | ( | MATRIX | local_world, |
VECTOR | translation, | ||
VECTOR | rotation | ||
) |
Create a local_world matrix given a translation and rotation. Commonly used to describe an object's position and orientation.
Definition at line 409 of file math3d.c.
References create_local_world(), matrix_rotate(), matrix_translate(), and matrix_unit().
Referenced by create_local_world().
void create_local_light | ( | MATRIX | local_light, |
VECTOR | rotation | ||
) |
Create a local_light matrix given a rotation. Commonly used to transform an object's normals for lighting calculations.
Definition at line 418 of file math3d.c.
References create_local_light(), matrix_rotate(), and matrix_unit().
Referenced by create_local_light().
void create_world_view | ( | MATRIX | world_view, |
VECTOR | translation, | ||
VECTOR | rotation | ||
) |
Create a world_view matrix given a translation and rotation. Commonly used to describe a camera's position and rotation.
Definition at line 426 of file math3d.c.
References create_world_view(), matrix_rotate(), matrix_translate(), and matrix_unit().
Referenced by create_world_view().
void create_view_screen | ( | MATRIX | view_screen, |
float | aspect, | ||
float | left, | ||
float | right, | ||
float | bottom, | ||
float | top, | ||
float | near, | ||
float | far | ||
) |
Create a view_screen matrix given an aspect and clipping plane values. Functionally similar to the opengl function: glFrustum()
Definition at line 448 of file math3d.c.
References create_view_screen(), and matrix_unit().
Referenced by create_view_screen().
void create_local_screen | ( | MATRIX | local_screen, |
MATRIX | local_world, | ||
MATRIX | world_view, | ||
MATRIX | view_screen | ||
) |
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 466 of file math3d.c.
References create_local_screen(), matrix_multiply(), and matrix_unit().
Referenced by create_local_screen().
void calculate_normals | ( | VECTOR * | output, |
int | count, | ||
VECTOR * | normals, | ||
MATRIX | local_light | ||
) |
Transform an array of normals by applying the specified local_light matrix.
Definition at line 478 of file math3d.c.
References calculate_normals(), and count.
Referenced by calculate_normals().
void calculate_lights | ( | VECTOR * | output, |
int | count, | ||
VECTOR * | normals, | ||
VECTOR * | light_directions, | ||
VECTOR * | light_colours, | ||
const int * | light_types, | ||
int | light_count | ||
) |
Calculate the light intensity for an array of lights given an array of normal values.
Definition at line 524 of file math3d.c.
References calculate_lights(), count, LIGHT_AMBIENT, LIGHT_DIRECTIONAL, and vector_innerproduct().
Referenced by calculate_lights().
void calculate_colours | ( | VECTOR * | output, |
int | count, | ||
VECTOR * | colours, | ||
VECTOR * | lights | ||
) |
Calculate colour values given an array of light intensity values.
Definition at line 571 of file math3d.c.
References calculate_colours(), count, and vector_clamp().
Referenced by calculate_colours().
void calculate_vertices | ( | VECTOR * | output, |
int | count, | ||
VECTOR * | vertices, | ||
MATRIX | local_screen | ||
) |
Calculate vertex values by applying the specific local_screen matrix.
Definition at line 589 of file math3d.c.
References calculate_vertices(), and count.
Referenced by calculate_vertices().