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