i6engine  1.0
api/components/CameraComponent.h
Go to the documentation of this file.
1 /*
2  * i6engine
3  * Copyright (2016) Daniel Bonrath, Michael Baer, All rights reserved.
4  *
5  * This file is part of i6engine; i6engine is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
25 #ifndef __I6ENGINE_API_CAMERACOMPONENT_H__
26 #define __I6ENGINE_API_CAMERACOMPONENT_H__
27 
30 
31 namespace i6e {
32 namespace api {
33 
56  public:
60  CameraComponent(const int64_t id, const attributeMap & params);
61 
65  virtual ~CameraComponent();
66 
72  void setPosition(const Vec3 & relativePosition);
73 
80  void setLookAt(const Vec3 & lookAt);
81 
87  void setNearClip(const int32_t n);
88 
94  void setAspectRatio(const double ratio);
95 
102  void setFOVy(const double fov);
103 
107  void setFrustumExtends(const double left, const double right, const double top, const double bottom);
108 
114  void setViewportDimension(const double left, const double top, const double width, const double height);
115 
119  void setViewportBackground(const double red, const double green, const double blue, const double alpha);
120 
124  Vec3 getPosition() const {
125  return _position;
126  }
127 
131  Vec3 getLookAt() const {
132  return _lookAt;
133  }
134 
138  attributeMap synchronize() const override;
139 
140  std::string getTemplateName() const override {
141  return "Camera";
142  }
143 
144  std::vector<componentOptions> getComponentOptions() override;
145 
149  void enableCompositor(const std::string & compositor, bool enabled);
150 
151  virtual std::pair<AddStrategy, int64_t> howToAdd(const ComPtr & comp) const override;
152 
153  protected:
158 
163 
167  int32_t _nearClip;
168 
173  double _aspect;
174 
175  int _zOrder;
176 
177  bool _viewport;
178 
179  double _left;
180  double _top;
181  double _width;
182  double _height;
183  double _red;
184  double _green;
185  double _blue;
186  double _alpha;
187  double _fov;
188  double _frustumLeft;
190  double _frustumTop;
192 
196  void Init() override;
197 
203  void sendCameraUpdateMessage();
204 
208  void sendViewportUpdateMessage();
209 
213  void sendFrustumUpdateMessage();
214  };
215 
216 } /* namespace api */
217 } /* namespace i6e */
218 
219 #endif /* __I6ENGINE_API_CAMERACOMPONENT_H__ */
220 
#define ISIXE_MODULES_API
std::map< std::string, std::string > attributeMap
Definition: attributeMap.h:42
Vec3 _lookAt
Point the Camera looks at.
Implements 3-dimensional vectors.
Definition: i6eVector.h:48
Vec3 getPosition() const
returns the relative position of the camera on the GameObject
A shared pointer counting references and adds objects being not referenced any more to an internal li...
Definition: sharedPtr.h:50
Vec3 getLookAt() const
returns the position of the lookAt in world space!
Attaches a camera to an object. The Camera will follow the object For creating a CameraComponent, these keys are possible: Name Required Type Description Public pos yes Vec3 relative position of camera to SceneNode yes lookAt yes Vec3 absolute look at position in the world yes nearclip yes double near clipping distance yes aspect no double aspect ration of the camera yes viewport no bool defines whether this camera has a viewport or not yes zOrder *) int relative position on the screen depending on other viewports (has to be unique), *) required when viewport true yes vp_left *) double left startpoint of the viewport, value between 0 and 1, *) required when viewport true yes vp_top *) double uppper startpoint of the viewport, value between 0 and 1, *) required when viewport true yes vp_width *) double width of the viewport, value between 0 and 1, *) required when viewport true yes vp_height *) double height of the viewport, value between 0 and 1, *) required when viewport true yes vp_red *) double red part of the viewports background colour, *) required when viewport true yes vp_green *) double green part of the viewports background colour, *) required when viewport true yes vp_blue *) double blue part of the viewports background colour, *) required when viewport true yes vp_alpha *) double alpha part of the viewports background colour, *) required when viewport true yes
Vec3 _position
Position of the camera.
std::string getTemplateName() const override
returns the name this template was registered with
int32_t _nearClip
nearClippingDistance
Component Base Class. All Components must derive from Component.
Definition: Component.h:97