Mercurial > hg > old > magoroku_racing
annotate camera.cc @ 134:42337585fb7c
fix merge
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 22 Jul 2011 18:32:39 +0900 |
parents | d9e3137e70a0 |
children |
rev | line source |
---|---|
0 | 1 #include <stdlib.h> |
91 | 2 #include <string.h> |
3 #include "libps2.h" | |
4 #include "ps2util.h" | |
0 | 5 #include "car.h" |
6 #include "game.h" | |
7 #include "controler.h" | |
91 | 8 #include "camera.h" |
0 | 9 |
90
8edae89a3877
compile on Mac OS X
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
88
diff
changeset
|
10 //大域変数、各部で共有 |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
11 extern SGO_PAD pad; |
0 | 12 |
91 | 13 static CAMERA camera, def_camera; |
0 | 14 |
15 | |
16 void | |
17 camera_init() | |
18 { | |
124 | 19 //カメラの初期位置設定 |
20 def_camera.xyz[0] = 0; | |
21 def_camera.xyz[1] =-7;// -3; | |
22 def_camera.xyz[2] =-14; //0; | |
23 def_camera.xyz[3] = 1; | |
0 | 24 |
124 | 25 def_camera.zd[0] = 0; |
26 def_camera.zd[1] = 2; | |
27 def_camera.zd[2] = 7; | |
28 def_camera.zd[3] = 1; | |
0 | 29 |
124 | 30 def_camera.yd[0] = 0; |
31 def_camera.yd[1] = 1; | |
32 def_camera.yd[2] = 0; | |
33 def_camera.yd[3] = 1; | |
0 | 34 |
124 | 35 def_camera.angle[0]=-0.2;//0; //pich |
36 def_camera.angle[1]=0; //yoh | |
37 def_camera.angle[2]=0; //roll | |
38 def_camera.angle[3]=0; | |
90
8edae89a3877
compile on Mac OS X
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
88
diff
changeset
|
39 |
124 | 40 //def_cameraをcameraにコピー |
41 memcpy( &camera, &def_camera, sizeof(CAMERA)); | |
42 set_camera(&def_camera); | |
0 | 43 } |
44 | |
91 | 45 /* |
46 ps2依存関係から拝借。 | |
47 自分が消したのか、元々無いのかは覚えていないけど | |
48 呼ばれているのでとりあえず(空っぽにしておく)。 | |
49 */ | |
50 // set_camera must be called if camera's parameters were moved | |
51 void set_camera(CAMERA *camera) | |
52 { | |
53 //vu0_rot_camera_matrix(world_view, camera->xyz, camera->zd, camera->yd,camera->angle); | |
54 } | |
55 | |
56 | |
0 | 57 /** |
88 | 58 * pose: カメラの対象物(obj)の座標行列 |
59 * カメラがobjについていくように(そのような動きに見せるため) | |
60 * カメラの位置ベクトル、視点ベクトルを更新 | |
0 | 61 */ |
62 void | |
91 | 63 camera_update(Game *game, FMATRIX pose) |
0 | 64 { |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
65 FVECTOR location, eyes, vertical, angle; |
128 | 66 |
67 //int type = game->camera_type; | |
0 | 68 |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
69 ps2_vu0_apply_matrix(location, pose, def_camera.xyz); |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
70 ps2_vu0_apply_matrix(eyes, pose, def_camera.zd); |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
71 ps2_vu0_apply_matrix(vertical, pose, def_camera.yd); |
0 | 72 |
73 /**When the car bends, the angle of the camera is changed**/ | |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
74 if(pad.left>0 && game->jiki->speed !=0){ |
90
8edae89a3877
compile on Mac OS X
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
88
diff
changeset
|
75 if(game->jiki->speed !=0){ |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
76 if(def_camera.angle[1]<=0.2){ |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
77 def_camera.angle[1]+=0.02; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
78 } |
0 | 79 } |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
80 } |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
81 else if(pad.right>0 && game->jiki->speed !=0){ |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
82 if(game->jiki->speed !=0){ |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
83 if(def_camera.angle[1]>=-0.2){ |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
84 def_camera.angle[1]-=0.02; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
85 } |
0 | 86 } |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
87 } |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
88 else { |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
89 if(def_camera.angle[1]<-0.01){ |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
90 def_camera.angle[1]+=0.02; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
91 } |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
92 else if(def_camera.angle[1]>0.01){ |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
93 def_camera.angle[1]-=0.02; |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
94 } |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
95 } |
128 | 96 |
96
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
97 ps2_vu0_apply_matrix(angle, pose, def_camera.angle); |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
98 ps2_vu0_copy_vector(camera.xyz, location); |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
99 ps2_vu0_copy_vector(camera.zd, eyes); |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
100 ps2_vu0_copy_vector(camera.yd, vertical); |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
101 ps2_vu0_copy_vector(camera.angle, angle); |
0b65ca27f113
compile on Mac OS X 2
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
91
diff
changeset
|
102 set_camera(&camera); |
0 | 103 } |
128 | 104 |
105 | |
106 CAMERA get_MagorokuCamera( void ) | |
107 { | |
108 return camera; | |
109 } |