/src/Assets_Assimp/port/dAssimp/assimp/camera.d

http://github.com/Akranar/daguerreo · D · 182 lines · 15 code · 12 blank · 155 comment · 0 complexity · 1edb0065cc98a37eab9f84c6e152b971 MD5 · raw file

  1. /*
  2. ---------------------------------------------------------------------------
  3. Open Asset Import Library (ASSIMP)
  4. ---------------------------------------------------------------------------
  5. Copyright (c) 2006-2009, ASSIMP Development Team
  6. All rights reserved.
  7. Redistribution and use of this software in source and binary forms,
  8. with or without modification, are permitted provided that the following
  9. conditions are met:
  10. * Redistributions of source code must retain the above
  11. copyright notice, this list of conditions and the
  12. following disclaimer.
  13. * Redistributions in binary form must reproduce the above
  14. copyright notice, this list of conditions and the
  15. following disclaimer in the documentation and/or other
  16. materials provided with the distribution.
  17. * Neither the name of the ASSIMP team, nor the names of its
  18. contributors may be used to endorse or promote products
  19. derived from this software without specific prior
  20. written permission of the ASSIMP Development Team.
  21. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  25. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  26. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  27. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  28. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. ---------------------------------------------------------------------------
  33. */
  34. /**
  35. * Contains the data structure which is used to store the imported information
  36. * about the virtual cameras in the scene.
  37. */
  38. module assimp.camera;
  39. import assimp.math;
  40. import assimp.types;
  41. extern ( C ) {
  42. /**
  43. * Helper structure to describe a virtual camera.
  44. *
  45. * Cameras have a representation in the node graph and can be animated.
  46. * An important aspect is that the camera itself is also part of the
  47. * scenegraph. This means, any values such as the look-at vector are not
  48. * absolute, they're <em>relative</em> to the coordinate system defined
  49. * by the node which corresponds to the camera. This allows for camera
  50. * animations. Static cameras parameters like the look-at or up vectors are
  51. * usually specified directly in the class members, but beware, they could
  52. * also be encoded in the node transformation. The following (pseudo)code
  53. * sample shows how to do it.
  54. *
  55. * Examples:
  56. * ---
  57. * // Get the camera matrix for a camera at a specific time
  58. * // if the node hierarchy for the camera does not contain
  59. * // at least one animated node this is a static computation
  60. * get-camera-matrix (node sceneRoot, camera cam) : matrix
  61. * {
  62. * node cnd = find-node-for-camera(cam)
  63. * matrix cmt = identity()
  64. *
  65. * // as usual - get the absolute camera transformation for this frame
  66. * for each node nd in hierarchy from sceneRoot to cnd
  67. * matrix cur
  68. * if (is-animated(nd))
  69. * cur = eval-animation(nd)
  70. * else cur = nd->mTransformation;
  71. * cmt = mult-matrices( cmt, cur )
  72. * end for
  73. *
  74. * // now multiply with the camera's own local transform
  75. * cam = mult-matrices (cam, get-camera-matrix(cmt) )
  76. * }
  77. * ---
  78. *
  79. * Note: Some file formats (such as 3DS, ASE) export a "target point" – the
  80. * point the camera is looking at (it can even be animated). Assimp
  81. * writes the target point as a subnode of the camera's main node, called
  82. * "<camName>.Target". However, this is just additional information; the
  83. * transformation applied to the main camera node already makes the
  84. * camera face the right direction.
  85. */
  86. struct aiCamera {
  87. /**
  88. * The name of the camera.
  89. *
  90. * There must be a node in the scenegraph with the same name. This node
  91. * specifies the position of the camera in the scene hierarchy and can
  92. * be animated.
  93. */
  94. aiString mName;
  95. /**
  96. * Position of the camera relative to the coordinate space defined by the
  97. * corresponding node.
  98. *
  99. * The default value is 0|0|0.
  100. */
  101. aiVector3D mPosition;
  102. /**
  103. * Up vector of the camera coordinate system relative to the
  104. * coordinate space defined by the corresponding node.
  105. *
  106. * The right vector of the camera coordinate system is the cross
  107. * product of the up and lookAt vectors.
  108. *
  109. * The default value is 0|1|0. The vector may be normalized, but it
  110. * needn't.
  111. */
  112. aiVector3D mUp;
  113. /**
  114. * Look-at vector of the camera coordinate system relative to the
  115. * coordinate space defined by the corresponding node.
  116. *
  117. * This is the viewing direction of the user.
  118. *
  119. * The default value is 0|0|1. The vector may be normalized, but it
  120. * needn't.
  121. */
  122. aiVector3D mLookAt;
  123. /**
  124. * Half horizontal field of view angle, in radians.
  125. *
  126. * The field of view angle is the angle between the center line of the
  127. * screen and the left or right border.
  128. *
  129. * The default value is PI/4.
  130. */
  131. float mHorizontalFOV;
  132. /**
  133. * Distance of the near clipping plane from the camera.
  134. *
  135. * The value may not be 0.f (for arithmetic reasons to prevent
  136. * a division through zero).
  137. *
  138. * The default value is 0.1f.
  139. */
  140. float mClipPlaneNear;
  141. /**
  142. * Distance of the far clipping plane from the camera.
  143. *
  144. * The far clipping plane must, of course, be further away than the
  145. * near clipping plane. The ratio between the near and the far plane
  146. * should not be too large (between 1000-10000 should be ok) to avoid
  147. * floating-point inaccuracies which could lead to z-fighting.
  148. *
  149. * The default value is 1000.f.
  150. */
  151. float mClipPlaneFar;
  152. /**
  153. * Screen aspect ratio.
  154. *
  155. * This is the ration between the width and the height of the
  156. * screen. Typical values are 4/3, 1/2 or 1/1. This value is
  157. * 0 if the aspect ratio is not defined in the source file.
  158. *
  159. * 0 is also the default value.
  160. */
  161. float mAspect;
  162. }
  163. }