annotate light.cc @ 134:42337585fb7c

fix merge
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Fri, 22 Jul 2011 18:32:39 +0900
parents 6ef3b0efdeaf
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
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
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
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
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
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
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
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
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
20
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
21 l->light0[0] = 0.0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
22 l->light0[1] = 0.0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
23 l->light0[2] = 1.0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
24 l->light0[3] = 1.0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
25
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
26 l->light1[0] = 0.0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
27 l->light1[1] = -1.0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
28 l->light1[2] = 0.0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
29 l->light1[3] = 1.0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
30
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
31 l->light2[0] = 1.0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
32 l->light2[1] = 1.0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
33 l->light2[2] = 1.0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
34 l->light2[3] = 1.0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
35
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
36 l->color0[0] = 0.4;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
37 l->color0[1] = 0.4;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
38 l->color0[2] = 0.4;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
39 l->color0[3] = 1.0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
40
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
41 l->color1[0] = 0.4;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
42 l->color1[1] = 0.4;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
43 l->color1[2] = 0.4;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
44 l->color1[3] = 1.0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
45
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
46 l->color2[0] = 0.4;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
47 l->color2[1] = 0.4;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
48 l->color2[2] = 0.4;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
49 l->color2[3] = 1.0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
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
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
52 l->ambient[0] = 0.4;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
53 l->ambient[1] = 0.4;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
54 l->ambient[2] = 0.4;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
55 l->ambient[3] = 1.0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
56
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
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
e085768
parents: 100
diff changeset
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
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
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
e085768
parents: 100
diff changeset
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
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
72 {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
73 ps2_vu0_normal_light_matrix(normal_light, l->light0, l->light1, l->light2);
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
74 ps2_vu0_light_color_matrix(light_color, l->color0, l->color1, l->color2, l->ambient);
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
75 }