home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / source / povsrc.sit / SOURCE / VIEWPNT.C < prev   
Encoding:
C/C++ Source or Header  |  1992-07-03  |  2.8 KB  |  97 lines

  1. /****************************************************************************
  2. *                viewpnt.c
  3. *
  4. *  This module implements methods for managing the viewpoint.
  5. *
  6. *  from Persistence of Vision Raytracer 
  7. *  Copyright 1992 Persistence of Vision Team
  8. *---------------------------------------------------------------------------
  9. *  Copying, distribution and legal info is in the file povlegal.doc which
  10. *  should be distributed with this file. If povlegal.doc is not available
  11. *  or for more info please contact:
  12. *
  13. *       Drew Wells [POV-Team Leader] 
  14. *       CIS: 73767,1244  Internet: 73767.1244@compuserve.com
  15. *       Phone: (213) 254-4041
  16. * This program is based on the popular DKB raytracer version 2.12.
  17. * DKBTrace was originally written by David K. Buck.
  18. * DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
  19. *
  20. *****************************************************************************/
  21.  
  22. #include "frame.h"
  23. #include "vector.h"
  24. #include "povproto.h"
  25.  
  26. METHODS Viewpoint_Methods =
  27. { NULL, NULL, NULL, NULL, Copy_Viewpoint,
  28.    Translate_Viewpoint, Rotate_Viewpoint,
  29.    Scale_Viewpoint, NULL};
  30.  
  31. void *Copy_Viewpoint (Object)
  32. OBJECT *Object;
  33. {
  34.    VIEWPOINT *Viewpoint = (VIEWPOINT *) Object;
  35.    VIEWPOINT *New_Viewpoint;
  36.  
  37.    New_Viewpoint = Get_Viewpoint();
  38.  
  39.    New_Viewpoint -> Location = Viewpoint -> Location;
  40.    New_Viewpoint -> Direction = Viewpoint -> Direction;
  41.    New_Viewpoint -> Right = Viewpoint -> Right;
  42.    New_Viewpoint -> Up = Viewpoint -> Up;
  43.    return (New_Viewpoint);
  44. }
  45.  
  46. void Translate_Viewpoint (Object, Vector)
  47. OBJECT *Object;
  48. VECTOR *Vector;
  49. {
  50.    VAdd (((VIEWPOINT *) Object) -> Location, 
  51.       ((VIEWPOINT *) Object) -> Location,
  52.       *Vector);
  53. }
  54.  
  55. void Rotate_Viewpoint (Object, Vector)
  56. OBJECT *Object;
  57. VECTOR *Vector;
  58. {
  59.    TRANSFORMATION Transformation;
  60.    VIEWPOINT *Viewpoint = (VIEWPOINT *) Object;
  61.  
  62.    Get_Rotation_Transformation(&Transformation, Vector);
  63.    MTransformVector (&(Viewpoint -> Location),
  64.       &(Viewpoint -> Location), &Transformation);
  65.  
  66.    MTransformVector (&(Viewpoint -> Direction),
  67.       &(Viewpoint -> Direction), &Transformation);
  68.  
  69.    MTransformVector (&(Viewpoint -> Up),
  70.       &(Viewpoint -> Up), &Transformation);
  71.  
  72.    MTransformVector (&(Viewpoint -> Right),
  73.       &(Viewpoint -> Right), &Transformation);
  74. }
  75.  
  76. void Scale_Viewpoint (Object, Vector)
  77. OBJECT *Object;
  78. VECTOR *Vector;
  79. {
  80.    TRANSFORMATION Transformation;
  81.    VIEWPOINT *Viewpoint = (VIEWPOINT *) Object;
  82.  
  83.    Get_Scaling_Transformation(&Transformation, Vector);
  84.    MTransformVector (&(Viewpoint -> Location),
  85.       &(Viewpoint -> Location), &Transformation);
  86.  
  87.    MTransformVector (&(Viewpoint -> Direction),
  88.       &(Viewpoint -> Direction), &Transformation);
  89.  
  90.    MTransformVector (&(Viewpoint -> Up),
  91.       &(Viewpoint -> Up), &Transformation);
  92.  
  93.    MTransformVector (&(Viewpoint -> Right),
  94.       &(Viewpoint -> Right), &Transformation);
  95. }
  96.