Viewers.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /* Copyright (c) 2002-2012 Croteam Ltd.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of version 2 of the GNU General Public License as published by
  4. the Free Software Foundation
  5. This program is distributed in the hope that it will be useful,
  6. but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8. GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License along
  10. with this program; if not, write to the Free Software Foundation, Inc.,
  11. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
  12. #ifndef VIEWERS_H
  13. #define VIEWERS_H
  14. /*
  15. * Definition of viewer and target placement
  16. */
  17. class CMasterViewer {
  18. friend class CSlaveViewer;
  19. public:
  20. CPlacement3D mv_plViewer; // placement of the viewer
  21. FLOAT mv_fTargetDistance; // distance of virtual target from viewer
  22. // default constructor
  23. CMasterViewer(void);
  24. // get placement of the viewer
  25. inline CPlacement3D GetViewerPlacement(void) const {return mv_plViewer;};
  26. // get placement of the virtual target
  27. CPlacement3D GetTargetPlacement(void) const;
  28. // set placement of the virtual target
  29. void SetTargetPlacement(FLOAT3D f3dTarget);
  30. // convert from slave
  31. void operator = (const CSlaveViewer &svSlave);
  32. };
  33. /*
  34. * Definition of viewing projection viewer placement
  35. */
  36. class CSlaveViewer {
  37. friend class CMasterViewer;
  38. public:
  39. enum ProjectionType {
  40. PT_ILLEGAL = 0,
  41. PT_PERSPECTIVE,
  42. PT_ISOMETRIC_FRONT,
  43. PT_ISOMETRIC_RIGHT,
  44. PT_ISOMETRIC_TOP,
  45. PT_ISOMETRIC_BACK,
  46. PT_ISOMETRIC_LEFT,
  47. PT_ISOMETRIC_BOTTOM,
  48. };
  49. CDrawPort *sv_pdpDrawPort; // drawport that this viewer was created for
  50. CPlacement3D sv_plViewer; // placement of the viewer
  51. CPlacement3D sv_plGrid; // grid's placement
  52. FLOAT sv_fTargetDistance; // distance of virtual target from viewer
  53. enum ProjectionType sv_ProjectionType; // tyoe of projection
  54. // get orientation angles for type of isometric viewer
  55. ANGLE3D GetAngleForIsometricType(void) const;
  56. public:
  57. // default constructor
  58. CSlaveViewer( const CMasterViewer &mvMaster, enum ProjectionType ptProjectionType,
  59. const CPlacement3D &plGrid, CDrawPort *pdpDrawPort);
  60. // create a projection for this viewer
  61. void MakeProjection(CAnyProjection3D &prProjection);
  62. // create a perspective projection for this viewer
  63. void MakePerspectiveProjection(CPerspectiveProjection3D &prPerspectiveProjection);
  64. // get placement of the viewer
  65. inline CPlacement3D GetViewerPlacement(void) const {return sv_plViewer;};
  66. // test if this is perspective viewer
  67. inline BOOL IsPerspective(void) const { ASSERT( sv_ProjectionType != PT_ILLEGAL);
  68. return sv_ProjectionType == PT_PERSPECTIVE; };
  69. // test if this is isometric viewer
  70. inline BOOL IsIsometric(void) const { ASSERT( sv_ProjectionType != PT_ILLEGAL);
  71. return sv_ProjectionType != PT_PERSPECTIVE; };
  72. /* Get zoom factor for the viewer. */
  73. FLOAT GetZoomFactor(void);
  74. /* Get distance for requested zoom factor for the viewer. */
  75. FLOAT GetDistanceForZoom(FLOAT fZoom);
  76. // get target distance
  77. inline FLOAT GetTargetDistance( void) const { return sv_fTargetDistance; };
  78. // get placement of the virtual target
  79. CPlacement3D GetTargetPlacement(void) const;
  80. // translate slave viewer in his own system
  81. void Translate_OwnSystem( PIX pixDI, PIX pixDJ, PIX pixDK);
  82. void TranslatePlacement_OtherSystem(CPlacement3D &plToTranslate,CPlacement3D &plOtherSystem,
  83. PIX pixDI, PIX pixDJ, PIX pixDK);
  84. // scales target distance using given factor
  85. void ScaleTargetDistance( FLOAT fFactor);
  86. // rotate slave viewer in his own system using HPB method
  87. void Rotate_HPB( PIX pixDI, PIX pixDJ, PIX pixDK);
  88. // translate a placement in viewer's system
  89. void TranslatePlacement_OwnSystem(CPlacement3D &plToTranslate,
  90. PIX pixDI, PIX pixDJ, PIX pixDK);
  91. // rotate a placement in viewer's system
  92. void RotatePlacement_HPB(CPlacement3D &plToRotate,
  93. PIX pixDI, PIX pixDJ, PIX pixDK);
  94. // rotate a placement in viewer's system
  95. void RotatePlacement_TrackBall(CPlacement3D &plToRotate,
  96. PIX pixDI, PIX pixDJ, PIX pixDK);
  97. // convert offset from pixels to meters
  98. FLOAT PixelsToMeters(PIX pix);
  99. void Translate_Local_OwnSystem(FLOAT fdX, FLOAT fdY, FLOAT fdZ);
  100. void Rotate_Local_HPB( FLOAT fdX, FLOAT fdY, FLOAT fdZ);
  101. };
  102. #endif // VIEWERS_H