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