0
|
1 /*
|
17
|
2 * $Id$
|
0
|
3 */
|
|
4 #include <stdlib.h>
|
|
5 #include "libps2.h"
|
|
6 #include "ps2util.h"
|
|
7 #include "car.h"
|
|
8 #include "game.h"
|
|
9 #include "controler.h"
|
|
10
|
|
11 extern SGO_PAD pad;
|
|
12
|
|
13 static CAMERA camera, def_camera;
|
|
14
|
|
15
|
|
16 void
|
|
17 camera_init()
|
|
18 {
|
|
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;
|
|
24
|
|
25 def_camera.zd[0] = 0;
|
|
26 def_camera.zd[1] = 2;
|
|
27 def_camera.zd[2] = 7;
|
|
28 def_camera.zd[3] = 1;
|
|
29
|
|
30 def_camera.yd[0] = 0;
|
|
31 def_camera.yd[1] = 1;
|
|
32 def_camera.yd[2] = 0;
|
|
33 def_camera.yd[3] = 1;
|
|
34
|
|
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;
|
|
39 memcpy( &camera, &def_camera, sizeof(CAMERA));
|
|
40 set_camera(&def_camera);
|
|
41 }
|
|
42
|
|
43
|
|
44 /**
|
88
|
45 * pose: カメラの対象物(obj)の座標行列
|
|
46 * カメラがobjについていくように(そのような動きに見せるため)
|
|
47 * カメラの位置ベクトル、視点ベクトルを更新
|
0
|
48 */
|
|
49 void
|
|
50 camera_update(FMATRIX pose)
|
|
51 {
|
|
52
|
|
53 FVECTOR location, eyes, vertical, angle;
|
|
54 // int type = game.camera_type;
|
|
55
|
|
56 ps2_vu0_apply_matrix(location, pose, def_camera.xyz);
|
|
57 ps2_vu0_apply_matrix(eyes, pose, def_camera.zd);
|
|
58 ps2_vu0_apply_matrix(vertical, pose, def_camera.yd);
|
|
59
|
|
60 /**When the car bends, the angle of the camera is changed**/
|
|
61 if(pad.left>0 && game.jiki->speed !=0){
|
|
62 if(def_camera.angle[1]<=0.2){
|
|
63 def_camera.angle[1]+=0.02;
|
|
64 }
|
|
65 }
|
|
66 else if(pad.right>0 && game.jiki->speed !=0){
|
|
67 if(def_camera.angle[1]>=-0.2){
|
|
68 def_camera.angle[1]-=0.02;
|
|
69 }
|
|
70 }
|
|
71 else {
|
|
72 if(def_camera.angle[1]<-0.01){
|
|
73 def_camera.angle[1]+=0.02;
|
|
74 }
|
|
75 else if(def_camera.angle[1]>0.01){
|
|
76 def_camera.angle[1]-=0.02;
|
|
77 }
|
|
78 }
|
|
79 ps2_vu0_apply_matrix(angle, pose, def_camera.angle);
|
|
80 ps2_vu0_copy_vector(camera.xyz, location);
|
|
81 ps2_vu0_copy_vector(camera.zd, eyes);
|
|
82 ps2_vu0_copy_vector(camera.yd, vertical);
|
|
83 ps2_vu0_copy_vector(camera.angle, angle);
|
|
84 set_camera(&camera);
|
|
85
|
|
86 }
|
|
87
|
|
88
|