cgv
Loading...
Searching...
No Matches
cgv::render::clipped_view Class Reference

extends the view class with information on z clipping planes and scene extent and supports clipping plane computation from scene extent. More...

#include <clipped_view.h>

Inheritance diagram for cgv::render::clipped_view:
cgv::render::view cgv::render::stereo_view

Public Member Functions

 clipped_view ()
 construct a parallel view with focus in the world origin looking in negative z-direction and the y-direction as up-direction with an extent of +-1
 
void compute_clipping_planes (double &z_near_derived, double &z_far_derived, bool clip_relative_to_extent=false) const
 compute clipping planes adapted to the current scene extent, z_near_derived is at least z_near and as large as possible to include the scene, similarly z_far_derived is as small as possible

 
void compute_clipping_planes (const view &view, double &z_near_derived, double &z_far_derived, bool clip_relative_to_extent=false) const
 compute clipping planes according to given view adapted to the current scene extent, z_near_derived is at least z_near and as large as possible to include the scene, similarly z_far_derived is as small as possible

 
void compute_clipping_planes (const dvec3 &eye, const dvec3 &view_dir, double &z_near_derived, double &z_far_derived, bool clip_relative_to_extent=false) const
 compute clipping planes according to given view adapted to the current scene extent, z_near_derived is at least z_near and as large as possible to include the scene, similarly z_far_derived is as small as possible

 
- Public Member Functions inherited from cgv::render::view
 view ()
 construct a parallel view with focus in the world origin looking in negative z-direction and the y-direction as up-direction with an extent of +-1
 
const dvec3get_focus () const
 query focus point
 
virtual void set_focus (const dvec3 &foc)
 set a new focus point keeping y extent at focus and y view angle fix, such that the eye position is also changed
 
void set_focus (const vec3 &foc)
 
void set_focus (double x, double y, double z)
 set focus from coordinates
 
dvec3ref_focus ()
 write access to focus point
 
const dvec3get_view_dir () const
 query current view direction
 
virtual void set_view_dir (const dvec3 &vd)
 set view direction without ensuring orthogonality to view up direction
 
void set_view_dir (const vec3 &vd)
 
void set_view_dir (double x, double y, double z)
 set view direction from coordinates
 
dvec3ref_view_dir ()
 write access to view dir
 
const dvec3get_view_up_dir () const
 query current view up direction
 
virtual void set_view_up_dir (const dvec3 &vud)
 set view up direction without ensuring orthogonality to view direction
 
void set_view_up_dir (const vec3 &vud)
 
void set_view_up_dir (double x, double y, double z)
 set view up direction from coordinates
 
dvec3ref_view_up_dir ()
 write access to view up direction
 
double & ref_y_extent_at_focus ()
 write access to extent at focus
 
double get_y_view_angle () const
 query opening angle (degrees) of view in y-direction
 
virtual void set_y_view_angle (double angle)
 set opening angle (degrees) of view in y-direction keeping y extent at focus resulting in a dolly zoom
 
double get_y_extent_at_focus () const
 query y extent of viewing window at focus point
 
virtual void set_y_extent_at_focus (double ext)
 set y extent of viewing window at focus point keeping y view angle resulting in a zoom
 
double & ref_y_view_angle ()
 write access to view angle
 
double get_tan_of_half_of_fovy (bool ensure_non_zero) const
 compute tan of half of y view angle, if ensure_non_zero is true, replace y view angles < 0.1 with 0.1
 
double get_y_extent_at_depth (double depth, bool ensure_non_zero) const
 get y extent of viewing window at an arbitrary depth, if ensure_non_zero is true, replace y view angles < 0.1 with 0.1
 
double get_depth_of_focus () const
 return the depth of the focus point
 
void put_coordinate_system (dvec3 &x, dvec3 &y, dvec3 &z) const
 construct coordinate system with z in negative view direction and x and y aligned with the right and up direction of the viewed image
 
void put_coordinate_system (vec3 &x, vec3 &y, vec3 &z) const
 
int compute_axis_and_angle (const dvec3 &target_view_dir, const dvec3 &target_view_up_dir, dvec3 &axis, double &angle)
 compute axis and angle of a rotation that the current view_dir and view_up_dir to the given target_view_dir and target_view_up_dir
 
bool is_parallel () const
 return whether the y view angle is zero
 
const dvec3 get_eye () const
 query the eye point, which is computed from focus, view dir, y extent at focus and y view angle
 
bool set_eye_keep_extent (const dvec3 &eye)
 set view dir and y view angle keeping focus and y extent such that get_eye() returns the passed point, return whether this was successful.
 
bool set_eye_keep_view_angle (const dvec3 &eye)
 set the view dir and y extent at focus keeping focus and y view angle such that get_eye() returns the passed point, return whether this was successful.
 
void view_look_at_keep_view_angle (const dvec3 &eye, const dvec3 &foc, const dvec3 &vud)
 set the view according to the standard view lookat definition from eye, focus and view up direction keeping the y-extent at the focus point constant
 
void view_look_at_keep_extent (const dvec3 &eye, const dvec3 &foc, const dvec3 &vud)
 set the view according to the standard view lookat definition from eye, focus and view up direction keeping the y-view angle constant
 
void roll (double angle)
 roll view around view direction by angle
 
void rotate (double axis_direction_x, double axis_direction_y, double axis_point_depth)
 rotated view around axis by angle
 
void move (double step)
 move along view direction by given step length in world coordinates
 
void pan (double step_x, double step_y)
 move in screen x and screen y directions by given step lengths in world coordinates
 
void zoom (double factor)
 zoom by given factor
 
virtual void enable_viewport_splitting (unsigned nr_cols, unsigned nr_rows)
 call this function before a drawing process to support viewport splitting inside the draw call via the activate/deactivate functions
 
virtual bool is_viewport_splitting_enabled (unsigned *nr_cols_ptr=0, unsigned *nr_rows_ptr=0) const
 check whether viewport splitting is activated and optionally set the number of columns and rows if corresponding pointers are passed
 
virtual void disable_viewport_splitting ()
 disable viewport splitting
 
virtual void activate_split_viewport (context &ctx, unsigned col_index, unsigned row_index)
 inside the drawing process activate the sub-viewport with the given column and row indices, always terminate an activated viewport with deactivate_split_viewport
 
virtual void deactivate_split_viewport (context &ctx)
 deactivate the previously split viewport
 
virtual void enable_viewport_individual_view (unsigned col_index, unsigned row_index, bool enable=true)
 make a viewport manage its own view
 
virtual bool does_viewport_use_individual_view (unsigned col_index, unsigned row_index) const
 check whether viewport manage its own view
 
virtual viewref_viewport_view (unsigned col_index, unsigned row_index)
 access the view of a given viewport
 
virtual int get_modelview_projection_window_matrices (int x, int y, int width, int height, const dmat4 **MPW_pptr, const dmat4 **MPW_other_pptr=0, int *x_other_ptr=0, int *y_other_ptr=0, int *vp_col_idx_ptr=0, int *vp_row_idx_ptr=0, int *vp_width_ptr=0, int *vp_height_ptr=0, int *vp_center_x_ptr=0, int *vp_center_y_ptr=0, int *vp_center_x_other_ptr=0, int *vp_center_y_other_ptr=0) const
 given an opengl pixel location and the size in pixels of the opengl window, return the modelview_projection_window matrix for unprojection
 
virtual int get_modelview_projection_device_matrices (int x, int y, int width, int height, const dmat4 **MVPD_pptr, const dmat4 **MVPD_other_pptr=0, int *x_other_ptr=0, int *y_other_ptr=0, int *vp_col_idx_ptr=0, int *vp_row_idx_ptr=0, int *vp_width_ptr=0, int *vp_height_ptr=0, int *vp_center_x_ptr=0, int *vp_center_y_ptr=0, int *vp_center_x_other_ptr=0, int *vp_center_y_other_ptr=0) const
 
virtual double get_z_and_unproject (context &ctx, int x, int y, dvec3 &p)
 given an opengl pixel location x,y return the window z-value from the depth buffer
 
double get_z_and_unproject (context &ctx, int x, int y, vec3 &p)
 
void compute_screen_rectangle (std::vector< dvec3 > &rect, double depth, double aspect) const
 fill rect with four points covering the screen rectangle at given depth from eye with given aspect ratio
 
void compute_screen_rectangle (std::vector< vec3 > &rect, double depth, double aspect) const
 

Protected Attributes

double z_near
 
double z_far
 
dbox3 scene_extent
 
- Protected Attributes inherited from cgv::render::view
dvec3 focus
 focus of the view
 
dvec3 view_up_dir
 
dvec3 view_dir
 
double y_view_angle
 
double y_extent_at_focus
 

getter and setter methods

double get_z_near () const
 return the currently set z-value for the z-near clipping plane
 
double & ref_z_near ()
 reference to z_near value for ui construction
 
virtual void set_z_near (double z)
 set the z-value for the z-near clipping plane
 
double get_z_far () const
 return the currently set z-value for the z-far clipping plane
 
double & ref_z_far ()
 reference to z_far value for ui construction
 
virtual void set_z_far (double z)
 set the z-value for the z-far clipping plane
 
virtual void set_scene_extent (const dbox3 &_box)
 set the extent of the scene in world coordinates used by the compute_clipping_planes functions to adapt the clipping planes to the scene
 
dbox3 get_scene_extent () const
 return the currently set scene extent
 
virtual void set_default_view ()
 reset view with focus and y-extent based on current scene extent
 
static double get_z_D (double z_eye, double z_near, double z_far)
 transform a z value in eye-coordinates (should be negative!) to device coordinate
 

Detailed Description

extends the view class with information on z clipping planes and scene extent and supports clipping plane computation from scene extent.

Definition at line 13 of file clipped_view.h.

Constructor & Destructor Documentation

◆ clipped_view()

cgv::render::clipped_view::clipped_view ( )

construct a parallel view with focus in the world origin looking in negative z-direction and the y-direction as up-direction with an extent of +-1

Definition at line 7 of file clipped_view.cxx.

Member Function Documentation

◆ compute_clipping_planes() [1/3]

void cgv::render::clipped_view::compute_clipping_planes ( const dvec3 eye,
const dvec3 view_dir,
double &  z_near_derived,
double &  z_far_derived,
bool  clip_relative_to_extent = false 
) const

compute clipping planes according to given view adapted to the current scene extent, z_near_derived is at least z_near and as large as possible to include the scene, similarly z_far_derived is as small as possible

Definition at line 75 of file clipped_view.cxx.

References cgv::media::axis_aligned_box< T, N >::get_center(), cgv::media::axis_aligned_box< T, N >::get_corner(), cgv::media::axis_aligned_box< T, N >::get_max_pnt(), cgv::media::axis_aligned_box< T, N >::get_min_pnt(), and cgv::media::axis_aligned_box< T, N >::is_valid().

◆ compute_clipping_planes() [2/3]

void cgv::render::clipped_view::compute_clipping_planes ( const view view,
double &  z_near_derived,
double &  z_far_derived,
bool  clip_relative_to_extent = false 
) const

compute clipping planes according to given view adapted to the current scene extent, z_near_derived is at least z_near and as large as possible to include the scene, similarly z_far_derived is as small as possible

Definition at line 69 of file clipped_view.cxx.

References compute_clipping_planes(), cgv::render::view::get_eye(), and cgv::render::view::get_view_dir().

◆ compute_clipping_planes() [3/3]

void cgv::render::clipped_view::compute_clipping_planes ( double &  z_near_derived,
double &  z_far_derived,
bool  clip_relative_to_extent = false 
) const

compute clipping planes adapted to the current scene extent, z_near_derived is at least z_near and as large as possible to include the scene, similarly z_far_derived is as small as possible

Definition at line 63 of file clipped_view.cxx.

References compute_clipping_planes().

Referenced by compute_clipping_planes(), and compute_clipping_planes().

◆ get_scene_extent()

dbox3 cgv::render::clipped_view::get_scene_extent ( ) const

return the currently set scene extent

Definition at line 40 of file clipped_view.cxx.

References cgv::media::axis_aligned_box< T, N >::is_valid().

Referenced by set_default_view().

◆ get_z_D()

double cgv::render::clipped_view::get_z_D ( double  z_eye,
double  z_near,
double  z_far 
)
static

transform a z value in eye-coordinates (should be negative!) to device coordinate

Definition at line 56 of file clipped_view.cxx.

◆ get_z_far()

double cgv::render::clipped_view::get_z_far ( ) const

return the currently set z-value for the z-far clipping plane

Definition at line 23 of file clipped_view.cxx.

◆ get_z_near()

double cgv::render::clipped_view::get_z_near ( ) const

return the currently set z-value for the z-near clipping plane

Definition at line 13 of file clipped_view.cxx.

◆ ref_z_far()

double & cgv::render::clipped_view::ref_z_far ( )
inline

reference to z_far value for ui construction

Definition at line 40 of file clipped_view.h.

◆ ref_z_near()

double & cgv::render::clipped_view::ref_z_near ( )
inline

reference to z_near value for ui construction

Definition at line 34 of file clipped_view.h.

◆ set_default_view()

void cgv::render::clipped_view::set_default_view ( )
virtual

reset view with focus and y-extent based on current scene extent

Definition at line 47 of file clipped_view.cxx.

References get_scene_extent(), cgv::render::view::set_focus(), cgv::render::view::set_view_dir(), cgv::render::view::set_view_up_dir(), and cgv::render::view::set_y_extent_at_focus().

◆ set_scene_extent()

void cgv::render::clipped_view::set_scene_extent ( const dbox3 _box)
virtual

set the extent of the scene in world coordinates used by the compute_clipping_planes functions to adapt the clipping planes to the scene

Definition at line 34 of file clipped_view.cxx.

◆ set_z_far()

void cgv::render::clipped_view::set_z_far ( double  z)
virtual

set the z-value for the z-far clipping plane

Definition at line 28 of file clipped_view.cxx.

◆ set_z_near()

void cgv::render::clipped_view::set_z_near ( double  z)
virtual

set the z-value for the z-near clipping plane

Definition at line 18 of file clipped_view.cxx.

Member Data Documentation

◆ scene_extent

dbox3 cgv::render::clipped_view::scene_extent
protected

Definition at line 18 of file clipped_view.h.

◆ z_far

double cgv::render::clipped_view::z_far
protected

Definition at line 17 of file clipped_view.h.

◆ z_near

double cgv::render::clipped_view::z_near
protected

Definition at line 16 of file clipped_view.h.


The documentation for this class was generated from the following files: