home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / dirs / dkbtrace_397.lzh / DKBTrace / DKBSource.LZH / viewpnt.c < prev    next >
C/C++ Source or Header  |  1990-08-26  |  4KB  |  126 lines

  1. /*****************************************************************************
  2. *
  3. *                                     viewpnt.c
  4. *
  5. *   from DKBTrace (c) 1990  David Buck
  6. *
  7. *  This module implements methods for managing the viewpoint.
  8. *
  9. * This software is freely distributable. The source and/or object code may be
  10. * copied or uploaded to communications services so long as this notice remains
  11. * at the top of each file.  If any changes are made to the program, you must
  12. * clearly indicate in the documentation and in the programs startup message
  13. * who it was who made the changes. The documentation should also describe what
  14. * those changes were. This software may not be included in whole or in
  15. * part into any commercial package without the express written consent of the
  16. * author.  It may, however, be included in other public domain or freely
  17. * distributed software so long as the proper credit for the software is given.
  18. *
  19. * This software is provided as is without any guarantees or warranty. Although
  20. * the author has attempted to find and correct any bugs in the software, he
  21. * is not responsible for any damage caused by the use of the software.  The
  22. * author is under no obligation to provide service, corrections, or upgrades
  23. * to this package.
  24. *
  25. * Despite all the legal stuff above, if you do find bugs, I would like to hear
  26. * about them.  Also, if you have any comments or questions, you may contact me
  27. * at the following address:
  28. *
  29. *     David Buck
  30. *     22C Sonnet Cres.
  31. *     Nepean Ontario
  32. *     Canada, K2H 8W7
  33. *
  34. *  I can also be reached on the following bulleton boards:
  35. *
  36. *     ATX              (613) 526-4141
  37. *     OMX              (613) 731-3419
  38. *     Mystic           (613) 731-0088 or (613) 731-6698
  39. *
  40. *  Fidonet:   1:163/109.9
  41. *  Internet:  David_Buck@Carleton.CA
  42. *
  43. *  IBM Port by Aaron A. Collins. Aaron may be reached on the following BBS'es:
  44. *
  45. *     Lattice BBS                      (708) 916-1200
  46. *     The Information Exchange BBS     (708) 945-5575
  47. *     Stillwaters BBS                  (708) 403-2826
  48. *
  49. *****************************************************************************/
  50.  
  51. #include "frame.h"
  52. #include "vector.h"
  53. #include "dkbproto.h"
  54.  
  55. METHODS Viewpoint_Methods =
  56.    { NULL, NULL, NULL, NULL, Copy_Viewpoint,
  57.      Translate_Viewpoint, Rotate_Viewpoint,
  58.      Scale_Viewpoint, NULL};
  59.  
  60. void *Copy_Viewpoint (Object)
  61.    OBJECT *Object;
  62.    {
  63.    VIEWPOINT *Viewpoint = (VIEWPOINT *) Object;
  64.    VIEWPOINT *New_Viewpoint;
  65.  
  66.    New_Viewpoint = Get_Viewpoint();
  67.  
  68.    New_Viewpoint -> Location = Viewpoint -> Location;
  69.    New_Viewpoint -> Direction = Viewpoint -> Direction;
  70.    New_Viewpoint -> Right = Viewpoint -> Right;
  71.    New_Viewpoint -> Up = Viewpoint -> Up;
  72.    return (New_Viewpoint);
  73.    }
  74.  
  75. void Translate_Viewpoint (Object, Vector)
  76.    OBJECT *Object;
  77.    VECTOR *Vector;
  78.    {
  79.    VAdd (((VIEWPOINT *) Object) -> Location, 
  80.          ((VIEWPOINT *) Object) -> Location,
  81.          *Vector);
  82.    }
  83.  
  84. void Rotate_Viewpoint (Object, Vector)
  85.    OBJECT *Object;
  86.    VECTOR *Vector;
  87.    {
  88.    TRANSFORMATION Transformation;
  89.    VIEWPOINT *Viewpoint = (VIEWPOINT *) Object;
  90.  
  91.    Get_Rotation_Transformation(&Transformation, Vector);
  92.    MTransformVector (&(Viewpoint -> Location),
  93.                      &(Viewpoint -> Location), &Transformation);
  94.  
  95.    MTransformVector (&(Viewpoint -> Direction),
  96.                      &(Viewpoint -> Direction), &Transformation);
  97.  
  98.    MTransformVector (&(Viewpoint -> Up),
  99.                      &(Viewpoint -> Up), &Transformation);
  100.  
  101.    MTransformVector (&(Viewpoint -> Right),
  102.                      &(Viewpoint -> Right), &Transformation);
  103.    }
  104.  
  105. void Scale_Viewpoint (Object, Vector)
  106.    OBJECT *Object;
  107.    VECTOR *Vector;
  108.    {
  109.    TRANSFORMATION Transformation;
  110.    VIEWPOINT *Viewpoint = (VIEWPOINT *) Object;
  111.  
  112.    Get_Scaling_Transformation(&Transformation, Vector);
  113.    MTransformVector (&(Viewpoint -> Location),
  114.                      &(Viewpoint -> Location), &Transformation);
  115.  
  116.    MTransformVector (&(Viewpoint -> Direction),
  117.                      &(Viewpoint -> Direction), &Transformation);
  118.  
  119.    MTransformVector (&(Viewpoint -> Up),
  120.                      &(Viewpoint -> Up), &Transformation);
  121.  
  122.    MTransformVector (&(Viewpoint -> Right),
  123.                      &(Viewpoint -> Right), &Transformation);
  124.    }
  125.  
  126.