Mercurial > hg > old > magoroku_racing.bad
view camera.c @ 19:8ab79a86aa73
*** empty log message ***
author | gongo |
---|---|
date | Sat, 04 Nov 2006 09:13:06 +0000 |
parents | 6910aeb52843 |
children | ce9ef7dcf2f0 |
line wrap: on
line source
/* * $Id$ */ #include <stdlib.h> #include "libps2.h" #include "ps2util.h" #include "car.h" #include "game.h" #include "controler.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; memcpy( &camera, &def_camera, sizeof(CAMERA)); set_camera(&def_camera); } /** * pose: カメラの対象物(obj)の座標行列 * カメラがobjについていくように(そのような動きに見せるため) * カメラの位置ベクトル、視点ベクトルを更新 */ void camera_update(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(def_camera.angle[1]<=0.2){ def_camera.angle[1]+=0.02; } } else if(pad.right>0 && 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); }