2 * GPAC - Multimedia Framework C SDK
\r
4 * Copyright (c) Jean Le Feuvre 2000-2005
\r
5 * All rights reserved
\r
7 * This file is part of GPAC / Scene Compositor sub-project
\r
9 * GPAC is free software; you can redistribute it and/or modify
\r
10 * it under the terms of the GNU Lesser General Public License as published by
\r
11 * the Free Software Foundation; either version 2, or (at your option)
\r
12 * any later version.
\r
14 * GPAC is distributed in the hope that it will be useful,
\r
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
17 * GNU Lesser General Public License for more details.
\r
19 * You should have received a copy of the GNU Lesser General Public
\r
20 * License along with this library; see the file COPYING. If not, write to
\r
21 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
\r
28 //#include <gpac/internal/compositor_dev.h>
\r
29 #include <gpac/scenegraph_vrml.h>
\r
34 /*if set frustum needs to be recomputed
\r
35 we avoid computing it at each frame/interaction since that's a lot of matrix maths*/
\r
37 /*if set when ortho, indicates the viewport matrix shall be used when computing modelview (2D only)*/
\r
38 CAM_HAS_VIEWPORT = 1<<2,
\r
43 /*only valid at root node*/
\r
45 /*subtree completely outside view vol*/
\r
47 /*subtree completely inside view vol*/
\r
49 /*subtree overlaps view vol - FIXME: would be nice to keep track of intersecting planes*/
\r
53 /*navigation info flags - non-VRML ones are simply blaxxun contact ones */
\r
58 /*any navigation (eg, user-interface navigation control allowed)*/
\r
65 FRUS_NEAR_PLANE = 0,
\r
77 /*nothing detected*/
\r
79 /*collision detected*/
\r
81 /*gravity detecion enabled*/
\r
82 CF_DO_GRAVITY = (1<<1),
\r
83 /*gravity detected*/
\r
84 CF_GRAVITY = (1<<2),
\r
85 /*viewpoint is stored at end of animation*/
\r
86 CF_STORE_VP = (1<<3),
\r
89 typedef struct _camera
\r
91 /*this flag MUST be set by the owner of the camera*/
\r
98 /*not always same as VP due to aspect ratio*/
\r
99 Fixed width, height;
\r
100 Fixed z_near, z_far;
\r
102 /*current vectors*/
\r
104 SFVec3f up, position, target;
\r
106 /*initial vp for reset*/
\r
107 SFVec3f vp_position;
\r
108 SFRotation vp_orientation;
\r
109 Fixed vp_fov, vp_dist;
\r
112 SFVec3f start_pos, end_pos;
\r
113 SFRotation start_ori, end_ori;
\r
114 Fixed start_fov, end_fov;
\r
115 /*for 2D cameras we never animate except for vp reset*/
\r
117 SFVec2f start_trans, start_rot;
\r
119 /*center of examine movement*/
\r
120 SFVec3f examine_center;
\r
123 u32 anim_len, anim_start;
\r
127 /*navigation info - overwridden by any bindable NavigationInfo node*/
\r
128 u32 navigation_flags, navigate_mode;
\r
129 SFVec3f avatar_size;
\r
130 Fixed visibility, speed;
\r
131 Bool had_viewpoint, had_nav_info;
\r
133 /*last camera position before collision& gravity detection*/
\r
136 /*collision point in world coord*/
\r
137 SFVec3f collide_point;
\r
138 /*collide dist in world coord, used to check if we have a closer collision*/
\r
139 Fixed collide_dist;
\r
140 /*ground in world coord*/
\r
141 SFVec3f ground_point;
\r
142 /*ground dist in world coord, used to check if we have a closer ground*/
\r
144 /*for obstacle detection*/
\r
145 Bool last_had_ground;
\r
148 /*projection & modelview matrices*/
\r
149 GF_Matrix projection, modelview;
\r
150 /*unprojection matrix = INV(P*M) used for screen->world compute*/
\r
151 GF_Matrix unprojection;
\r
152 /*viewport matrix*/
\r
153 GF_Matrix viewport;
\r
155 GF_Plane planes[6];
\r
156 /*p vertex idx per plane (for bbox-frustum intersection checks)*/
\r
158 /*frustrum bounding sphere (for sphere-sphere frustum intersection checks)*/
\r
163 /*invalidate camera to force recompute of all params*/
\r
164 void camera_invalidate(GF_Camera *cam);
\r
165 /*updates camera. user transform is only used in 2D to set global user zoom/pan/translate*/
\r
166 void camera_update(GF_Camera *cam, GF_Matrix2D *user_transform, Bool center_coords);
\r
167 /*reset to last viewport*/
\r
168 void camera_reset_viewpoint(GF_Camera *cam, Bool animate);
\r
169 /*move camera to given vp*/
\r
170 void camera_move_to(GF_Camera *cam, SFVec3f pos, SFVec3f target, SFVec3f up);
\r
171 Bool camera_animate(GF_Camera *cam);
\r
172 void camera_stop_anim(GF_Camera *cam);
\r
173 /*start jump mode*/
\r
174 void camera_jump(GF_Camera *cam);
\r
176 void camera_set_vectors(GF_Camera *cam, SFVec3f pos, SFRotation ori, Fixed fov);
\r
178 SFRotation camera_get_orientation(SFVec3f pos, SFVec3f target, SFVec3f up);
\r
179 SFVec3f camera_get_pos_dir(GF_Camera *cam);
\r
180 SFVec3f camera_get_target_dir(GF_Camera *cam);
\r
181 SFVec3f camera_get_right_dir(GF_Camera *cam);
\r