Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / effects / renderer / engine-model / FUiEffects_RendererEngineModelCamera.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file                FUiEffects_RendererEngineModelCamera.cpp
20  * @brief               This file contains implementation of Camera class
21  *
22  */
23
24 #include <renderer/engine-model/FUiEffects_RendererEngineModelCamera.h>
25 #include <renderer/math/FUiEffects_RendererMathCommon.h>
26
27 namespace Tizen { namespace Ui { namespace Effects { namespace _Renderer { namespace EngineModel
28 {
29
30 Camera::Camera(void)
31 {
32         _proj.value.MakePerspectiveFovRH(Math::F_Deg_2_Rad(45.0f), 1.0f, 0.1f, 32000.0f);
33         _proj.invalid = false;
34
35         _frustum.invalid = true;
36
37         _minPos.Set(0.0f, 0.0f);
38         _maxPos.Set(0.0f, 0.0f);
39
40         _clearColor.Set(1.0f, 1.0f, 1.0f, 1.0f);
41 }
42
43 Camera::~Camera(void)
44 {
45 }
46
47 void
48 Camera::SetViewport(const Math::Vector2f& minPos, const Math::Vector2f& maxPos)
49 {
50         _minPos = minPos;
51         _maxPos = maxPos;
52         return;
53 }
54
55 const Math::Vector2f&
56 Camera::GetViewportMin(void)
57 {
58         return _minPos;
59 }
60
61 const Math::Vector2f&
62 Camera::GetViewportMax(void)
63 {
64         return _maxPos;
65 }
66
67 void
68 Camera::Visit(Visitor& v)
69 {
70         v.OnCamera(*this);
71         return;
72 }
73
74 const Math::Matrix4f&
75 Camera::GetProj(void)
76 {
77         return _proj.value;
78 }
79
80 void
81 Camera::SetProj(const Math::Matrix4f& arg)
82 {
83         _proj.value = arg;
84         _proj.invalid = false;
85
86         _frustum.invalid = true;
87         return;
88 }
89
90 void
91 Camera::SetLocal(const Math::Matrix4f& arg)
92 {
93         Node::SetLocal(arg);
94         _frustum.invalid = true;
95         return;
96 }
97
98 void
99 Camera::SetWorld(const Math::Matrix4f& arg)
100 {
101         Node::SetWorld(arg);
102         _frustum.invalid = true;
103         return;
104 }
105
106 const Frustum&
107 Camera::GetFrustum(void)
108 {
109         if (_frustum.invalid)
110         {
111                 ValidateFrustum();
112         }
113         return _frustum.value;
114 }
115
116 bool
117 Camera::AttachedToParent(Group* pParent)
118 {
119         if (!Node::AttachedToParent(pParent))
120         {
121                 return false;
122         }
123
124         _frustum.invalid = true;
125         return true;
126 }
127
128 bool
129 Camera::RemoveFromParent(Group* pParent)
130 {
131         if (!Node::RemoveFromParent(pParent))
132         {
133                 return false;
134         }
135
136         _frustum.invalid = true;
137         return true;
138 }
139
140 void
141 Camera::ParentMoved(Group* pParent)
142 {
143         Node::ParentMoved(pParent);
144         _frustum.invalid = true;
145         return;
146 }
147
148 void
149 Camera::ValidateFrustum(void)
150 {
151         _frustum.value.Build(GetProj(), GetWorld());
152         _frustum.invalid = false;
153         return;
154 }
155
156 void
157 Camera::SetClearColor(const Math::Vector4f& color)
158 {
159         _clearColor = color;
160         return;
161 }
162
163 const Math::Vector4f&
164 Camera::GetClearColor(void)
165 {
166         return _clearColor;
167 }
168
169 }}}}} //Tizen::Ui::Effects::_Renderer::EngineModel