00001
00002 #ifndef CAMERA_H
00003 #define CAMERA_H
00004
00005 #ifdef _PC
00006 #include "car.h"
00007 #include "object.h"
00008 #endif
00009 #ifdef _N64
00010 #include "geom.h"
00011 #include "model.h"
00012 #include "particle.h"
00013 #include "aerial.h"
00014 #include "NewColl.h"
00015 #include "Body.h"
00016 #include "car.h"
00017 #include "visibox.h"
00018 #include "ctrlread.h"
00019 #include "object.h"
00020 #include "Control.h"
00021 #include "level.h"
00022 #include "player.h"
00023 #endif
00024
00025
00026
00027 #define MAX_CAMERAS 8
00028
00029 #ifdef _PC
00030 #define CAMERA_LEFT (Keys[DIK_A])
00031 #define CAMERA_RIGHT (Keys[DIK_D])
00032 #define CAMERA_UP (Keys[DIK_W])
00033 #define CAMERA_DOWN (Keys[DIK_S])
00034 #define CAMERA_BACKWARDS (Keys[DIK_Q])
00035 #define CAMERA_FORWARDS (Keys[DIK_E])
00036
00037 #define LENS_DIST_MOD 0.25f
00038 #define MIN_LENS (-HALF * BaseGeomPers)
00039 #endif
00040
00041 #ifdef _N64
00042 #define CAMERA_LEFT (Buttons & BUT_C_LEFT)
00043 #define CAMERA_RIGHT (Buttons & BUT_C_RIGHT)
00044 #define CAMERA_UP (Buttons & BUT_C_UP)
00045 #define CAMERA_DOWN (Buttons & BUT_C_DOWN)
00046 #define CAMERA_BACKWARDS (Buttons & BUT_DOWN)
00047 #define CAMERA_FORWARDS (Buttons & BUT_UP)
00048
00049 #define LENS_DIST_MOD 0.025f
00050 #define MIN_LENS (-HALF * BaseGeomPers)
00051 #endif
00052
00053
00054 enum {
00055 CAM_FOLLOW,
00056 CAM_ATTACHED,
00057 CAM_RAIL,
00058 CAM_FREEDOM,
00059 CAM_NEWFOLLOW,
00060 CAM_EDIT,
00061
00062 CAM_NTYPES
00063 };
00064 typedef long CAMTYPE;
00065
00066 enum {
00067 CAMERA_FLAG_FREE,
00068 CAMERA_FLAG_PRIMARY,
00069 CAMERA_FLAG_SECONDARY,
00070 };
00071
00072 typedef struct CameraStruct {
00073
00074
00075 long Type;
00076 long SubType;
00077
00078
00079 void (*CalcCamPos)(struct CameraStruct *camera);
00080 void (*CalcCamLook)(struct CameraStruct *camera);
00081
00082
00083 MAT WMatrix;
00084 QUATERNION Quat;
00085
00086
00087 VEC WPos;
00088 VEC OldWPos;
00089 VEC Vel;
00090
00091
00092 VEC DestOffset;
00093 VEC PosOffset;
00094 VEC WorldPosOffset;
00095
00096
00097 VEC LookOffset;
00098 VEC OldLookOffset;
00099
00100
00101 OBJECT *Object;
00102
00103
00104 REAL Lens;
00105 REAL NearClip;
00106 REAL ZoomMod;
00107
00108
00109 bool Collide;
00110 bool Zoom;
00111 bool Change;
00112
00113 REAL Timer;
00114 REAL Shake;
00115
00116
00117 NEWCOLLPOLY CollPoly;
00118
00119 VEC CollPos;
00120 VEC OldCollPos;
00121
00122 REAL X, Y, Xsize, Ysize;
00123 long Flag;
00124 #ifdef _N64
00125 PLAYER *Player;
00126 #endif
00127
00128 } CAMERA;
00129
00130
00132
00133
00134
00136
00138
00139
00140 enum CamNodeTypeEnum {
00141 CAMNODE_MONORAIL,
00142 CAMNODE_STATIC,
00143
00144 CAMNODE_NTYPES
00145 };
00146
00147 typedef struct CamNodeStruct {
00148 long Type;
00149 long ID;
00150 VEC Pos;
00151 REAL ZoomMod;
00152 long Link;
00153 VISIMASK VisiMask;
00154 } CAMNODE;
00155
00156 #define CAMERA_MAX_NODES (1024)
00157 #define MAX_CAMNODE_DIST (OGU2GU_LENGTH * 10000.0f)
00158
00159
00161
00162
00163
00164 typedef struct CamFollowDataStruct {
00165 bool Collide;
00166 VEC PosOffset;
00167 VEC LookOffset;
00168 } CAMFOLLOWDATA;
00169
00170 typedef struct CamAttachedDataStruct {
00171 VEC PosOffset;
00172 bool Forward;
00173 } CAMATTACHEDDATA;
00174
00175 enum {
00176 CAM_FOLLOW_BEHIND,
00177 CAM_FOLLOW_CLOSE,
00178 CAM_FOLLOW_LEFT,
00179 CAM_FOLLOW_RIGHT,
00180 CAM_FOLLOW_FRONT,
00181 CAM_FOLLOW_ROTATE,
00182
00183 CAM_FOLLOW_NTYPES
00184 };
00185
00186 enum {
00187 CAM_ATTACHED_INCAR,
00188 CAM_ATTACHED_LEFT,
00189 CAM_ATTACHED_RIGHT,
00190 CAM_ATTACHED_REARVIEW,
00191
00192 CAM_ATTACHED_NTYPES
00193 };
00194
00195 enum {
00196 CAM_RAIL_DYNAMIC_MONO,
00197 CAM_RAIL_STATIC_NEAREST,
00198
00199 CAM_RAIL_NTYPES
00200 };
00201
00202
00203
00204 extern void (*CameraFunction[])(void);
00205 extern void SetCameraView(MAT *cammat, VEC *campos, REAL shake);
00206 extern void SetViewport(REAL x, REAL y, REAL xsize, REAL ysize, REAL pers);
00207 extern CAMERA *AddCamera(REAL x, REAL y, REAL xsize, REAL ysize, long flag);
00208 extern void RemoveCamera(CAMERA *camera);
00209 extern void InitCameras(void);
00210 extern void SetProjMatrix(REAL n, REAL f, REAL fov);
00211
00212 extern CAMNODE *FindNearestCameraPath(VEC *pos, long *nodeNum, long *linkNum);
00213
00214 extern void UpdateCamera(CAMERA *camera);
00215
00216 extern void SetCameraFollow(CAMERA *camera, OBJECT *object, long type);
00217 extern void SetCameraAttached(CAMERA *camera, OBJECT *object, long type);
00218 extern void SetCameraFreedom(CAMERA *camera, OBJECT *object, long unUsed);
00219 extern void SetCameraRail(CAMERA *camera, OBJECT *object, long type);
00220 extern void SetCameraEdit(CAMERA *camera, OBJECT *object, long unUsed);
00221 extern void SetCameraNewFollow(CAMERA *camera, OBJECT *object, long type);
00222 extern void InitCamPos(CAMERA *camera);
00223
00224 extern void TriggerCamera(struct PlayerStruct *player, long flag, long n, VEC *vec);
00225
00226 #ifdef _PC
00227 extern long LoadCameraNodes(FILE *fp);
00228 #endif
00229 #ifdef _N64
00230 extern long LoadCameraNodes(void);
00231 #endif
00232
00233
00234
00235
00236 extern char CameraCount;
00237 extern REAL CameraHomeHeight;
00238 extern MAT ViewMatrixScaled, ViewMatrix, ViewCameraMatrix, ViewMatrixScaledMirrorY;
00239 extern VEC ViewTransScaled, ViewTrans, ViewCameraPos;
00240 #ifdef _N64
00241 extern REAL ViewAngle;
00242 #endif
00243 extern VEC CameraHomePos;
00244 extern REAL MouseXpos, MouseYpos, MouseXrel, MouseYrel;
00245 extern REAL CameraEditXrel, CameraEditYrel, CameraEditZrel;
00246 extern char MouseLeft, MouseRight, MouseLastLeft, MouseLastRight;
00247 extern PLANE CameraPlaneLeft, CameraPlaneRight, CameraPlaneTop, CameraPlaneBottom;
00248 extern CAMERA Camera[];
00249 extern CAMERA *CAM_MainCamera;
00250 extern CAMNODE CAM_CameraNode[CAMERA_MAX_NODES];
00251 extern long CAM_NCameraNodes;
00252 extern long CAM_ValidRailCamNode;
00253 #ifdef _PC
00254 extern D3DRECT ViewportRect;
00255 #endif
00256
00257 #endif