2
Copyright (c) 2008-2009 NetAllied Systems GmbH
4
This file is part of COLLADAStreamWriter.
6
Licensed under the MIT Open Source License,
7
for details please see LICENSE file or the website
8
http://www.opensource.org/licenses/mit-license.php
11
#ifndef __COLLADASTREAMWRITER_CAMERA_OPTIC_H__
12
#define __COLLADASTREAMWRITER_CAMERA_OPTIC_H__
14
#include "COLLADASWPrerequisites.h"
15
#include "COLLADASWStreamWriter.h"
16
#include "COLLADASWExtraTechnique.h"
17
#include "COLLADASWConstants.h"
22
/** A class that hold all information about an @a \<camera\> element.*/
23
class BaseOptic : public ElementWriter, public BaseExtraTechnique
28
// Camera should be able to call the add() method.
33
/** Flags, if the values was set. */
42
/** The aspect ratio of the field of view. If the <aspect_ratio>
43
element is not specified, it is calculated from the <xfov> or <yfov>
44
elements and the current viewport. The aspect ratio is defined as the
45
ratio of the field of view�s width over its height. */
47
String mAspectRatioSid;
49
/** The distance to the near clipping plane. */
53
/** The distance to the far clipping plane. */
57
/** The horizontal field of view in degrees - used for the perspective camera. */
61
/** The vertical field of view in degrees - used for the perspective camera. */
65
/** The horizontal (X) magnification of the view.
66
The X and Y magnifications are simple scale factors, applied to the
67
X and Y components of the orthographic viewport. As such, if your
68
default orthographic viewport is [[-1,1],[-1,1]] as in OpenGL and
69
DirectX, your COLLADASW orthographic viewport becomes
70
[[-xmag,xmag],[-ymag,ymag]]. This gives an orthographic width of
71
xmag/2 and an orthographic height of ymag/2.
72
- used for the orthographic camera.*/
76
/** The vertical (Y) magnification of the view.
77
The X and Y magnifications are simple scale factors, applied to the
78
X and Y components of the orthographic viewport. As such, if your
79
default orthographic viewport is [[-1,1],[-1,1]] as in OpenGL and
80
DirectX, your COLLADASW orthographic viewport becomes
81
[[-xmag,xmag],[-ymag,ymag]]. This gives an orthographic width of
82
xmag/2 and an orthographic height of ymag/2.
83
- used for the orthographic camera.*/
89
/** Adds the optics information. */
92
/** Adds the optic type specific information. */
93
virtual void addTypeSpecificInfos () const = 0;
99
* @param cameraId The id of the camera.
100
* @param cameraName The name of the camera.
102
BaseOptic ( StreamWriter* streamWriter );
105
virtual ~BaseOptic() {}
107
/** The distance to the far clipping plane. */
108
void setZFar ( float val, const String& sid="" ) { mZFar = val; mZFarSid = sid; mHasZFar = true; }
109
void setZFar( const float val, const bool useDefaultSid, const String& sid="" );
110
/** Returns the default sid used for the zfar element*/
111
static const String& getZFarDefaultSid() { return CSWC::CSW_ELEMENT_ZFAR; }
113
/** The distance to the near clipping plane. */
114
void setZNear ( float val, const String& sid="" ) { mZNear = val; mZNearSid = sid; mHasZNear = true; }
115
void setZNear( const float val, const bool useDefaultSid, const String& sid="" );
116
/** Returns the default sid used for the znear element*/
117
static const String& getZNearDefaultSid() { return CSWC::CSW_ELEMENT_ZNEAR; }
119
/** The aspect ratio of the field of view. If the <aspect_ratio>
120
element is not specified, it is calculated from the <xfov> or <yfov>
121
elements and the current viewport. The aspect ratio is defined as the
122
ratio of the field of view�s width over its height. */
123
void setAspectRatio ( float val, const bool useDefaultSid = false, const String& sid="" );
125
/** The horizontal field of view in degrees - used for the perspective camera. */
126
void setXFov ( float val, const String& sid="" ) { mXFov = val; mXFovSid = sid; mHasXFov = true; }
127
void setXFov( float val, const bool useDefaultSid, const String& sid="" );
128
/** Returns the default sid used for the xfovelement*/
129
static const String& getXFovDefaultSid() { return CSWC::CSW_ELEMENT_XFOV; }
131
/** The vertical field of view in degrees - used for the perspective camera. */
132
void setYFov ( float val, const String& sid="" ) { mYFov = val; mYFovSid = sid; mHasYFov = true; }
133
void setYFov( float val, const bool useDefaultSid, const String& sid="" );
134
/** Returns the default sid used for the yfov element*/
135
static const String& getYFovDefaultSid() { return CSWC::CSW_ELEMENT_YFOV; }
137
/** The horizontal (X) magnification of the view.
138
The X and Y magnifications are simple scale factors, applied to the
139
X and Y components of the orthographic viewport. As such, if your
140
default orthographic viewport is [[-1,1],[-1,1]] as in OpenGL and
141
DirectX, your COLLADASW orthographic viewport becomes
142
[[-xmag,xmag],[-ymag,ymag]]. This gives an orthographic width of
143
xmag/2 and an orthographic height of ymag/2.
144
- used for the orthographic camera.*/
145
void setXMag ( float val, const String& sid="" ) { mXMag = val; mXMagSid = sid; mHasXMag = true; }
146
void setXMag ( float val, bool useDefaultSid, const String& sid="" );
147
/** Returns the default sid used for the xmag element*/
148
static const String& getXMagDefaultSid() { return CSWC::CSW_ELEMENT_XMAG; }
150
/** The vertical (Y) magnification of the view.
151
The X and Y magnifications are simple scale factors, applied to the
152
X and Y components of the orthographic viewport. As such, if your
153
default orthographic viewport is [[-1,1],[-1,1]] as in OpenGL and
154
DirectX, your COLLADASW orthographic viewport becomes
155
[[-xmag,xmag],[-ymag,ymag]]. This gives an orthographic width of
156
xmag/2 and an orthographic height of ymag/2.
157
- used for the orthographic camera.*/
158
void setYMag ( float val, const String& sid="" ) { mYMag = val; mYMagSid = sid; mHasYMag = true; }
159
void setYMag ( float val, bool useDefaultSid, const String& sid="" );
160
/** Returns the default sid used for the ymag element*/
161
static const String& getYMagDefaultSid() { return CSWC::CSW_ELEMENT_YMAG; }
166
/** Camera class for perspective camera.
167
The projection type. The COMMON profile defines the optics types
168
<perspective> and <orthographic>. All other <optics> types must be
169
specified within a profile-specific <technique>.
170
Perspective embodies the appearance of objects relative to each other
171
as determined by their distance from a viewer. Computer graphics
172
techniques apply a perspective projection in order to render 3-D
173
objects onto 2-D surfaces to create properly proportioned images on
175
class PerspectiveOptic : public BaseOptic
181
* @param cameraId The id of the camera.
182
* @param cameraName The name of the camera.
184
PerspectiveOptic ( StreamWriter* streamWriter )
185
: BaseOptic ( streamWriter )
188
virtual ~PerspectiveOptic() {}
192
/** Adds the camera type specific information. */
193
void addTypeSpecificInfos () const;
197
/** Camera class for orthographic camera.
198
The COMMON profile defines the optics types
199
<perspective> and <orthographic>. All other <optics> types must be
200
specified within a profile-specific <technique>.
201
Orthographic projection describes a way of drawing a 3-D scene on a
202
2-D surface. In an orthographic projection, the apparent size of an
203
object does not depend on its distance from the camera. */
204
class OrthographicOptic : public BaseOptic
211
OrthographicOptic ( StreamWriter* streamWriter )
212
: BaseOptic ( streamWriter ) {}
214
virtual ~OrthographicOptic() {}
218
/** Adds the optic type specific information. */
219
void addTypeSpecificInfos () const;
224
} //namespace COLLADASW
226
#endif //__COLLADASTREAMWRITER_CAMERA_OPTIC_H__