![]() |
|
|||
File indexing completed on 2025-02-21 09:30:07
0001 /* 0002 --------------------------------------------------------------------------- 0003 Open Asset Import Library (assimp) 0004 --------------------------------------------------------------------------- 0005 0006 Copyright (c) 2006-2024, assimp team 0007 0008 All rights reserved. 0009 0010 Redistribution and use of this software in source and binary forms, 0011 with or without modification, are permitted provided that the following 0012 conditions are met: 0013 0014 * Redistributions of source code must retain the above 0015 copyright notice, this list of conditions and the 0016 following disclaimer. 0017 0018 * Redistributions in binary form must reproduce the above 0019 copyright notice, this list of conditions and the 0020 following disclaimer in the documentation and/or other 0021 materials provided with the distribution. 0022 0023 * Neither the name of the assimp team, nor the names of its 0024 contributors may be used to endorse or promote products 0025 derived from this software without specific prior 0026 written permission of the assimp team. 0027 0028 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 0029 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 0030 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 0031 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 0032 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 0033 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 0034 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 0035 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 0036 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0037 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 0038 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0039 --------------------------------------------------------------------------- 0040 */ 0041 0042 /** @file camera.h 0043 * @brief Defines the aiCamera data structure 0044 */ 0045 0046 #pragma once 0047 #ifndef AI_CAMERA_H_INC 0048 #define AI_CAMERA_H_INC 0049 0050 #ifdef __GNUC__ 0051 #pragma GCC system_header 0052 #endif 0053 0054 #include "types.h" 0055 0056 #ifdef __cplusplus 0057 extern "C" { 0058 #endif 0059 0060 // --------------------------------------------------------------------------- 0061 /** Helper structure to describe a virtual camera. 0062 * 0063 * Cameras have a representation in the node graph and can be animated. 0064 * An important aspect is that the camera itself is also part of the 0065 * scene-graph. This means, any values such as the look-at vector are not 0066 * *absolute*, they're <b>relative</b> to the coordinate system defined 0067 * by the node which corresponds to the camera. This allows for camera 0068 * animations. For static cameras parameters like the 'look-at' or 'up' vectors 0069 * are usually specified directly in aiCamera, but beware, they could also 0070 * be encoded in the node transformation. The following (pseudo)code sample 0071 * shows how to do it: <br><br> 0072 * @code 0073 * // Get the camera matrix for a camera at a specific time 0074 * // if the node hierarchy for the camera does not contain 0075 * // at least one animated node this is a static computation 0076 * get-camera-matrix (node sceneRoot, camera cam) : matrix 0077 * { 0078 * node cnd = find-node-for-camera(cam) 0079 * matrix cmt = identity() 0080 * 0081 * // as usual - get the absolute camera transformation for this frame 0082 * for each node nd in hierarchy from sceneRoot to cnd 0083 * matrix cur 0084 * if (is-animated(nd)) 0085 * cur = eval-animation(nd) 0086 * else cur = nd->mTransformation; 0087 * cmt = mult-matrices( cmt, cur ) 0088 * end for 0089 * 0090 * // now multiply with the camera's own local transform 0091 * cam = mult-matrices (cam, get-camera-matrix(cmt) ) 0092 * } 0093 * @endcode 0094 * 0095 * @note some file formats (such as 3DS, ASE) export a "target point" - 0096 * the point the camera is looking at (it can even be animated). Assimp 0097 * writes the target point as a subnode of the camera's main node, 0098 * called "<camName>.Target". However this is just additional information 0099 * then the transformation tracks of the camera main node make the 0100 * camera already look in the right direction. 0101 * 0102 */ 0103 struct aiCamera { 0104 /** The name of the camera. 0105 * 0106 * There must be a node in the scenegraph with the same name. 0107 * This node specifies the position of the camera in the scene 0108 * hierarchy and can be animated. 0109 */ 0110 C_STRUCT aiString mName; 0111 0112 /** Position of the camera relative to the coordinate space 0113 * defined by the corresponding node. 0114 * 0115 * The default value is 0|0|0. 0116 */ 0117 C_STRUCT aiVector3D mPosition; 0118 0119 /** 'Up' - vector of the camera coordinate system relative to 0120 * the coordinate space defined by the corresponding node. 0121 * 0122 * The 'right' vector of the camera coordinate system is 0123 * the cross product of the up and lookAt vectors. 0124 * The default value is 0|1|0. The vector 0125 * may be normalized, but it needn't. 0126 */ 0127 C_STRUCT aiVector3D mUp; 0128 0129 /** 'LookAt' - vector of the camera coordinate system relative to 0130 * the coordinate space defined by the corresponding node. 0131 * 0132 * This is the viewing direction of the user. 0133 * The default value is 0|0|1. The vector 0134 * may be normalized, but it needn't. 0135 */ 0136 C_STRUCT aiVector3D mLookAt; 0137 0138 /** Horizontal field of view angle, in radians. 0139 * 0140 * The field of view angle is the angle between the center 0141 * line of the screen and the left or right border. 0142 * The default value is 1/4PI. 0143 */ 0144 float mHorizontalFOV; 0145 0146 /** Distance of the near clipping plane from the camera. 0147 * 0148 * The value may not be 0.f (for arithmetic reasons to prevent 0149 * a division through zero). The default value is 0.1f. 0150 */ 0151 float mClipPlaneNear; 0152 0153 /** Distance of the far clipping plane from the camera. 0154 * 0155 * The far clipping plane must, of course, be further away than the 0156 * near clipping plane. The default value is 1000.f. The ratio 0157 * between the near and the far plane should not be too 0158 * large (between 1000-10000 should be ok) to avoid floating-point 0159 * inaccuracies which could lead to z-fighting. 0160 */ 0161 float mClipPlaneFar; 0162 0163 /** Screen aspect ratio. 0164 * 0165 * This is the ration between the width and the height of the 0166 * screen. Typical values are 4/3, 1/2 or 1/1. This value is 0167 * 0 if the aspect ratio is not defined in the source file. 0168 * 0 is also the default value. 0169 */ 0170 float mAspect; 0171 0172 /** Half horizontal orthographic width, in scene units. 0173 * 0174 * The orthographic width specifies the half width of the 0175 * orthographic view box. If non-zero the camera is 0176 * orthographic and the mAspect should define to the 0177 * ratio between the orthographic width and height 0178 * and mHorizontalFOV should be set to 0. 0179 * The default value is 0 (not orthographic). 0180 */ 0181 float mOrthographicWidth; 0182 #ifdef __cplusplus 0183 0184 aiCamera() AI_NO_EXCEPT 0185 : mUp(0.f, 1.f, 0.f), 0186 mLookAt(0.f, 0.f, 1.f), 0187 mHorizontalFOV(0.25f * (float)AI_MATH_PI), 0188 mClipPlaneNear(0.1f), 0189 mClipPlaneFar(1000.f), 0190 mAspect(0.f), 0191 mOrthographicWidth(0.f) {} 0192 0193 /** @brief Get a *right-handed* camera matrix from me 0194 * @param out Camera matrix to be filled 0195 */ 0196 void GetCameraMatrix(aiMatrix4x4 &out) const { 0197 /** todo: test ... should work, but i'm not absolutely sure */ 0198 0199 /** We don't know whether these vectors are already normalized ...*/ 0200 aiVector3D zaxis = mLookAt; 0201 zaxis.Normalize(); 0202 aiVector3D yaxis = mUp; 0203 yaxis.Normalize(); 0204 aiVector3D xaxis = mUp ^ mLookAt; 0205 xaxis.Normalize(); 0206 0207 out.a4 = -(xaxis * mPosition); 0208 out.b4 = -(yaxis * mPosition); 0209 out.c4 = -(zaxis * mPosition); 0210 0211 out.a1 = xaxis.x; 0212 out.a2 = xaxis.y; 0213 out.a3 = xaxis.z; 0214 0215 out.b1 = yaxis.x; 0216 out.b2 = yaxis.y; 0217 out.b3 = yaxis.z; 0218 0219 out.c1 = zaxis.x; 0220 out.c2 = zaxis.y; 0221 out.c3 = zaxis.z; 0222 0223 out.d1 = out.d2 = out.d3 = 0.f; 0224 out.d4 = 1.f; 0225 } 0226 0227 #endif 0228 }; 0229 0230 #ifdef __cplusplus 0231 } 0232 #endif 0233 0234 #endif // AI_CAMERA_H_INC
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |