camera.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2016 RWS Inc, All Rights Reserved
  4. //
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of version 2 of the GNU General Public License as published by
  7. // the Free Software Foundation
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License along
  15. // with this program; if not, write to the Free Software Foundation, Inc.,
  16. // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. //
  18. // camera.h
  19. // Project: Nostril (aka Postal)
  20. //
  21. // History:
  22. // 01/09/96 MJR Started.
  23. //
  24. // 02/28/97 JMI Snap(...) now accepts a CHood*.
  25. //
  26. // 07/31/97 JMI Added m_bClip to allow us to disable clipping to realm
  27. // edges.
  28. //
  29. ////////////////////////////////////////////////////////////////////////////////
  30. #ifndef CAMERA_H
  31. #define CAMERA_H
  32. #include "RSPiX.h"
  33. #include "scene.h"
  34. #include "hood.h"
  35. // A CCamera object is used to take pictures of a CScene and place them onto
  36. // a film (actually, it's an RImage, but "film" fits the concept better).
  37. //
  38. // The area of the scene that is transferred to the film is referred to as the
  39. // camera's "view". The view is a rectangular area that is "mapped" onto two
  40. // different coordinate systems: that of the scene and that of the film. The
  41. // view itself represents a third "common" coordinate system.
  42. //
  43. // The variables m_sSceneViewX and m_sSceneViewY link the view to the scene
  44. // coordinate system, and m_sFilmViewX and m_sFilmViewY link it to the film
  45. // coordinate system. These variables can be used to easily convert between
  46. // the coordinate systems. In addition, the variables m_sScene2FilmX and
  47. // m_sScene2FilmY are available to convert directly between scene and film
  48. // coordinates. Note that any coordinate can be converted from or to any
  49. // system with with a single addition or subtraction:
  50. //
  51. // Most (if not all) member variables are "public" to allow for simple and
  52. // efficient access. If necessary, they can be modified directly, but if
  53. // this is done, Update() MUST BE CALLED IMMEDIATELY AFTERWARDS in order to
  54. // maintain the camera's internal consistancy.
  55. class CCamera
  56. {
  57. //---------------------------------------------------------------------------
  58. // Types, enums, etc.
  59. //---------------------------------------------------------------------------
  60. //---------------------------------------------------------------------------
  61. // Variables
  62. //---------------------------------------------------------------------------
  63. public:
  64. short m_sViewW; // View's width
  65. short m_sViewH; // View's height
  66. CScene* m_pScene; // Scene (the source)
  67. short m_sSceneViewX; // View's upper left x in the scene
  68. short m_sSceneViewY; // View's upper left y in the scene
  69. RImage* m_pimFilm; // Film (the destination)
  70. short m_sFilmViewX; // View's upper left x on the film
  71. short m_sFilmViewY; // View's upper left y on the film
  72. short m_sScene2FilmX; // Subtract from scene x to convert to film x
  73. short m_sScene2FilmY; // Subtract from scene y to convert to film y
  74. CHood* m_pHood; // Hood (used to limit camera movement)
  75. bool m_bClip; // Clip camera position to edge of realm, if true
  76. // (default); otherwise, no clipping.
  77. //---------------------------------------------------------------------------
  78. // Public functions
  79. //---------------------------------------------------------------------------
  80. public:
  81. // Default (and only) constructor
  82. CCamera();
  83. // Destructor
  84. ~CCamera();
  85. // Set camera's scene
  86. void SetScene(
  87. CScene* pScene); // In: Scene to take picture of
  88. // Set camera's hood
  89. void SetHood(
  90. CHood* pHood); // In: Hood to use for camera control
  91. // Set camera's view of the scene
  92. void SetView(
  93. short sSceneViewX, // In: View's upper left x (in scene coords)
  94. short sSceneViewY, // In: View's upper left y (in scene coords)
  95. short sViewW, // In: View's width
  96. short sViewH); // In: View's height
  97. // Set camera's view position (assumes the view's size will be or was set separately)
  98. void SetViewPos(
  99. short sSceneViewX, // In: View's upper left x (in scene coords)
  100. short sSceneViewY); // In: View's upper left y (in scene coords)
  101. // Set camera's view size (assumes the view's position will be or was set separately)
  102. void SetViewSize(
  103. short sViewW, // In: View's width
  104. short sViewH); // In: View's height
  105. // Set camera's film (the RImage in which to put pictures of the scene). The view
  106. // can be put anywhere on the film and is clipped as required to fit the film.
  107. void SetFilm(
  108. RImage* pimFilm, // In: Film (where the picture ends up)
  109. short sFilmViewX, // In: View's upper left x (in film coords)
  110. short sFilmViewY); // In: View's upper left y (in film coords)
  111. // Snap a picture with the lens cover on (i.e. - set film's view area to black)
  112. void SnapWithLensCoverOn(void);
  113. // Snap a picture using the preset parameters (scene, view, and film)
  114. void Snap(void);
  115. // Snap a picture using the specified parameters. These parameters are
  116. // temporary -- they do not affect any of the preset parameters!
  117. void Snap(
  118. short sViewW, // In: View's width
  119. short sViewH, // In: View's height
  120. CScene* pScene, // In: Scene to take picture of
  121. CHood* phood, // In: Hood for this scene.
  122. short sSceneViewX, // In: View's upper left x (in scene coords)
  123. short sSceneViewY, // In: View's upper left y (in scene coords)
  124. RImage* pimFilm, // In: Film (where the picture ends up)
  125. short sFilmViewX, // In: View's upper left x (in film coords)
  126. short sFilmViewY); // In: View's upper left y (in film coords)
  127. // Update internal state after setting new values
  128. void Update(void);
  129. };
  130. #endif //CAMERA_H
  131. ////////////////////////////////////////////////////////////////////////////////
  132. // EOF
  133. ////////////////////////////////////////////////////////////////////////////////