Mercurial > hg > old > magoroku_racing
annotate light.cc @ 138:993d5f7e5f30
collision
malloc error after face reading
author | e085768 |
---|---|
date | Fri, 22 Jul 2011 23:51:14 +0900 |
parents | 6ef3b0efdeaf |
children |
rev | line source |
---|---|
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
90
diff
changeset
|
1 /* light.c */ |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
90
diff
changeset
|
2 |
0 | 3 #include <stdio.h> |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
90
diff
changeset
|
4 #include "libps2.h" |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
90
diff
changeset
|
5 #include "light.h" |
0 | 6 |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
90
diff
changeset
|
7 #include "sjoy.h" // ps2関連ファイルから |
0 | 8 |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
90
diff
changeset
|
9 FMATRIX normal_light; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
90
diff
changeset
|
10 FMATRIX light_color; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
90
diff
changeset
|
11 |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
90
diff
changeset
|
12 |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
90
diff
changeset
|
13 void init_light(LIGHT *l) |
0 | 14 { |
90
8edae89a3877
compile on Mac OS X
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
2
diff
changeset
|
15 //Three lights in all. |
8edae89a3877
compile on Mac OS X
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
2
diff
changeset
|
16 // The color of the light of "light0" is color0. |
8edae89a3877
compile on Mac OS X
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
2
diff
changeset
|
17 // The color of the light of "light1" is color1. |
8edae89a3877
compile on Mac OS X
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
2
diff
changeset
|
18 // The color of the light of "light2" is color2. |
8edae89a3877
compile on Mac OS X
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
2
diff
changeset
|
19 |
0 | 20 |
21 l->light0[0] = 0.0; | |
22 l->light0[1] = 0.0; | |
23 l->light0[2] = 1.0; | |
24 l->light0[3] = 1.0; | |
25 | |
26 l->light1[0] = 0.0; | |
27 l->light1[1] = -1.0; | |
28 l->light1[2] = 0.0; | |
29 l->light1[3] = 1.0; | |
30 | |
31 l->light2[0] = 1.0; | |
32 l->light2[1] = 1.0; | |
33 l->light2[2] = 1.0; | |
34 l->light2[3] = 1.0; | |
35 | |
36 l->color0[0] = 0.4; | |
37 l->color0[1] = 0.4; | |
38 l->color0[2] = 0.4; | |
39 l->color0[3] = 1.0; | |
40 | |
41 l->color1[0] = 0.4; | |
42 l->color1[1] = 0.4; | |
43 l->color1[2] = 0.4; | |
44 l->color1[3] = 1.0; | |
45 | |
46 l->color2[0] = 0.4; | |
47 l->color2[1] = 0.4; | |
48 l->color2[2] = 0.4; | |
49 l->color2[3] = 1.0; | |
50 | |
90
8edae89a3877
compile on Mac OS X
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
2
diff
changeset
|
51 //Reflection degree of light |
0 | 52 l->ambient[0] = 0.4; |
53 l->ambient[1] = 0.4; | |
54 l->ambient[2] = 0.4; | |
55 l->ambient[3] = 1.0; | |
56 | |
57 } | |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
90
diff
changeset
|
58 |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
90
diff
changeset
|
59 // 自作:miya |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
90
diff
changeset
|
60 void ps2_vu0_normal_light_matrix(FMATRIX light_color, FVECTOR l0, FVECTOR l1, FVECTOR l2) |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
90
diff
changeset
|
61 { |
124 | 62 printf("ps2_vu0_normal_light_matrix\n"); |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
90
diff
changeset
|
63 } |
0 | 64 |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
90
diff
changeset
|
65 // 自作:miya |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
90
diff
changeset
|
66 void ps2_vu0_light_color_matrix( FMATRIX light_color, FVECTOR c0, FVECTOR c1, FVECTOR c2, FVECTOR a) |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
90
diff
changeset
|
67 { |
124 | 68 printf("ps2_vu0_light_color_matrix\n"); |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
90
diff
changeset
|
69 } |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
90
diff
changeset
|
70 |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
90
diff
changeset
|
71 void set_light(LIGHT *l) |
0 | 72 { |
73 ps2_vu0_normal_light_matrix(normal_light, l->light0, l->light1, l->light2); | |
74 ps2_vu0_light_color_matrix(light_color, l->color0, l->color1, l->color2, l->ambient); | |
75 } |