~ubuntu-branches/ubuntu/wily/opencollada/wily

« back to all changes in this revision

Viewing changes to COLLADAStreamWriter/include/COLLADASWCameraOptic.h

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2015-05-14 17:23:27 UTC
  • Revision ID: package-import@ubuntu.com-20150514172327-f862u8envms01fra
Tags: upstream-0.1.0~20140703.ddf8f47+dfsg1
Import upstream version 0.1.0~20140703.ddf8f47+dfsg1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright (c) 2008-2009 NetAllied Systems GmbH
 
3
 
 
4
    This file is part of COLLADAStreamWriter.
 
5
 
 
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
 
9
*/
 
10
 
 
11
#ifndef __COLLADASTREAMWRITER_CAMERA_OPTIC_H__
 
12
#define __COLLADASTREAMWRITER_CAMERA_OPTIC_H__
 
13
 
 
14
#include "COLLADASWPrerequisites.h"
 
15
#include "COLLADASWStreamWriter.h"
 
16
#include "COLLADASWExtraTechnique.h"
 
17
#include "COLLADASWConstants.h"
 
18
 
 
19
namespace COLLADASW
 
20
{
 
21
 
 
22
    /** A class that hold all information about an @a \<camera\> element.*/
 
23
    class BaseOptic : public ElementWriter, public BaseExtraTechnique
 
24
    {
 
25
 
 
26
    private:
 
27
 
 
28
        // Camera should be able to call the add() method.
 
29
        friend class Camera;
 
30
 
 
31
    protected:
 
32
 
 
33
        /** Flags, if the values was set. */
 
34
        bool mHasXFov;
 
35
        bool mHasYFov;
 
36
        bool mHasXMag;
 
37
        bool mHasYMag;
 
38
        bool mHasAspectRatio;
 
39
        bool mHasZNear;
 
40
        bool mHasZFar;
 
41
 
 
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. */
 
46
        float mAspectRatio;
 
47
        String mAspectRatioSid;
 
48
 
 
49
        /** The distance to the near clipping plane. */
 
50
        float mZNear;
 
51
        String mZNearSid;
 
52
 
 
53
        /** The distance to the far clipping plane. */
 
54
        float mZFar;
 
55
        String mZFarSid;
 
56
 
 
57
        /** The horizontal field of view in degrees - used for the perspective camera. */
 
58
        float mXFov;
 
59
        String mXFovSid;
 
60
 
 
61
        /** The vertical field of view in degrees - used for the perspective camera. */
 
62
        float mYFov;
 
63
        String mYFovSid;
 
64
 
 
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.*/
 
73
        float mXMag;
 
74
        String mXMagSid;
 
75
 
 
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.*/
 
84
        float mYMag;
 
85
        String mYMagSid;
 
86
 
 
87
    protected:
 
88
 
 
89
        /** Adds the optics information. */
 
90
        void add() const;
 
91
 
 
92
        /** Adds the optic type specific information. */
 
93
        virtual void addTypeSpecificInfos () const = 0;
 
94
 
 
95
    public:
 
96
 
 
97
        /** 
 
98
        * Constructor
 
99
        * @param cameraId The id of the camera.
 
100
        * @param cameraName The name of the camera.
 
101
        */
 
102
        BaseOptic ( StreamWriter* streamWriter );
 
103
 
 
104
        /** Destructor */
 
105
        virtual ~BaseOptic() {}
 
106
 
 
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; }
 
112
 
 
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; }
 
118
 
 
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="" );
 
124
 
 
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; }
 
130
 
 
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; }
 
136
 
 
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; }
 
149
 
 
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; }
 
162
 
 
163
    };
 
164
 
 
165
 
 
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 
 
174
    display monitors. */
 
175
    class PerspectiveOptic : public BaseOptic
 
176
    {
 
177
    public:
 
178
 
 
179
        /** 
 
180
        * Constructor
 
181
        * @param cameraId The id of the camera.
 
182
        * @param cameraName The name of the camera.
 
183
        */
 
184
        PerspectiveOptic ( StreamWriter* streamWriter )
 
185
        : BaseOptic ( streamWriter )
 
186
        {}
 
187
 
 
188
        virtual ~PerspectiveOptic() {}
 
189
 
 
190
    protected:
 
191
 
 
192
        /** Adds the camera type specific information. */
 
193
        void addTypeSpecificInfos () const;
 
194
 
 
195
    };
 
196
 
 
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
 
205
    {
 
206
    public:
 
207
 
 
208
        /** 
 
209
        * Constructor
 
210
        */
 
211
        OrthographicOptic ( StreamWriter* streamWriter ) 
 
212
        : BaseOptic ( streamWriter ) {}
 
213
 
 
214
        virtual ~OrthographicOptic() {}
 
215
 
 
216
    protected:
 
217
 
 
218
        /** Adds the optic type specific information. */
 
219
        void addTypeSpecificInfos () const;
 
220
 
 
221
    };
 
222
 
 
223
 
 
224
} //namespace COLLADASW
 
225
 
 
226
#endif //__COLLADASTREAMWRITER_CAMERA_OPTIC_H__