annotate camera.c @ 30:7a348d9ce4ac

*** empty log message ***
author gongo
date Sun, 05 Nov 2006 02:36:29 +0000
parents 6910aeb52843
children ce9ef7dcf2f0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
1 /*
17
6910aeb52843 *** empty log message ***
gongo
parents: 0
diff changeset
2 * $Id$
0
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
3 */
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
4 #include <stdlib.h>
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
5 #include "libps2.h"
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
6 #include "ps2util.h"
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
7 #include "car.h"
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
8 #include "game.h"
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
9 #include "controler.h"
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
10
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
11 extern SGO_PAD pad;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
12
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
13 static CAMERA camera, def_camera;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
14
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
15
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
16 void
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
17 camera_init()
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
18 {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
19
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
20 def_camera.xyz[0] = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
21 def_camera.xyz[1] =-7;// -3;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
22 def_camera.xyz[2] =-14; //0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
23 def_camera.xyz[3] = 1;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
24
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
25 def_camera.zd[0] = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
26 def_camera.zd[1] = 2;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
27 def_camera.zd[2] = 7;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
28 def_camera.zd[3] = 1;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
29
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
30 def_camera.yd[0] = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
31 def_camera.yd[1] = 1;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
32 def_camera.yd[2] = 0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
33 def_camera.yd[3] = 1;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
34
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
35 def_camera.angle[0]=-0.2;//0; //pich
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
36 def_camera.angle[1]=0; //yoh
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
37 def_camera.angle[2]=0; //roll
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
38 def_camera.angle[3]=0;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
39 memcpy( &camera, &def_camera, sizeof(CAMERA));
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
40 set_camera(&def_camera);
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
41 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
42
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
43
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
44 /**
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
45 * pose: カメラの対象物(obj)の座標行列
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
46 * カメラがobjについていくように(そのような動きに見せるため)
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
47 * カメラの位置ベクトル、視点ベクトルを更新
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
48 */
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
49 void
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
50 camera_update(FMATRIX pose)
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
51 {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
52
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
53 FVECTOR location, eyes, vertical, angle;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
54 // int type = game.camera_type;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
55
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
56 ps2_vu0_apply_matrix(location, pose, def_camera.xyz);
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
57 ps2_vu0_apply_matrix(eyes, pose, def_camera.zd);
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
58 ps2_vu0_apply_matrix(vertical, pose, def_camera.yd);
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
59
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
60 /**When the car bends, the angle of the camera is changed**/
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
61 if(pad.left>0 && game.jiki->speed !=0){
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
62 if(def_camera.angle[1]<=0.2){
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
63 def_camera.angle[1]+=0.02;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
64 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
65 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
66 else if(pad.right>0 && game.jiki->speed !=0){
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
67 if(def_camera.angle[1]>=-0.2){
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
68 def_camera.angle[1]-=0.02;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
69 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
70 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
71 else {
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
72 if(def_camera.angle[1]<-0.01){
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
73 def_camera.angle[1]+=0.02;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
74 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
75 else if(def_camera.angle[1]>0.01){
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
76 def_camera.angle[1]-=0.02;
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
77 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
78 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
79 ps2_vu0_apply_matrix(angle, pose, def_camera.angle);
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
80 ps2_vu0_copy_vector(camera.xyz, location);
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
81 ps2_vu0_copy_vector(camera.zd, eyes);
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
82 ps2_vu0_copy_vector(camera.yd, vertical);
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
83 ps2_vu0_copy_vector(camera.angle, angle);
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
84 set_camera(&camera);
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
85
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
86 }
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
87
0fae5658fb0b Initial revision
gongo
parents:
diff changeset
88