openTRI 0.1
triCamera.h
1/*
2 * triCamera.h: Header for Camera
3 * This file is part of the "tri Engine".
4 *
5 * Copyright (C) 2007 tri
6 * Copyright (C) 2007 Alexander Berl 'Raphael' <raphael@fx-world.org>
7 *
8 * $Id: $
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24
25#ifndef __TRICAMERA_H__
26#define __TRICAMERA_H__
27
28#include "triTypes.h"
29
30
34
35
36extern triVec4f triOrigin;
37
38typedef struct
39{
40 triVec4 pos; // the camera's position (triVec4 for vfpu accesses)
41 triVec4 dir; // the camera's looking direction
42 triVec4 up; // the camera's up vector
43 triVec4 right; // the camera's right vector
44
45 triQuat rot; // the camera's current rotation in triQuaternion form
46
47 triVec4 destPos; // the camera's destination position
48 triQuat destRot; // the camera's destination rotation
49 triFloat t; // the time to take the camera to destination
50
51 triS32 dirty; // camera changed, needs view matrix update
52} triCamera ALIGN16;
53
54
55
56
57// Create a default camera looking into positive z direction at position (x,y,z)
58triCamera* triCameraCreate( triFloat x, triFloat y, triFloat z );
59
60// Static camera movement control:
61// move camera position by (x,y,z)
62void triCameraMove( triCamera* cam, triFloat x, triFloat y, triFloat z );
63
64// rotate camera angle degrees around the axis (x,y,z) around itself
65void triCameraRotate( triCamera* cam, triFloat angle, triVec4f* axis );
66
67// rotate camera angle degrees around the axis (x,y,z) around the point center
68void triCameraRotateAbout( triCamera* cam, triFloat angle, triVec4f* axis, triVec4f* center );
69
70
71// Camera movement based on keyframe positions:
72// set camera destination point based on rotation (angle,x,y,z) and position (px,py,pz) and a time frame to reach the position
73void triCameraSetDestination( triCamera* cam, triFloat angle, triVec4f* axis, triFloat px, triFloat py, triFloat pz, triFloat t );
74
75// do an interpolation step towards the camera's destination
76void triCameraInterpolate( triCamera* cam, triFloat dt );
77
78// update the VIEW matrix to resemble the camera
79void triCameraUpdateMatrix( triCamera* cam );
80
81
82// project world space coordinates into normalized device space coordinates
83void triCameraProject( triVec4* vout, triCamera* cam, triVec4* vin );
84// unproject screen space coordinates into world space coordinates
85void triCameraUnproject( triVec4* vout, triCamera* cam, triVec4* vin );
87
88#endif // __TRICAMERA_H__
Definition triCamera.h:39
4D float Vector (quaternion)
Definition triTypes.h:228