home *** CD-ROM | disk | FTP | other *** search
/ Learn 3D Graphics Programming on the PC / Learn_3D_Graphics_Programming_on_the_PC_Ferraro.iso / rwdos / pick.h < prev    next >
C/C++ Source or Header  |  1995-02-15  |  4KB  |  106 lines

  1. #if !defined(_PICK_H)
  2. #define _PICK_H
  3.  
  4. /**********************************************************************
  5.  *
  6.  * File :     pick.h
  7.  *
  8.  * Abstract : The interface to some enhanced picking functionality
  9.  *            which use ray casting to determine the exact position
  10.  *            of the projection of a viewport position onto an
  11.  *            arbitrary plane. These functions can be used to drag
  12.  *            objects directly under the mouse cursor.
  13.  *
  14.  *            This application had been written to be compatible with
  15.  *            both the fixed and floating-point versions of the
  16.  *            RenderWare library, i.e., it uses the macros CREAL,
  17.  *            INT2REAL, RAdd, RDiv, RSub etc. If your application is
  18.  *            intended for the floating-point version of the library
  19.  *            only these macros are not necessary.
  20.  *
  21.  *            Please note that this application is intended for
  22.  *            demonstration purposes only. No support will be
  23.  *            provided for this code and it comes with no warranty.
  24.  *
  25.  **********************************************************************
  26.  *
  27.  * This file is a product of Criterion Software Ltd.
  28.  *
  29.  * This file is provided as is with no warranties of any kind and is
  30.  * provided without any obligation on Criterion Software Ltd. or
  31.  * Canon Inc. to assist in its use or modification.
  32.  *
  33.  * Criterion Software Ltd. will not, under any
  34.  * circumstances, be liable for any lost revenue or other damages arising
  35.  * from the use of this file.
  36.  *
  37.  * Copyright (c) 1994, 1995 Criterion Software Ltd.
  38.  * All Rights Reserved.
  39.  *
  40.  * RenderWare is a trademark of Canon Inc.
  41.  *
  42.  **********************************************************************/
  43.  
  44. /**********************************************************************
  45.  *
  46.  * Header files.
  47.  *
  48.  **********************************************************************/
  49.  
  50. #include <rwlib.h>
  51. #include <rwdos.h>
  52.  
  53. /**********************************************************************
  54.  *
  55.  * Type definitions.
  56.  *
  57.  **********************************************************************/
  58.  
  59. /*
  60.  * This type represents a ray which we intersect with a plane to
  61.  * compute a position.
  62.  */
  63. typedef struct
  64. {
  65.     RwV3d p;        /* Origin of the ray.    */
  66.     RwV3d v;        /* Direction of the ray. */
  67. } RwRay;
  68.  
  69. /**********************************************************************
  70.  *
  71.  * Functions.
  72.  *
  73.  **********************************************************************/
  74.  
  75. /**********************************************************************/
  76.  
  77. /**********************************************************************/
  78.  
  79. /*
  80.  * Return t at the point of interestion of the given ray and plane.
  81.  * The plane is defined by a point on the plane (p) and a nornal to the
  82.  * plane (n). Returns TRUE if the ray and plane intersect and FALSE if
  83.  * the ray and plane are parallel.
  84.  */
  85. extern RwBool IntersectRayAndPlane(RwRay *ray, RwV3d *n, RwV3d *p, RwReal *t);
  86.  
  87. /*
  88.  * Given a camera and a viewport position spawn a ray into world space.
  89.  * NOTE: This function does not take into account camera offsets.
  90.  */
  91. extern RwRay *SpawnRay(RwCamera *camera, RwInt32 x, RwInt32 y, RwRay *ray);
  92.  
  93. /*
  94.  * Compute the position (in world coordinates) of the given clump under
  95.  * the given (x, y) position in the viewport of the given camera. The
  96.  * clump will keep a constant orientation and distance with respect to
  97.  * the camera, i.e., this function can be used to drag the clump around
  98.  * on the plane parallel to the camera on which the clump lies.
  99.  */
  100. extern RwV3d *GetClumpPositionUnderPointer(RwClump *clump, RwCamera *camera,
  101.                                            RwInt32 x, RwInt32 y, RwV3d *pos);
  102.  
  103. /**********************************************************************/
  104.  
  105. #endif /* !defined(_PICK_H) */
  106.