1 /* Copyright (C) 1992-1998 The Geometry Center 2 * Copyright (C) 1998-2000 Stuart Levy, Tamara Munzner, Mark Phillips 3 * 4 * This file is part of Geomview. 5 * 6 * Geomview is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU Lesser General Public License as published 8 * by the Free Software Foundation; either version 2, or (at your option) 9 * any later version. 10 * 11 * Geomview is distributed in the hope that it will be useful, but 12 * WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with Geomview; see the file COPYING. If not, write 18 * to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, 19 * USA, or visit http://www.gnu.org. 20 */ 21 22 23 /* Authors: Charlie Gunn, Stuart Levy, Tamara Munzner, Mark Phillips */ 24 25 #ifndef CAMERA_H 26 #define CAMERA_H 27 28 #include "3d.h" 29 #include "handle.h" 30 #include "color.h" 31 32 #include <stdarg.h> 33 34 typedef struct Camera Camera; 35 36 /* Public Camera methods (more below): */ 37 38 Camera *CamCreate( int attr1, ... ); 39 Camera *CamSet( Camera *, int attr1, ... ); 40 Camera * _CamSet(Camera *cam, int attr, va_list *a_list); 41 int CamGet( Camera *, int attr, void *value); 42 void CamDelete( Camera * ); 43 Camera *CamCopy( Camera *src, Camera *dst ); 44 Camera *CamMerge( Camera *src, Camera *dst ); 45 46 /* Camera attributes: */ 47 /* Set/Create type Get type */ 48 #define CAM_END 800 /* --------------- -------- */ 49 #define CAM_PERSPECTIVE 801 /* int int * */ 50 #define CAM_C2W 802 /* Transform Transform */ 51 #define CAM_W2C 803 /* Transform Transform */ 52 #define CAM_FOV 804 /* float float * */ 53 #define CAM_HALFYFIELD 805 /* float float * */ 54 #define CAM_HALFFIELD 806 /* float float * */ 55 #define CAM_ASPECT 807 /* float float * */ 56 #define CAM_FOCUS 808 /* float float * */ 57 #define CAM_NEAR 809 /* float float * */ 58 #define CAM_FAR 810 /* float float * */ 59 #define CAM_STEREO 811 /* int int * */ 60 #define CAM_STEREOSEP 812 /* float float * */ 61 #define CAM_STEREOANGLE 813 /* float float * */ 62 #define CAM_STEREOEYE 814 /* int int * */ 63 #define CAM_C2WHANDLE 815 /* Handle * Handle ** */ 64 #define CAM_W2CHANDLE 816 /* Handle * Handle ** */ 65 #define CAM_STEREYES 817 /* Transform [2] Transform [2] */ 66 #define CAM_STERHANDLES 818 /* Handle *[2] Handle *[2] */ 67 #define CAM_SPACE 819 /* int int * */ 68 #define CAM_BGCOLOR 820 /* ColorA * ColorA * */ 69 #define CAM_BGIMAGE 821 /* Image * Image ** */ 70 #define CAM_BGIMGHANDLE 822 /* Handle * Handle ** */ 71 72 #define CAM_ABLOCK 899 /* void **ablock */ 73 74 /* 75 CAM_END: end of attribute list 76 CAM_PERSPECTIVE: perspective (1) or ortho (0) projection (default:1) 77 CAM_C2W: camera-to-world transform: <world> * C2W = <cam> 78 CAM_W2C: world-to-camera transform (inverse of CAM_C2W) 79 CAM_C2WHANDLE: Handle onto CAM_C2W 80 CAM_W2CHANDLE: Handle onto CAM_W2C 81 CAM_FOV: field of view (in degrees) 82 CAM_HALFYFIELD: FOV half-width at z=1 (Y direction) 83 CAM_HALFFIELD: min FOV half-width 84 CAM_ASPECT: aspect ratio, X/Y 85 CAM_FOCUS: nominal focal distance for perspec<->ortho 86 CAM_NEAR: near clipping plane 87 CAM_FAR: far clipping plane 88 CAM_STEREO: stereo (1) or mono (0) (default:0) 89 CAM_STEREOSEP: separation distance between stereo eyes 90 CAM_STEREOANGLE: angle between stereo eyes (degrees) 91 CAM_STEREYES: array of two transforms resp. for left & right eye, 92 applied as <world> * C2W * STEREYE * projection 93 CAM_STERHANDLES: Handles for left and right eye transforms 94 CAM_STEREOEYE: Which stereo eye selected: CAM_LEFT or CAM_RIGHT 95 CAM_SPACE: TM_EUCLIDEAN, TM_HYPERBOLIC, or TM_SPHERICAL 96 */ 97 98 #define CAM_LEFT 0 99 #define CAM_RIGHT 1 100 101 /* 102 * Additional public Camera methods: 103 */ 104 105 /* Reset to defaults */ 106 void CamReset( Camera * ); 107 108 /* return Camera's projection xform; doesn't change camera at all */ 109 void CamViewProjection( Camera *, Transform ); 110 111 /* Complete cam world->proj xform; doesn't change camera at all */ 112 void CamView( Camera *, Transform ); 113 114 /* Apply T to camtoworld xform */ 115 void CamTransform( Camera *, Transform T ); 116 117 /* Rotate camera about X */ 118 void CamRotateX( Camera *, float angle ); 119 120 /* Rotate about Y (radians) */ 121 void CamRotateY( Camera *, float ); 122 123 /* Rotate about Z */ 124 void CamRotateZ( Camera *, float ); 125 126 /* Translate X,Y,Z */ 127 void CamTranslate( Camera *, float,float,float ); 128 129 /* Hyperbolic xlate */ 130 void CamHypTranslate( Camera *, float,float,float, float ); 131 132 /* Zoom in X,Y,Z */ 133 void CamScale( Camera *, float,float,float ); 134 135 /* ??? */ 136 void CamAlignZ( Camera *, float,float,float ); 137 138 /* Save to file */ 139 void CamSave(Camera *, char *); 140 void CamFSave(Camera *, FILE *, char *); 141 142 /* Load from file */ 143 Camera *CamLoad(Camera *, char *); 144 Camera *CamFLoad(Camera *, IOBFILE *, char *); 145 146 /************************************************************************ 147 * The following procedures are on death row; they will be taken out * 148 * soon because they have been superceded by CamGet and CamSet * 149 ************************************************************************/ 150 151 /* Get object xform */ 152 void CamCurrentPosition( Camera *, Transform ); 153 154 /* Camera's world->camera xform (inverse of CamCurrentPosition) */ 155 void CamViewWorld( Camera *, Transform ); 156 157 /* Set "focal" length */ 158 void CamFocus( Camera *, float focus ); 159 160 /* Get focal length */ 161 float CamCurrentFocus( Camera * ); 162 163 /* Set X/Y aspect */ 164 void CamFrameAspect( Camera *, float aspectratio ); 165 166 /* Get X/Y aspect */ 167 float CamCurrentAspect( Camera * ); 168 169 /* camtoworld xform = T */ 170 void CamTransformTo( Camera *, Transform T ); 171 172 /* Left/Right/Mono */ 173 void CamStereoEye( Camera *cam, int whicheye ); 174 175 /* Set clip planes */ 176 void CamClipping( Camera *, float near, float far ); 177 178 /* Get clipping */ 179 void CamCurrentClipping( Camera *, float *near, float *far ); 180 181 /* Set field: minfov/2 */ 182 void CamHalfField( Camera *, float halffield ); 183 184 /* Set field: Yfov/2 */ 185 void CamHalfYField( Camera *, float halfyfield ); 186 187 /* perspective/ortho */ 188 void CamPerspective( Camera *, int perspective ); 189 190 /* or orthographic */ 191 int CamIsPerspective( Camera * ); 192 193 /* Get fov/2 (max way) */ 194 float CamCurrentHalfField( Camera * ); 195 196 /* Get fov/2 (Y dir) */ 197 float CamCurrentHalfYField( Camera * ); 198 199 /* Get xfms, cur eye */ 200 int CamCurrentStereo( Camera *, Transform leye, Transform reye ); 201 202 void CamDefault(Camera *cam); 203 204 int CamStreamIn(Pool *p, Handle **hp, Camera **camp); 205 int CamStreamOut(Pool *p, Handle *hp, Camera *cam); 206 207 void CamHandleScan( Camera *cam, int (*func)(), void *arg ); 208 209 #endif /* !CAMERA_H */ 210