QD3DCamera.h
上传用户:xjjlds
上传日期:2015-12-05
资源大小:22823k
文件大小:15k
源码类别:

多媒体编程

开发平台:

Visual C++

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