API Documentation
Loading...
Searching...
No Matches
Camera.h
Go to the documentation of this file.
1/**--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Design
28File: Camera
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include <NDEVR/Model.h>
34#include <NDEVR/SelectionInfo.h>
35#include <NDEVR/SnapLocation.h>
36#include <NDEVR/CameraBackground.h>
37#include <NDEVR/AutoZoomFocus.h>
38#include <NDEVR/CameraAnimation.h>
39#include <NDEVR/Resource.h>
40#include <NDEVR/Time.h>
41#include <NDEVR/TimeSpan.h>
42#include <NDEVR/BaseValues.h>
43#include <NDEVR/Vector.h>
44#include <NDEVR/Angle.h>
45#include <NDEVR/BasicResourceListener.h>
46#if NDEVR_VIEWPORT
47namespace NDEVR
48{
49 class ViewportFormat;
50 class NDEVR_DESIGN_API Camera : public Model
51 {
52 public:
53 Resource<Vertex<3, fltp08>> offset;
54 Resource<Vector<3, Angle<fltp08>>> orientation;
55 Resource<Vertex<3, fltp08>> target;
56
57 Resource<fltp08> near_plane;
58 Resource<fltp08> far_plane;
59 Resource<fltp08> zoom_extent_mult;
60
61 Resource<Vector<2, Angle<fltp08>>> perspective_fov;
62 Resource<Vector<2, fltp08>> orthographic_fov;
63
64 Resource<Time> last_update_time;
65 Resource<bool> location_lock;
66 Resource<bool> rotation_lock;
67 Resource<bool> is_orthographic;
68 Resource<bool> is_exposed;
69 Resource<fltp08> plane_intercept_value;
70 Resource<fltp08> orthographic_perspective_ratio;
71 Resource<SelectionInfo> selection_info;
72
73 DynamicPointer<Dictionary<UUID, bool>> visible_items;
74
75 public:
76 Camera(Model& camera);
77 Camera(const Camera& camera);
78 const Ray<3, fltp08>& getLookat() const;
79 bool refreshMovement(const Time& current_time, const DesignObjectLookup* lookup, const TimeSpan& time_out = TimeSpan(0.2));
80 void refreshFocusBounds(const DesignObjectLookup* lookup);
81
82 void clearAnimations();
83 void move(const Ray<3, fltp08>& distance);
84 void move(const Ray<3, fltp08>& distance, const CameraAnimation& original);
85 void zoom(fltp08 distance_mult, const CameraAnimation& original);
86 void moveForward(fltp08 distance);
87 void moveHorizontal(fltp08 distance);
88 void moveVertical(fltp08 distance);
89 void move(fltp08 horizontal_distance, fltp08 vertical_distance);
90 void move(fltp08 horizontal_distance, fltp08 vertical_distance, const CameraAnimation& original);
91 void lookHorizontal(fltp08 percent);
92 void lookVertical(fltp08 percent);
93 void look(fltp08 horz_percent, fltp08 vert_percent);
94 void look(fltp08 horz_percent, fltp08 vert_percent, const CameraAnimation& original);
95
96 void moveHorizontalPercent(fltp08 percent);
97 void moveVerticalPercent(fltp08 percent);
98 void movePercent(fltp08 horizontal_percent, fltp08 vertical_percent);
99 void movePercent(fltp08 horizontal_percent, fltp08 vertical_percent, const CameraAnimation& original);
100 void panPercent(fltp08 horizontal_percent, fltp08 vertical_percent, const CameraAnimation& original);
101 void addAnimation(CameraAnimation animation, bool clear_current_animations = true);
102 void addZoomAnimation(fltp08 distance_mult, const TimeSpan& time, bool clear_animations = true);
103 void addLookatAnimation(Vector<3, fltp08> lookat, const TimeSpan& time, bool clear_animations = true);
104 void addIsOrthographicAnimation(bool is_orthographic, const TimeSpan& time, bool clear_animations = true);
105 void addOrbitAnimation(Vector<3, fltp08> target, Vector<3, Angle<fltp08>> orient, fltp08 zoom, bool face_target, const TimeSpan& time, bool clear_animations = true);
106 void setAutoZoomFocus(AutoZoomFocus focus);
107 void addZoomToExtentsAnimation(SnapLocation location, Bounds<3, fltp08> object, const TimeSpan& time, bool use_true_extents = true, bool clear_animations = true, Vector<3, Angle<fltp08>> angle_offsets = Vector<3, Angle<fltp08>>(Angle<fltp08>(0)));
108 void addZoomToExtentsAnimation(Bounds<3, fltp08> object, const TimeSpan& time, bool use_true_extents = true, bool clear_animations = true, Vector<3, Angle<fltp08>> angle_offsets = Vector<3, Angle<fltp08>>(Angle<fltp08>(0)));
109 void addZoomToExtentsAnimation(Vector<3, Angle<fltp08>> orientation, Bounds<3, fltp08> object, const TimeSpan& time, bool use_true_extents = true, bool clear_animations = true);
110 void addZoomMultiplierAnimation(fltp08 multiplier, const TimeSpan& time, bool clear_animations = true);
111 void postUpdateBackground();
112 void clearAutozoomFocus();
113 bool hasFullAutoFocus() const;
114 void readMetaData();
115 void writeMetaData();
116 SnapLocation currentSnapLocation() const;
117 SnapLocation preferredSnapLocation() const;
118 bool hasWorldGridAlignment() const;
119 void copyFrom(const Camera& object);
120 void updateGridSpacing();
121 bool isUserCamera() const;
122 void setupFromFormat(const ViewportFormat& format);
123 ViewportFormat format() const;
124 bool isObjectPotentiallyVisibleToCamera(const UUID& id) const;
125 [[nodiscard]] Matrix<fltp08> getLookatTransform() const;
126 void setLookatTransform(const Matrix<fltp08>& transform);
127 //Converts to range -1.0 to 1.0 based off of current window size
128 Vertex<2, fltp08> toScreenSpace(const Vector<2, fltp04>& pixel_location) const;
129 Vertex<3, fltp08> toWorldSpaceFromPixelSpace(const Vector<2, fltp04>& pixel_location, fltp08 depth_percent) const;
130 Vertex<3, fltp08> toWorldSpaceFromViewSpace(const Vector<2, fltp08>& view_location, fltp08 depth_percent) const;
131 SelectionInfo createSelectionInfo() const;
132 SelectionInfo createSelectionInfo(const Vector<2, fltp04>& pixel_location) const;
133 SelectionInfo createSelectionInfo(const Bounds<2, fltp04>& pixel_location) const;
134 SelectionInfo createSelectionInfo(const Polygon<fltp04>& pixel_location) const;
135 Vector<3, Angle<fltp08>> gotoOrientation() const;
136 Vector<2, Angle<fltp08>> activeFOV() const;
137 Vector<2, fltp08> activeOrthoSize() const;
138 Vector<3, fltp08> gotoLocation() const;
139 Bounds<3, fltp08> getOrthographicBounds() const;
140 Bounds<2, Angle<fltp08>> getPerspectiveBounds() const;
141 Vector<2, uint04> windowSize() const;
142 fltp08 pixelThickness() const;
143 void setPixelThickness(fltp08 thickness);
144 void setNearPlaneBounds(const Bounds<1, fltp08>& near_plane_bounds) { m_near_plane_bounds = near_plane_bounds; }
145 void setFarPlaneBounds(const Bounds<1, fltp08>& near_plane_bounds) { m_far_plane_bounds = near_plane_bounds; }
146 const Bounds<1, fltp08>& nearPlaneBounds() const { return m_near_plane_bounds; }
147 const Bounds<1, fltp08>& farPlaneBounds() const { return m_far_plane_bounds; }
148
149 Matrix<fltp08> projectionMatrix() const;
150 void setWindowSize(const Vector<2, uint04>& size);
151 void setUseReferenceSize(bool use_reference_size);
152 fltp08 calculatedReferenceSize() const;
153 void setReferenceSize(fltp08 size);
154 Vector<2, Angle<fltp08>> getRotateAroundPoint(const Vector<3, fltp04>& vCenter) const;
155 Bounds<3, fltp08> getFocusBounds() const { return m_autozoom_focus.bounds; }
156 void setFocusBounds(const Bounds<3, fltp08>& bounds) { m_autozoom_focus.bounds = bounds; }
157 //Vector<3, fltp08> lastReference() const { return m_last_refrence; }
158 const CameraBackground& cameraBackground() const { return m_camera_background; }
159 CameraBackground& cameraBackground() { return m_camera_background; }
160 private:
161 void _zoomToTargetModel(const Model& model, const DesignObjectLookup* lookup);
162 void _setupListeners();
163 Bounds<3, fltp08> boundsOfTargets(const DesignObjectLookup* lookup) const;
164 private:
165 Ray<2, uint04> m_window_size;
166 fltp08 m_reference_size;
167
168 Bounds<1, fltp08> m_near_plane_bounds;
169 Bounds<1, fltp08> m_far_plane_bounds;
170
171 Ray<3, fltp08> m_lookat;
172 Ray<3, fltp08> m_up_direction;
173 fltp08 m_pixel_thickness;
174 Vertex<3, fltp08> m_goto_initial_offset;
175 Vertex<3, fltp08> m_goto_initial_target;
176 Vector<3, Angle<fltp08>> m_goto_initial_orientation;
177 Vector<2, fltp08> m_goto_initial_ortho_bounds;
178 fltp08 m_goto_initial_zoom_extent_mult;
179 AutoZoomFocus m_autozoom_focus;
180 CameraBackground m_camera_background;
181 Matrix<fltp08> m_custom_transform;
182 Buffer<CameraAnimation> m_animations;
183 BasicResourceListener m_units_listener;
184 SnapLocation m_default_snap = SnapLocation::e_no_snap;
185 bool m_use_reference_size = true;
186 bool m_refresh_background = false;
187 private:
188 void executeAnimations(Time current_time);
189 };
190};//End namespace NDEVR
191#endif
192
193
#define NDEVR_DESIGN_API
Definition DLLInfo.h:77
Definition ACIColor.h:37
SnapLocation
Definition ViewLocation.h:37
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:181