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
40
42 const dvec3& get_focus() const;
44 virtual void set_focus(const dvec3& foc);
45 void set_focus(const vec3& foc) { set_focus(dvec3(foc)); }
47 void set_focus(double x, double y, double z);
49 dvec3& ref_focus();
50
52 const dvec3& get_view_dir() const;
54 virtual void set_view_dir(const dvec3& vd);
55 void set_view_dir(const vec3& vd) { set_view_dir(dvec3(vd)); }
57 void set_view_dir(double x, double y, double z);
59 dvec3& ref_view_dir();
60
62 const dvec3& get_view_up_dir() const;
64 virtual void set_view_up_dir(const dvec3& vud);
65 void set_view_up_dir(const vec3& vud) { set_view_up_dir(dvec3(vud)); }
67 void set_view_up_dir(double x, double y, double z);
69 dvec3& ref_view_up_dir();
71 double& ref_y_extent_at_focus();
72
74 double get_y_view_angle() const;
76 virtual void set_y_view_angle(double angle);
78 double get_y_extent_at_focus() const;
80 virtual void set_y_extent_at_focus(double ext);
82 double& ref_y_view_angle();
84
88 double get_tan_of_half_of_fovy(bool ensure_non_zero) const;
90 double get_y_extent_at_depth(double depth, bool ensure_non_zero) const;
92 double get_depth_of_focus() const;
94
96 void put_coordinate_system(dvec3& x, dvec3& y, dvec3& z) const;
97 void put_coordinate_system(vec3& x, vec3& y, vec3& z) const;
99
100 int compute_axis_and_angle(const dvec3& target_view_dir, const dvec3& target_view_up_dir, dvec3& axis, double& angle);
102 bool is_parallel() const;
104
106 const dvec3 get_eye() const;
108
111 bool set_eye_keep_extent(const dvec3& eye);
113
116 bool set_eye_keep_view_angle(const dvec3& eye);
118 void view_look_at_keep_view_angle(const dvec3& eye, const dvec3& foc, const dvec3& vud);
120 void view_look_at_keep_extent(const dvec3& eye, const dvec3& foc, const dvec3& vud);
122
126 void roll(double angle);
128
133 void rotate(double axis_direction_x, double axis_direction_y, double axis_point_depth);
135 void move(double step);
137 void pan(double step_x, double step_y);
139 void zoom(double factor);
141
145 virtual void enable_viewport_splitting(unsigned nr_cols, unsigned nr_rows);
147 virtual bool is_viewport_splitting_enabled(unsigned* nr_cols_ptr = 0, unsigned* nr_rows_ptr = 0) const;
149 virtual void disable_viewport_splitting();
151 virtual void activate_split_viewport(context& ctx, unsigned col_index, unsigned row_index);
153 virtual void deactivate_split_viewport(context& ctx);
155 virtual void enable_viewport_individual_view(unsigned col_index, unsigned row_index, bool enable = true);
157 virtual bool does_viewport_use_individual_view(unsigned col_index, unsigned row_index) const;
159 virtual view& ref_viewport_view(unsigned col_index, unsigned row_index);
161
178 virtual int get_modelview_projection_window_matrices(int x, int y, int width, int height,
179 const dmat4** MPW_pptr,
180 const dmat4** MPW_other_pptr = 0, int* x_other_ptr = 0, int* y_other_ptr = 0,
181 int* vp_col_idx_ptr = 0, int* vp_row_idx_ptr = 0,
182 int* vp_width_ptr = 0, int *vp_height_ptr = 0,
183 int* vp_center_x_ptr = 0, int* vp_center_y_ptr = 0,
184 int* vp_center_x_other_ptr = 0, int* vp_center_y_other_ptr = 0) const;
185
186 DEPRECATED("deprecated, use get_modelview_projection_window_matrices() instead.") virtual int get_modelview_projection_device_matrices(int x, int y, int width, int height,
187 const dmat4** MVPD_pptr,
188 const dmat4** MVPD_other_pptr = 0, int* x_other_ptr = 0, int* y_other_ptr = 0,
189 int* vp_col_idx_ptr = 0, int* vp_row_idx_ptr = 0,
190 int* vp_width_ptr = 0, int *vp_height_ptr = 0,
191 int* vp_center_x_ptr = 0, int* vp_center_y_ptr = 0,
192 int* vp_center_x_other_ptr = 0, int* vp_center_y_other_ptr = 0) const {
193 return get_modelview_projection_window_matrices(x,y,width,height,MVPD_pptr,MVPD_other_pptr,
194 x_other_ptr,y_other_ptr,vp_col_idx_ptr, vp_row_idx_ptr, vp_width_ptr, vp_height_ptr,
195 vp_center_x_ptr, vp_center_y_ptr, vp_center_x_other_ptr, vp_center_y_other_ptr);
196 }
198
200 virtual double get_z_and_unproject(context& ctx, int x, int y, dvec3& p);
201 double get_z_and_unproject(context& ctx, int x, int y, vec3& p);
203 void compute_screen_rectangle(std::vector<dvec3>& rect, double depth, double aspect) const;
204 void compute_screen_rectangle(std::vector<vec3>& rect, double depth, double aspect) const;
206
207};
208 }
209}
210
211#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
the cgv namespace
Definition print.h:11