ps2sdk  1.1
A collection of Open Source libraries used for developing applications on Sony's PlayStation 2® (PS2).
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 
21 typedef float VECTOR[4] __attribute__((__aligned__(16)));
22 
23 typedef float MATRIX[16] __attribute__((__aligned__(16)));
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 /* VECTOR FUNCTIONS */
31 void vector_apply(VECTOR output, VECTOR input0, MATRIX input1);
32 
34 void vector_clamp(VECTOR output, VECTOR input0, float min, float max);
35 
37 void vector_copy(VECTOR output, VECTOR input0);
38 
40 float vector_innerproduct(VECTOR input0, VECTOR input1);
41 
43 void vector_multiply(VECTOR output, VECTOR input0, VECTOR input1);
44 
46 void vector_normalize(VECTOR output, VECTOR input0);
47 
49 void vector_outerproduct(VECTOR output, VECTOR input0, VECTOR input1);
50 
51 /* MATRIX FUNCTIONS */
53 void matrix_copy(MATRIX output, MATRIX input0);
54 
56 void matrix_inverse(MATRIX output, MATRIX input0);
57 
59 void matrix_multiply(MATRIX output, MATRIX input0, MATRIX input1);
60 
62 void matrix_rotate(MATRIX output, MATRIX input0, VECTOR input1);
63 
65 void matrix_scale(MATRIX output, MATRIX input0, VECTOR input1);
66 
68 void matrix_translate(MATRIX output, MATRIX input0, VECTOR input1);
69 
71 void matrix_transpose(MATRIX output, MATRIX input0);
72 
74 void matrix_unit(MATRIX output);
75 
76 /* CREATE FUNCTIONS */
77 
81 void create_local_world(MATRIX local_world, VECTOR translation, VECTOR rotation);
82 
86 void create_local_light(MATRIX local_light, VECTOR rotation);
87 
91 void create_world_view(MATRIX world_view, VECTOR translation, VECTOR rotation);
92 
96 void create_view_screen(MATRIX view_screen, float aspect, float left, float right, float bottom, float top, float near, float far);
97 
102 
103 /* CALCULATE FUNCTIONS */
104 
106 #define LIGHT_AMBIENT 0
108 #define LIGHT_DIRECTIONAL 1
109 
111 void calculate_normals(VECTOR *output, int count, VECTOR *normals, MATRIX local_light);
112 
114 void calculate_lights(VECTOR *output, int count, VECTOR *normals, VECTOR *light_directions, VECTOR *light_colours, int *light_types, int light_count);
115 
117 void calculate_colours(VECTOR *output, int count, VECTOR *colours, VECTOR *lights);
118 
120 void calculate_vertices(VECTOR *output, int count, VECTOR *vertices, MATRIX local_screen);
121 
122 #ifdef __cplusplus
123 }
124 #endif
125 
126 #endif /* __MATH3D_H__ */
VECTOR vertices[24]
Definition: mesh_data.c:31
VECTOR colours[24]
Definition: mesh_data.c:58
MATRIX world_view
Definition: main.c:57
MATRIX local_screen
Definition: main.c:57
MATRIX local_world
Definition: main.c:57
MATRIX view_screen
Definition: main.c:57
void vector_normalize(VECTOR output, VECTOR input0)
Definition: math3d.c:121
float MATRIX[16]
Definition: math3d.h:23
void create_local_screen(MATRIX local_screen, MATRIX local_world, MATRIX world_view, MATRIX view_screen)
Definition: math3d.c:434
void matrix_multiply(MATRIX output, MATRIX input0, MATRIX input1)
Definition: math3d.c:219
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:377
void matrix_copy(MATRIX output, MATRIX input0)
Definition: math3d.c:175
float vector_innerproduct(VECTOR input0, VECTOR input1)
Definition: math3d.c:87
void matrix_inverse(MATRIX output, MATRIX input0)
Definition: math3d.c:201
void calculate_vertices(VECTOR *output, int count, VECTOR *vertices, MATRIX local_screen)
Definition: math3d.c:557
void matrix_scale(MATRIX output, MATRIX input0, VECTOR input1)
Definition: math3d.c:314
void matrix_rotate(MATRIX output, MATRIX input0, VECTOR input1)
Definition: math3d.c:285
void matrix_unit(MATRIX output)
Definition: math3d.c:364
void create_world_view(MATRIX world_view, VECTOR translation, VECTOR rotation)
Definition: math3d.c:394
void calculate_lights(VECTOR *output, int count, VECTOR *normals, VECTOR *light_directions, VECTOR *light_colours, int *light_types, int light_count)
Definition: math3d.c:492
void vector_outerproduct(VECTOR output, VECTOR input0, VECTOR input1)
Definition: math3d.c:151
float VECTOR[4]
Definition: math3d.h:21
void create_view_screen(MATRIX view_screen, float aspect, float left, float right, float bottom, float top, float near, float far)
Definition: math3d.c:416
void calculate_normals(VECTOR *output, int count, VECTOR *normals, MATRIX local_light)
Definition: math3d.c:446
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:326
void calculate_colours(VECTOR *output, int count, VECTOR *colours, VECTOR *lights)
Definition: math3d.c:539
void create_local_light(MATRIX local_light, VECTOR rotation)
Definition: math3d.c:386
void matrix_transpose(MATRIX output, MATRIX input0)
Definition: math3d.c:338
#define min(a, b)
Definition: standard.h:54
#define max(a, b)
Definition: standard.h:57
VECTOR normals[1598]
Definition: mesh_data.c:4756
int light_count
Definition: teapot.c:43