Mercurial > hg > old > magoroku_racing
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/compile Thu Jun 02 14:56:11 2011 +0900 @@ -0,0 +1,103 @@ +#include <stdlib.h> +#include <string.h> +#include "libps2.h" +#include "ps2util.h" +#include "car.h" +#include "game.h" +#include "controler.h" +#include "camera.h" + +//大域変数、各部で共有 +extern SGO_PAD pad; + +static CAMERA camera, def_camera; + + +void +camera_init() +{ + + //カメラの初期位置設定 + def_camera.xyz[0] = 0; + def_camera.xyz[1] =-7;// -3; + def_camera.xyz[2] =-14; //0; + def_camera.xyz[3] = 1; + + def_camera.zd[0] = 0; + def_camera.zd[1] = 2; + def_camera.zd[2] = 7; + def_camera.zd[3] = 1; + + def_camera.yd[0] = 0; + def_camera.yd[1] = 1; + def_camera.yd[2] = 0; + def_camera.yd[3] = 1; + + def_camera.angle[0]=-0.2;//0; //pich + def_camera.angle[1]=0; //yoh + def_camera.angle[2]=0; //roll + def_camera.angle[3]=0; + + //def_cameraをcameraにコピー + memcpy( &camera, &def_camera, sizeof(CAMERA)); + set_camera(&def_camera); + +} + +/* + ps2依存関係から拝借。 + 自分が消したのか、元々無いのかは覚えていないけど + 呼ばれているのでとりあえず(空っぽにしておく)。 +*/ +// set_camera must be called if camera's parameters were moved +void set_camera(CAMERA *camera) +{ + //vu0_rot_camera_matrix(world_view, camera->xyz, camera->zd, camera->yd,camera->angle); +} + + +/** + * pose: カメラの対象物(obj)の座標行列 + * カメラがobjについていくように(そのような動きに見せるため) + * カメラの位置ベクトル、視点ベクトルを更新 + */ +void +camera_update(Game *game, FMATRIX pose) +{ + FVECTOR location, eyes, vertical, angle; + + //int type = game->camera_type; + + ps2_vu0_apply_matrix(location, pose, def_camera.xyz); + ps2_vu0_apply_matrix(eyes, pose, def_camera.zd); + ps2_vu0_apply_matrix(vertical, pose, def_camera.yd); + + /**When the car bends, the angle of the camera is changed**/ + if(pad.left>0 && game->jiki->speed !=0){ + if(game->jiki->speed !=0){ + if(def_camera.angle[1]<=0.2){ + def_camera.angle[1]+=0.02; + } + } + else if(pad.right>0 && game->jiki->speed !=0){ + if(game->jiki->speed !=0){ + if(def_camera.angle[1]>=-0.2){ + def_camera.angle[1]-=0.02; + } + } + else { + if(def_camera.angle[1]<-0.01){ + def_camera.angle[1]+=0.02; + } + else if(def_camera.angle[1]>0.01){ + def_camera.angle[1]-=0.02; + } + } + ps2_vu0_apply_matrix(angle, pose, def_camera.angle); + ps2_vu0_copy_vector(camera.xyz, location); + ps2_vu0_copy_vector(camera.zd, eyes); + ps2_vu0_copy_vector(camera.yd, vertical); + ps2_vu0_copy_vector(camera.angle, angle); + set_camera(&camera); + + }