GraphicsAPI_2020C
camera.h
Go to the documentation of this file.
1 /*
2 ---------------------------------------------------------------------------
3 Open Asset Import Library (assimp)
4 ---------------------------------------------------------------------------
5 
6 Copyright (c) 2006-2017, assimp team
7 
8 
9 All rights reserved.
10 
11 Redistribution and use of this software in source and binary forms,
12 with or without modification, are permitted provided that the following
13 conditions are met:
14 
15 * Redistributions of source code must retain the above
16  copyright notice, this list of conditions and the
17  following disclaimer.
18 
19 * Redistributions in binary form must reproduce the above
20  copyright notice, this list of conditions and the
21  following disclaimer in the documentation and/or other
22  materials provided with the distribution.
23 
24 * Neither the name of the assimp team, nor the names of its
25  contributors may be used to endorse or promote products
26  derived from this software without specific prior
27  written permission of the assimp team.
28 
29 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 ---------------------------------------------------------------------------
41 */
42 
47 #pragma once
48 #ifndef AI_CAMERA_H_INC
49 #define AI_CAMERA_H_INC
50 
51 #include "types.h"
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
57 // ---------------------------------------------------------------------------
100 struct aiCamera
101 {
108  C_STRUCT aiString mName;
109 
116 
117 
126  C_STRUCT aiVector3D mUp;
127 
128 
136  C_STRUCT aiVector3D mLookAt;
137 
138 
146 
153 
163 
164 
172  float mAspect;
173 
174 #ifdef __cplusplus
175 
176  aiCamera()
177  : mUp (0.f,1.f,0.f)
178  , mLookAt (0.f,0.f,1.f)
179  , mHorizontalFOV (0.25f * (float)AI_MATH_PI)
180  , mClipPlaneNear (0.1f)
181  , mClipPlaneFar (1000.f)
182  , mAspect (0.f)
183  {}
184 
188  void GetCameraMatrix (aiMatrix4x4& out) const
189  {
193  aiVector3D zaxis = mLookAt; zaxis.Normalize();
194  aiVector3D yaxis = mUp; yaxis.Normalize();
195  aiVector3D xaxis = mUp^mLookAt; xaxis.Normalize();
196 
197  out.a4 = -(xaxis * mPosition);
198  out.b4 = -(yaxis * mPosition);
199  out.c4 = -(zaxis * mPosition);
200 
201  out.a1 = xaxis.x;
202  out.a2 = xaxis.y;
203  out.a3 = xaxis.z;
204 
205  out.b1 = yaxis.x;
206  out.b2 = yaxis.y;
207  out.b3 = yaxis.z;
208 
209  out.c1 = zaxis.x;
210  out.c2 = zaxis.y;
211  out.c3 = zaxis.z;
212 
213  out.d1 = out.d2 = out.d3 = 0.f;
214  out.d4 = 1.f;
215  }
216 
217 #endif
218 };
219 
220 
221 #ifdef __cplusplus
222 }
223 #endif
224 
225 #endif // AI_CAMERA_H_INC
Basic data types and primitives, such as vectors or colors.
Definition: matrix4x4.h:269
C_STRUCT aiVector3D mUp
'Up' - vector of the camera coordinate system relative to the coordinate space defined by the corresp...
Definition: camera.h:126
Helper structure to describe a virtual camera.
Definition: camera.h:100
C_STRUCT aiVector3D mPosition
Position of the camera relative to the coordinate space defined by the corresponding node...
Definition: camera.h:115
void GetCameraMatrix(aiMatrix4x4 &out) const
Get a right-handed camera matrix from me.
Definition: camera.h:188
Represents an UTF-8 string, zero byte terminated.
Definition: types.h:252
float mClipPlaneNear
Distance of the near clipping plane from the camera.
Definition: camera.h:152
Definition: vector3.h:135
float mClipPlaneFar
Distance of the far clipping plane from the camera.
Definition: camera.h:162
C_STRUCT aiString mName
The name of the camera.
Definition: camera.h:108
float mHorizontalFOV
Half horizontal field of view angle, in radians.
Definition: camera.h:145
C_STRUCT aiVector3D mLookAt
'LookAt' - vector of the camera coordinate system relative to the coordinate space defined by the cor...
Definition: camera.h:136
float mAspect
Screen aspect ratio.
Definition: camera.h:172