home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / QuickTime VR / Windows / Interfaces / QD3DCamera.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-03  |  10.5 KB  |  350 lines  |  [TEXT/MPS ]

  1. /******************************************************************************
  2.  **                                                                             **
  3.  **     Module:        QD3DCamera.h                                             **
  4.  **                                                                          **
  5.  **                                                                          **
  6.  **                                                                          **
  7.  **     Purpose:     Generic camera routines                                      **
  8.  **                                                                          **
  9.  **                                                                          **
  10.  **     Copyright (C) 1991-1995 Apple Computer, Inc. All rights reserved.     **    
  11.  **                                                                          **
  12.  *****************************************************************************/
  13. #ifndef QD3DCamera_h
  14. #define QD3DCamera_h
  15.  
  16. #if PRAGMA_ONCE
  17.     #pragma once
  18. #endif
  19.  
  20. #if defined(THINK_C) || defined(__SC__)
  21.     #pragma options(!pack_enums, !align_arrays)
  22.     #pragma SC options align=power
  23. #elif defined(__MWERKS__)
  24.     #pragma enumsalwaysint on
  25.     #pragma align_array_members off
  26.     #pragma options align=native
  27. #elif defined(__PPCC__)
  28.     #pragma options align=power
  29. #elif defined(__xlc) || defined(__xlC) || defined(__xlC__) || defined(__XLC121__)
  30.     #pragma options enum=int
  31. #endif
  32.  
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif    /* __cplusplus */
  36.  
  37.  
  38. /******************************************************************************
  39.  **                                                                             **
  40.  **                            Data Structure Definitions                         **
  41.  **                                                                             **
  42.  *****************************************************************************/
  43. /*
  44.  *  The placement of the camera.
  45.  */
  46. typedef struct TQ3CameraPlacement{
  47.     TQ3Point3D        cameraLocation;        /*  Location point of the camera     */
  48.     TQ3Point3D        pointOfInterest;    /*  Point of interest                 */
  49.     TQ3Vector3D        upVector;            /*  "up" vector                     */
  50. } TQ3CameraPlacement;
  51.  
  52.  
  53. /*
  54.  *  The range of the camera.
  55.  */
  56. typedef struct TQ3CameraRange {
  57.     float    hither;        /*  Hither plane, measured from "from" towards "to"    */
  58.     float    yon;        /*  Yon  plane, measured from "from" towards "to"     */
  59. } TQ3CameraRange;
  60.  
  61.  
  62. /*
  63.  *  Viewport specification.  Origin is (-1, 1), and corresponds to the 
  64.  *  upper left-hand corner; width and height maximum is (2.0, 2.0),
  65.  *  corresponding to the lower left-hand corner of the window.  The
  66.  *  TQ3Viewport specifies a part of the viewPlane that gets displayed 
  67.  *    on the window that is to be drawn.
  68.  *  Normally, it is set with an origin of (-1.0, 1.0), and a width and
  69.  *  height of both 2.0, specifying that the entire window is to be
  70.  *  drawn.  If, for example, an exposure event of the window exposed
  71.  *  the right half of the window, you would set the origin to (0, 1),
  72.  *  and the width and height to (1.0) and (2.0), respectively.
  73.  *
  74.  */
  75. typedef struct TQ3CameraViewPort {
  76.     TQ3Point2D        origin;
  77.     float            width;
  78.     float            height;
  79. } TQ3CameraViewPort;
  80.  
  81.  
  82. typedef struct TQ3CameraData {
  83.     TQ3CameraPlacement    placement;
  84.     TQ3CameraRange        range;
  85.     TQ3CameraViewPort    viewPort;
  86. } TQ3CameraData;
  87.  
  88.  
  89. /*
  90.  *  An orthographic camera.
  91.  *
  92.  *  The lens characteristics are set with the dimensions of a
  93.  *  rectangular viewPort in the frame of the camera.
  94.  */
  95. typedef struct TQ3OrthographicCameraData {
  96.     TQ3CameraData        cameraData;
  97.     float                left;
  98.     float                top;
  99.     float                right;
  100.     float                bottom;
  101. } TQ3OrthographicCameraData;
  102.  
  103. /*
  104.  *  A perspective camera specified in terms of an arbitrary view plane.
  105.  *
  106.  *  This is most useful when setting the camera to look at a particular
  107.  *  object.  The viewPlane is set to distance from the camera to the object.
  108.  *  The halfWidth is set to half the width of the cross section of the object,
  109.  *  and the halfHeight equal to the halfWidth divided by the aspect ratio
  110.  *  of the viewPort.
  111.  * 
  112.  *  This is the only perspective camera with specifications for off-axis
  113.  *  viewing, which is desirable for scrolling.
  114.  */
  115. typedef struct TQ3ViewPlaneCameraData {
  116.     TQ3CameraData        cameraData;
  117.     float                viewPlane;
  118.     float                halfWidthAtViewPlane;
  119.     float                halfHeightAtViewPlane;
  120.     float                centerXOnViewPlane;
  121.     float                centerYOnViewPlane;
  122. } TQ3ViewPlaneCameraData;
  123.  
  124. /*
  125.  *    A view angle aspect camera is a perspective camera specified in 
  126.  *    terms of the minimum view angle and the aspect ratio of X to Y.
  127.  *
  128.  */
  129. typedef struct TQ3ViewAngleAspectCameraData {
  130.     TQ3CameraData        cameraData;
  131.     float                fov;
  132.     float                aspectRatioXToY;
  133. } TQ3ViewAngleAspectCameraData;
  134.  
  135.  
  136. /******************************************************************************
  137.  **                                                                             **
  138.  **                            Generic Camera routines                             **
  139.  **                                                                             **
  140.  *****************************************************************************/
  141.  
  142.  
  143. QD3D_EXPORT TQ3ObjectType Q3Camera_GetType(
  144.     TQ3CameraObject                camera);
  145.  
  146. QD3D_EXPORT TQ3Status Q3Camera_SetData(
  147.     TQ3CameraObject                camera,
  148.     const TQ3CameraData            *cameraData);
  149.  
  150. QD3D_EXPORT TQ3Status Q3Camera_GetData(
  151.     TQ3CameraObject                camera,
  152.     TQ3CameraData                *cameraData);
  153.     
  154. QD3D_EXPORT TQ3Status Q3Camera_SetPlacement(
  155.     TQ3CameraObject                camera,
  156.     const TQ3CameraPlacement    *placement);
  157.     
  158. QD3D_EXPORT TQ3Status Q3Camera_GetPlacement(
  159.     TQ3CameraObject                camera,
  160.     TQ3CameraPlacement            *placement);
  161.     
  162. QD3D_EXPORT TQ3Status Q3Camera_SetRange(
  163.     TQ3CameraObject                camera,
  164.     const TQ3CameraRange        *range);
  165.  
  166. QD3D_EXPORT TQ3Status Q3Camera_GetRange(
  167.     TQ3CameraObject                camera,
  168.     TQ3CameraRange                *range);
  169.  
  170. QD3D_EXPORT TQ3Status Q3Camera_SetViewPort(
  171.     TQ3CameraObject                camera,
  172.     const TQ3CameraViewPort        *viewPort);
  173.  
  174. QD3D_EXPORT TQ3Status Q3Camera_GetViewPort(
  175.     TQ3CameraObject                camera,
  176.     TQ3CameraViewPort            *viewPort);
  177.  
  178. QD3D_EXPORT TQ3Status Q3Camera_GetWorldToView( 
  179.     TQ3CameraObject                camera,
  180.     TQ3Matrix4x4                *worldToView);
  181.  
  182. QD3D_EXPORT TQ3Status Q3Camera_GetWorldToFrustum( 
  183.     TQ3CameraObject                camera,
  184.     TQ3Matrix4x4                *worldToFrustum);
  185.  
  186. QD3D_EXPORT TQ3Status Q3Camera_GetViewToFrustum(
  187.     TQ3CameraObject                camera,
  188.     TQ3Matrix4x4                *viewToFrustum);
  189.  
  190.  
  191. /******************************************************************************
  192.  **                                                                             **
  193.  **                            Specific Camera Routines                          **
  194.  **                                                                             **
  195.  *****************************************************************************/
  196.  
  197. /******************************************************************************
  198.  **                                                                             **
  199.  **                            Orthographic Camera                                  **
  200.  **                                                                             **
  201.  *****************************************************************************/
  202.  
  203. QD3D_EXPORT TQ3CameraObject Q3OrthographicCamera_New(
  204.     const TQ3OrthographicCameraData    *orthographicData);
  205.  
  206. QD3D_EXPORT TQ3Status Q3OrthographicCamera_GetData(
  207.     TQ3CameraObject                    camera,
  208.     TQ3OrthographicCameraData        *cameraData);
  209.  
  210. QD3D_EXPORT TQ3Status Q3OrthographicCamera_SetData(
  211.     TQ3CameraObject                    camera,
  212.     const TQ3OrthographicCameraData    *cameraData);
  213.  
  214. QD3D_EXPORT TQ3Status Q3OrthographicCamera_SetLeft(
  215.     TQ3CameraObject                    camera,
  216.     float                            left);
  217.     
  218. QD3D_EXPORT TQ3Status Q3OrthographicCamera_GetLeft(
  219.     TQ3CameraObject                    camera,
  220.     float                            *left);
  221.  
  222. QD3D_EXPORT TQ3Status Q3OrthographicCamera_SetTop(
  223.     TQ3CameraObject                    camera,
  224.     float                            top);
  225.     
  226. QD3D_EXPORT TQ3Status Q3OrthographicCamera_GetTop(
  227.     TQ3CameraObject                    camera,
  228.     float                            *top);
  229.  
  230. QD3D_EXPORT TQ3Status Q3OrthographicCamera_SetRight(
  231.     TQ3CameraObject                    camera,
  232.     float                            right);
  233.     
  234. QD3D_EXPORT TQ3Status Q3OrthographicCamera_GetRight(
  235.     TQ3CameraObject                    camera,
  236.     float                            *right);
  237.  
  238. QD3D_EXPORT TQ3Status Q3OrthographicCamera_SetBottom(
  239.     TQ3CameraObject                    camera,
  240.     float                            bottom);
  241.     
  242. QD3D_EXPORT TQ3Status Q3OrthographicCamera_GetBottom(
  243.     TQ3CameraObject                    camera,
  244.     float                            *bottom);
  245.  
  246.  
  247. /******************************************************************************
  248.  **                                                                             **
  249.  **                            ViewPlane Camera                                  **
  250.  **                                                                             **
  251.  *****************************************************************************/
  252.  
  253. QD3D_EXPORT TQ3CameraObject Q3ViewPlaneCamera_New(
  254.     const TQ3ViewPlaneCameraData    *cameraData);
  255.     
  256. QD3D_EXPORT TQ3Status Q3ViewPlaneCamera_GetData(
  257.     TQ3CameraObject                    camera,
  258.     TQ3ViewPlaneCameraData            *cameraData);
  259.  
  260. QD3D_EXPORT TQ3Status Q3ViewPlaneCamera_SetData(
  261.     TQ3CameraObject                    camera,
  262.     const TQ3ViewPlaneCameraData    *cameraData);
  263.  
  264. QD3D_EXPORT TQ3Status Q3ViewPlaneCamera_SetViewPlane(
  265.     TQ3CameraObject                    camera,
  266.     float                            viewPlane);
  267.     
  268. QD3D_EXPORT TQ3Status Q3ViewPlaneCamera_GetViewPlane(
  269.     TQ3CameraObject                    camera,
  270.     float                            *viewPlane);
  271.  
  272. QD3D_EXPORT TQ3Status Q3ViewPlaneCamera_SetHalfWidth(
  273.     TQ3CameraObject                    camera,
  274.     float                            halfWidthAtViewPlane);
  275.  
  276. QD3D_EXPORT TQ3Status Q3ViewPlaneCamera_GetHalfWidth(
  277.     TQ3CameraObject                    camera,
  278.     float                            *halfWidthAtViewPlane);
  279.  
  280. QD3D_EXPORT TQ3Status Q3ViewPlaneCamera_SetHalfHeight(
  281.     TQ3CameraObject                    camera,
  282.     float                            halfHeightAtViewPlane);
  283.  
  284. QD3D_EXPORT TQ3Status Q3ViewPlaneCamera_GetHalfHeight(
  285.     TQ3CameraObject                    camera,
  286.     float                            *halfHeightAtViewPlane);
  287.     
  288. QD3D_EXPORT TQ3Status Q3ViewPlaneCamera_SetCenterX(
  289.     TQ3CameraObject                    camera,
  290.     float                            centerXOnViewPlane);
  291.     
  292. QD3D_EXPORT TQ3Status Q3ViewPlaneCamera_GetCenterX(
  293.     TQ3CameraObject                    camera,
  294.     float                            *centerXOnViewPlane);
  295.     
  296. QD3D_EXPORT TQ3Status Q3ViewPlaneCamera_SetCenterY(
  297.     TQ3CameraObject                    camera,
  298.     float                            centerYOnViewPlane);
  299.     
  300. QD3D_EXPORT TQ3Status Q3ViewPlaneCamera_GetCenterY(
  301.     TQ3CameraObject                    camera,
  302.     float                            *centerYOnViewPlane);
  303.  
  304.  
  305. /******************************************************************************
  306.  **                                                                             **
  307.  **                            View Angle Aspect Camera                          **
  308.  **                                                                             **
  309.  *****************************************************************************/
  310.  
  311. QD3D_EXPORT TQ3CameraObject Q3ViewAngleAspectCamera_New(
  312.     const TQ3ViewAngleAspectCameraData    *cameraData);
  313.  
  314. QD3D_EXPORT TQ3Status Q3ViewAngleAspectCamera_SetData(
  315.     TQ3CameraObject                        camera,
  316.     const TQ3ViewAngleAspectCameraData    *cameraData);
  317.     
  318. QD3D_EXPORT TQ3Status Q3ViewAngleAspectCamera_GetData(
  319.     TQ3CameraObject                        camera,
  320.     TQ3ViewAngleAspectCameraData        *cameraData);
  321.  
  322. QD3D_EXPORT TQ3Status Q3ViewAngleAspectCamera_SetFOV(
  323.     TQ3CameraObject                        camera,
  324.     float                                fov);
  325.  
  326. QD3D_EXPORT TQ3Status Q3ViewAngleAspectCamera_GetFOV(
  327.     TQ3CameraObject                        camera,
  328.     float                                *fov);
  329.  
  330. QD3D_EXPORT TQ3Status Q3ViewAngleAspectCamera_SetAspectRatio(
  331.     TQ3CameraObject                        camera,
  332.     float                                aspectRatioXToY);
  333.     
  334. QD3D_EXPORT TQ3Status Q3ViewAngleAspectCamera_GetAspectRatio(
  335.     TQ3CameraObject                        camera,
  336.     float                                *aspectRatioXToY);
  337.  
  338.  
  339. #ifdef __cplusplus
  340. }
  341. #endif    /* __cplusplus */
  342.  
  343. #if defined(__MWERKS__)
  344.     #pragma enumsalwaysint reset
  345. #elif defined(__xlc) || defined(__xlC) || defined(__xlC__) || defined(__XLC121__)
  346.     #pragma options enum=reset
  347. #endif
  348.  
  349. #endif  /*  QD3DCamera_h  */
  350.