cgv
Loading...
Searching...
No Matches
view.h
1#pragma once
2
3#include <cgv/math/fvec.h>
4#include <cgv/math/fmat.h>
5#include <cgv/defines/deprecated.h>
6#include "lib_begin.h"
7
8namespace cgv {
9 namespace render {
10
11 class context;
12
21class CGV_API view
22{
23protected:
27 dvec3 view_up_dir;
29 dvec3 view_dir;
31 double y_view_angle;
33 double y_extent_at_focus;
34public:
36 view();
37 virtual ~view() noexcept = default;
38
41
43 const dvec3& get_focus() const;
45 virtual void set_focus(const dvec3& foc);
46 void set_focus(const vec3& foc) { set_focus(dvec3(foc)); }
48 void set_focus(double x, double y, double z);
50 dvec3& ref_focus();
51
53 const dvec3& get_view_dir() const;
55 virtual void set_view_dir(const dvec3& vd);
56 void set_view_dir(const vec3& vd) { set_view_dir(dvec3(vd)); }
58 void set_view_dir(double x, double y, double z);
60 dvec3& ref_view_dir();
61
63 const dvec3& get_view_up_dir() const;
65 virtual void set_view_up_dir(const dvec3& vud);
66 void set_view_up_dir(const vec3& vud) { set_view_up_dir(dvec3(vud)); }
68 void set_view_up_dir(double x, double y, double z);
70 dvec3& ref_view_up_dir();
72 double& ref_y_extent_at_focus();
73
75 double get_y_view_angle() const;
77 virtual void set_y_view_angle(double angle);
79 double get_y_extent_at_focus() const;
81 virtual void set_y_extent_at_focus(double ext);
83 double& ref_y_view_angle();
85
89 double get_tan_of_half_of_fovy(bool ensure_non_zero) const;
91 double get_y_extent_at_depth(double depth, bool ensure_non_zero) const;
93 double get_depth_of_focus() const;
95
97 void put_coordinate_system(dvec3& x, dvec3& y, dvec3& z) const;
98 void put_coordinate_system(vec3& x, vec3& y, vec3& z) const;
100
101 int compute_axis_and_angle(const dvec3& target_view_dir, const dvec3& target_view_up_dir, dvec3& axis, double& angle);
103 bool is_parallel() const;
105
107 const dvec3 get_eye() const;
109
112 bool set_eye_keep_extent(const dvec3& eye);
114
117 bool set_eye_keep_view_angle(const dvec3& eye);
119 void view_look_at_keep_view_angle(const dvec3& eye, const dvec3& foc, const dvec3& vud);
121 void view_look_at_keep_extent(const dvec3& eye, const dvec3& foc, const dvec3& vud);
123
127 void roll(double angle);
129
134 void rotate(double axis_direction_x, double axis_direction_y, double axis_point_depth);
136 void move(double step);
138 void pan(double step_x, double step_y);
140 void zoom(double factor);
142
146 virtual void enable_viewport_splitting(unsigned nr_cols, unsigned nr_rows);
148 virtual bool is_viewport_splitting_enabled(unsigned* nr_cols_ptr = 0, unsigned* nr_rows_ptr = 0) const;
150 virtual void disable_viewport_splitting();
152 virtual void activate_split_viewport(context& ctx, unsigned col_index, unsigned row_index);
154 virtual void deactivate_split_viewport(context& ctx);
156 virtual void enable_viewport_individual_view(unsigned col_index, unsigned row_index, bool enable = true);
158 virtual bool does_viewport_use_individual_view(unsigned col_index, unsigned row_index) const;
160 virtual view& ref_viewport_view(unsigned col_index, unsigned row_index);
162
179 virtual int get_modelview_projection_window_matrices(int x, int y, int width, int height,
180 const dmat4** MPW_pptr,
181 const dmat4** MPW_other_pptr = 0, int* x_other_ptr = 0, int* y_other_ptr = 0,
182 int* vp_col_idx_ptr = 0, int* vp_row_idx_ptr = 0,
183 int* vp_width_ptr = 0, int *vp_height_ptr = 0,
184 int* vp_center_x_ptr = 0, int* vp_center_y_ptr = 0,
185 int* vp_center_x_other_ptr = 0, int* vp_center_y_other_ptr = 0) const;
186
187 DEPRECATED("deprecated, use get_modelview_projection_window_matrices() instead.") virtual int get_modelview_projection_device_matrices(int x, int y, int width, int height,
188 const dmat4** MVPD_pptr,
189 const dmat4** MVPD_other_pptr = 0, int* x_other_ptr = 0, int* y_other_ptr = 0,
190 int* vp_col_idx_ptr = 0, int* vp_row_idx_ptr = 0,
191 int* vp_width_ptr = 0, int *vp_height_ptr = 0,
192 int* vp_center_x_ptr = 0, int* vp_center_y_ptr = 0,
193 int* vp_center_x_other_ptr = 0, int* vp_center_y_other_ptr = 0) const {
194 return get_modelview_projection_window_matrices(x,y,width,height,MVPD_pptr,MVPD_other_pptr,
195 x_other_ptr,y_other_ptr,vp_col_idx_ptr, vp_row_idx_ptr, vp_width_ptr, vp_height_ptr,
196 vp_center_x_ptr, vp_center_y_ptr, vp_center_x_other_ptr, vp_center_y_other_ptr);
197 }
199
201 virtual double get_z_and_unproject(context& ctx, int x, int y, dvec3& p);
202 double get_z_and_unproject(context& ctx, int x, int y, vec3& p);
204 void compute_screen_rectangle(std::vector<dvec3>& rect, double depth, double aspect) const;
205 void compute_screen_rectangle(std::vector<vec3>& rect, double depth, double aspect) const;
207
208};
209 }
210}
211
212#include <cgv/config/lib_end.h>
defines a symmetric view with the following quantities:
Definition view.h:22
dvec3 focus
focus of the view
Definition view.h:25
this header is dependency free
Definition print.h:11