PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
math3d.h
Go to the documentation of this file.
1/*
2# _____ ___ ____ ___ ____
3# ____| | ____| | | |____|
4# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5#-----------------------------------------------------------------------
6# (c) 2005 Naomi Peori <naomi@peori.ca>
7# Licenced under Academic Free License version 2.0
8# Review ps2sdk README & LICENSE files for further details.
9*/
10
16#ifndef __MATH3D_H__
17#define __MATH3D_H__
18
19#include <tamtypes.h>
20
21typedef float VECTOR[4] __attribute__((__aligned__(16)));
22
23typedef float MATRIX[16] __attribute__((__aligned__(16)));
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29/* VECTOR FUNCTIONS */
31void vector_apply(VECTOR output, VECTOR input0, MATRIX input1);
32
34void vector_clamp(VECTOR output, VECTOR input0, float min, float max);
35
37void vector_copy(VECTOR output, VECTOR input0);
38
40float vector_innerproduct(VECTOR input0, VECTOR input1);
41
43void vector_multiply(VECTOR output, VECTOR input0, VECTOR input1);
44
46void vector_normalize(VECTOR output, VECTOR input0);
47
49void vector_outerproduct(VECTOR output, VECTOR input0, VECTOR input1);
50
52void vector_add(VECTOR sum, VECTOR addend, VECTOR summand);
53
55void vector_cross_product(VECTOR product, VECTOR multiplicand, VECTOR multiplier);
56
58void vector_triangle_normal(VECTOR output, VECTOR a, VECTOR b, VECTOR c);
59
60/* MATRIX FUNCTIONS */
62void matrix_copy(MATRIX output, MATRIX input0);
63
65void matrix_inverse(MATRIX output, MATRIX input0);
66
68void matrix_multiply(MATRIX output, MATRIX input0, MATRIX input1);
69
71void matrix_rotate(MATRIX output, MATRIX input0, VECTOR input1);
72
74void matrix_scale(MATRIX output, MATRIX input0, VECTOR input1);
75
77void matrix_translate(MATRIX output, MATRIX input0, VECTOR input1);
78
80void matrix_transpose(MATRIX output, MATRIX input0);
81
83void matrix_unit(MATRIX output);
84
85/* CREATE FUNCTIONS */
86
90void create_local_world(MATRIX local_world, VECTOR translation, VECTOR rotation);
91
95void create_local_light(MATRIX local_light, VECTOR rotation);
96
100void create_world_view(MATRIX world_view, VECTOR translation, VECTOR rotation);
101
105void create_view_screen(MATRIX view_screen, float aspect, float left, float right, float bottom, float top, float near, float far);
106
110void create_local_screen(MATRIX local_screen, MATRIX local_world, MATRIX world_view, MATRIX view_screen);
111
112/* CALCULATE FUNCTIONS */
113
115#define LIGHT_AMBIENT 0
117#define LIGHT_DIRECTIONAL 1
118
120void calculate_normals(VECTOR *output, int count, VECTOR *normals, MATRIX local_light);
121
123void calculate_lights(VECTOR *output, int count, VECTOR *normals, VECTOR *light_directions, VECTOR *light_colours, const int *light_types, int light_count);
124
126void calculate_colours(VECTOR *output, int count, VECTOR *colours, VECTOR *lights);
127
129void calculate_vertices(VECTOR *output, int count, VECTOR *vertices, MATRIX local_screen);
130
131#ifdef __cplusplus
132}
133#endif
134
135#endif /* __MATH3D_H__ */
void vector_normalize(VECTOR output, VECTOR input0)
Definition math3d.c:121
void vector_cross_product(VECTOR product, VECTOR multiplicand, VECTOR multiplier)
Definition math3d.c:182
void create_local_screen(MATRIX local_screen, MATRIX local_world, MATRIX world_view, MATRIX view_screen)
Definition math3d.c:466
void matrix_multiply(MATRIX output, MATRIX input0, MATRIX input1)
Definition math3d.c:251
void vector_copy(VECTOR output, VECTOR input0)
Definition math3d.c:73
void vector_multiply(VECTOR output, VECTOR input0, VECTOR input1)
Definition math3d.c:107
void vector_clamp(VECTOR output, VECTOR input0, float min, float max)
Definition math3d.c:50
void create_local_world(MATRIX local_world, VECTOR translation, VECTOR rotation)
Definition math3d.c:409
void matrix_copy(MATRIX output, MATRIX input0)
Definition math3d.c:207
float vector_innerproduct(VECTOR input0, VECTOR input1)
Definition math3d.c:87
void matrix_inverse(MATRIX output, MATRIX input0)
Definition math3d.c:233
void calculate_lights(VECTOR *output, int count, VECTOR *normals, VECTOR *light_directions, VECTOR *light_colours, const int *light_types, int light_count)
Definition math3d.c:524
void vector_triangle_normal(VECTOR output, VECTOR a, VECTOR b, VECTOR c)
Definition math3d.c:191
void calculate_vertices(VECTOR *output, int count, VECTOR *vertices, MATRIX local_screen)
Definition math3d.c:589
void matrix_scale(MATRIX output, MATRIX input0, VECTOR input1)
Definition math3d.c:346
void matrix_rotate(MATRIX output, MATRIX input0, VECTOR input1)
Definition math3d.c:317
void vector_add(VECTOR sum, VECTOR addend, VECTOR summand)
Definition math3d.c:173
void matrix_unit(MATRIX output)
Definition math3d.c:396
void create_world_view(MATRIX world_view, VECTOR translation, VECTOR rotation)
Definition math3d.c:426
void vector_outerproduct(VECTOR output, VECTOR input0, VECTOR input1)
Definition math3d.c:151
void create_view_screen(MATRIX view_screen, float aspect, float left, float right, float bottom, float top, float near, float far)
Definition math3d.c:448
void calculate_normals(VECTOR *output, int count, VECTOR *normals, MATRIX local_light)
Definition math3d.c:478
void vector_apply(VECTOR output, VECTOR input0, MATRIX input1)
Definition math3d.c:20
void matrix_translate(MATRIX output, MATRIX input0, VECTOR input1)
Definition math3d.c:358
void calculate_colours(VECTOR *output, int count, VECTOR *colours, VECTOR *lights)
Definition math3d.c:571
void create_local_light(MATRIX local_light, VECTOR rotation)
Definition math3d.c:418
void matrix_transpose(MATRIX output, MATRIX input0)
Definition math3d.c:370
u32 count
start sector of fragmented bd/file