libigl v2.5.0
Loading...
Searching...
No Matches
igl::opengl::ViewerCore Class Reference

Basic class of the 3D mesh viewer. More...

#include <ViewerCore.h>

Public Types

enum  RotationType { ROTATION_TYPE_TRACKBALL = 0 , ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP = 1 , ROTATION_TYPE_NO_ROTATION = 2 , NUM_ROTATION_TYPES = 3 }
 Type of user interface for changing the view rotation based on the mouse draggin. More...
 
using GLuint = MeshGL::GLuint
 

Public Member Functions

 ViewerCore ()
 
void init ()
 Initialization.
 
void shut ()
 Shutdown.
 
void InitSerialization ()
 Serialization code.
 
void align_camera_center (const Eigen::MatrixXd &V, const Eigen::MatrixXi &F)
 Adjust the view to see the entire model.
 
void align_camera_center (const Eigen::MatrixXd &V)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
void get_scale_and_shift_to_fit_mesh (const Eigen::MatrixXd &V, const Eigen::MatrixXi &F, float &zoom, Eigen::Vector3f &shift)
 Determines how much to zoom and shift such that the mesh fills the unit box (centered at the origin)
 
void get_scale_and_shift_to_fit_mesh (const Eigen::MatrixXd &V, float &zoom, Eigen::Vector3f &shift)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
void clear_framebuffers ()
 Clear the frame buffers.
 
void draw (ViewerData &data, bool update_matrices=true)
 Draw everything.
 
void initialize_shadow_pass ()
 initialize shadow pass
 
void deinitialize_shadow_pass ()
 deinitialize shadow pass
 
void draw_shadow_pass (ViewerData &data, bool update_matrices=true)
 Draw everything to shadow map.
 
void draw_buffer (ViewerData &data, bool update_matrices, Eigen::Matrix< unsigned char, Eigen::Dynamic, Eigen::Dynamic > &R, Eigen::Matrix< unsigned char, Eigen::Dynamic, Eigen::Dynamic > &G, Eigen::Matrix< unsigned char, Eigen::Dynamic, Eigen::Dynamic > &B, Eigen::Matrix< unsigned char, Eigen::Dynamic, Eigen::Dynamic > &A)
 Render given ViewerData to a buffer.
 
void draw_labels (ViewerData &data, const igl::opengl::MeshGL::TextGL &labels)
 Draw the text lables.
 
void set_rotation_type (const RotationType &value)
 Set the current rotation type.
 
void set (unsigned int &property_mask, bool value=true) const
 Set a ViewerData visualization option for this viewport.
 
void unset (unsigned int &property_mask) const
 Unset a ViewerData visualization option for this viewport.
 
void toggle (unsigned int &property_mask) const
 Toggle a ViewerData visualization option for this viewport.
 
bool is_set (unsigned int property_mask) const
 Check whether a ViewerData visualization option is set for this viewport.
 
void delete_shadow_buffers ()
 delete the shadow buffers
 
void generate_shadow_buffers ()
 generate the shadow buffers
 

Public Attributes

unsigned int id = 1u
 Unique identifier.
 
Eigen::Vector4f background_color
 Background color as RGBA.
 
Eigen::Vector3f light_position
 Light position (or direction to light)
 
bool is_directional_light
 Whether to treat light_position as a point or direction.
 
bool is_shadow_mapping
 Whether shadow mapping is on.
 
GLuint shadow_width
 Width of the shadow map.
 
GLuint shadow_height
 Height of the shadow map.
 
GLuint shadow_depth_tex
 Shadow map depth texture.
 
GLuint shadow_depth_fbo
 Shadow map depth framebuffer object.
 
GLuint shadow_color_rbo
 Shadow map color render buffer object.
 
float lighting_factor
 Factor of lighting (0: no lighting, 1: full lighting)
 
RotationType rotation_type
 Type of rotation interaction.
 
Eigen::Quaternionf trackball_angle
 View rotation as quaternion.
 
float camera_base_zoom
 Base zoom of camera.
 
float camera_zoom
 Current zoom of camera.
 
bool orthographic
 Whether camera is orthographic (or perspective)
 
Eigen::Vector3f camera_base_translation
 Base translation of camera.
 
Eigen::Vector3f camera_translation
 Current translation of camera.
 
Eigen::Vector3f camera_eye
 Current "eye" / origin position of camera.
 
Eigen::Vector3f camera_up
 Current "up" vector of camera.
 
Eigen::Vector3f camera_center
 Current "look at" position of camera.
 
float camera_view_angle
 Current view angle of camera.
 
float camera_dnear
 Near plane of camera.
 
float camera_dfar
 Far plane of camera.
 
bool depth_test
 Whether testing for depth is enabled.
 
bool is_animating
 Whether "animating" (continuous drawing) is enabled.
 
double animation_max_fps
 Max fps of animation loop (e.g. 30fps or 60fps)
 
float object_scale
 Caches the two-norm between the min/max point of the bounding box.
 
Eigen::Vector4f viewport
 Viewport size.
 
Eigen::Matrix4f view
 OpenGL view transformation matrix on last render pass.
 
Eigen::Matrix4f proj
 OpenGL proj transformation matrix on last render pass.
 
Eigen::Matrix4f norm
 OpenGL norm transformation matrix on last render pass.
 
Eigen::Matrix4f shadow_view
 OpenGL shadow_view transformation matrix on last render pass.
 
Eigen::Matrix4f shadow_proj
 OpenGL shadow_proj transformation matrix on last render pass.
 

Detailed Description

Basic class of the 3D mesh viewer.

Member Typedef Documentation

◆ GLuint

Member Enumeration Documentation

◆ RotationType

Type of user interface for changing the view rotation based on the mouse draggin.

Enumerator
ROTATION_TYPE_TRACKBALL 

Typical trackball rotation (like Meshlab)

ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP 

Fixed up rotation (like Blender, Maya, etc.)

ROTATION_TYPE_NO_ROTATION 

No rotation suitable for 2D.

NUM_ROTATION_TYPES 

Total number of rotation types.

Constructor & Destructor Documentation

◆ ViewerCore()

igl::opengl::ViewerCore::ViewerCore ( )

Member Function Documentation

◆ init()

void igl::opengl::ViewerCore::init ( )

Initialization.

◆ shut()

void igl::opengl::ViewerCore::shut ( )

Shutdown.

◆ InitSerialization()

void igl::opengl::ViewerCore::InitSerialization ( )

Serialization code.

◆ align_camera_center() [1/2]

void igl::opengl::ViewerCore::align_camera_center ( const Eigen::MatrixXd &  V,
const Eigen::MatrixXi &  F 
)

Adjust the view to see the entire model.

Parameters
[in]V#V by 3 list of vertex positions
[in]F#F by 3 list of triangle indices into V

◆ align_camera_center() [2/2]

void igl::opengl::ViewerCore::align_camera_center ( const Eigen::MatrixXd &  V)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ get_scale_and_shift_to_fit_mesh() [1/2]

void igl::opengl::ViewerCore::get_scale_and_shift_to_fit_mesh ( const Eigen::MatrixXd &  V,
const Eigen::MatrixXi &  F,
float &  zoom,
Eigen::Vector3f &  shift 
)

Determines how much to zoom and shift such that the mesh fills the unit box (centered at the origin)

Parameters
[in]V#V by 3 list of vertex positions
[in]F#F by 3 list of triangle indices into V
[out]zoomzoom factor
[out]shift3d shift

◆ get_scale_and_shift_to_fit_mesh() [2/2]

void igl::opengl::ViewerCore::get_scale_and_shift_to_fit_mesh ( const Eigen::MatrixXd &  V,
float &  zoom,
Eigen::Vector3f &  shift 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ clear_framebuffers()

void igl::opengl::ViewerCore::clear_framebuffers ( )

Clear the frame buffers.

◆ draw()

void igl::opengl::ViewerCore::draw ( ViewerData data,
bool  update_matrices = true 
)

Draw everything.

Note
data cannot be const because it is being set to "clean"
Parameters
[in]datawhich ViewerData to draw
[in]update_matriceswhether to update view, proj, and norm matrices in shaders

◆ initialize_shadow_pass()

void igl::opengl::ViewerCore::initialize_shadow_pass ( )

initialize shadow pass

◆ deinitialize_shadow_pass()

void igl::opengl::ViewerCore::deinitialize_shadow_pass ( )

deinitialize shadow pass

◆ draw_shadow_pass()

void igl::opengl::ViewerCore::draw_shadow_pass ( ViewerData data,
bool  update_matrices = true 
)

Draw everything to shadow map.

Parameters
[in]datawhich ViewerData to draw
[in]update_matriceswhether to update view, proj, and norm

◆ draw_buffer()

void igl::opengl::ViewerCore::draw_buffer ( ViewerData data,
bool  update_matrices,
Eigen::Matrix< unsigned char, Eigen::Dynamic, Eigen::Dynamic > &  R,
Eigen::Matrix< unsigned char, Eigen::Dynamic, Eigen::Dynamic > &  G,
Eigen::Matrix< unsigned char, Eigen::Dynamic, Eigen::Dynamic > &  B,
Eigen::Matrix< unsigned char, Eigen::Dynamic, Eigen::Dynamic > &  A 
)

Render given ViewerData to a buffer.

The width and height are determined by non-zeros dimensions of R (and G,B,A should match) or – if both are zero — are set to this core's viewport sizes.

Parameters
[in]datawhich ViewerData to draw
[in]update_matriceswhether to update view, proj, and norm matrices in shaders
[out]Rwidth by height red pixel color values
[out]Gwidth by height green pixel color values
[out]Bwidth by height blue pixel color values
[out]Awidth by height alpha pixel color values

◆ draw_labels()

void igl::opengl::ViewerCore::draw_labels ( ViewerData data,
const igl::opengl::MeshGL::TextGL labels 
)

Draw the text lables.

Parameters
[in]datawhich ViewerData to draw
[in]labelstext labels to draw

◆ set_rotation_type()

void igl::opengl::ViewerCore::set_rotation_type ( const RotationType value)

Set the current rotation type.

Parameters
[in]valuethe new rotation type

◆ set()

void igl::opengl::ViewerCore::set ( unsigned int &  property_mask,
bool  value = true 
) const

Set a ViewerData visualization option for this viewport.

Parameters
[in]property_maska bit mask of visualization option
[in]valuewhether to set or unset the property

◆ unset()

void igl::opengl::ViewerCore::unset ( unsigned int &  property_mask) const

Unset a ViewerData visualization option for this viewport.

Parameters
[in]property_maska bit mask of visualization option

◆ toggle()

void igl::opengl::ViewerCore::toggle ( unsigned int &  property_mask) const

Toggle a ViewerData visualization option for this viewport.

Parameters
[in]property_maska bit mask of visualization option

◆ is_set()

bool igl::opengl::ViewerCore::is_set ( unsigned int  property_mask) const

Check whether a ViewerData visualization option is set for this viewport.

Parameters
[in]property_maska bit mask of visualization option
Returns
whether the property is set

◆ delete_shadow_buffers()

void igl::opengl::ViewerCore::delete_shadow_buffers ( )

delete the shadow buffers

◆ generate_shadow_buffers()

void igl::opengl::ViewerCore::generate_shadow_buffers ( )

generate the shadow buffers

Member Data Documentation

◆ id

unsigned int igl::opengl::ViewerCore::id = 1u

Unique identifier.

◆ background_color

Eigen::Vector4f igl::opengl::ViewerCore::background_color

Background color as RGBA.

◆ light_position

Eigen::Vector3f igl::opengl::ViewerCore::light_position

Light position (or direction to light)

◆ is_directional_light

bool igl::opengl::ViewerCore::is_directional_light

Whether to treat light_position as a point or direction.

◆ is_shadow_mapping

bool igl::opengl::ViewerCore::is_shadow_mapping

Whether shadow mapping is on.

◆ shadow_width

GLuint igl::opengl::ViewerCore::shadow_width

Width of the shadow map.

◆ shadow_height

GLuint igl::opengl::ViewerCore::shadow_height

Height of the shadow map.

◆ shadow_depth_tex

GLuint igl::opengl::ViewerCore::shadow_depth_tex

Shadow map depth texture.

◆ shadow_depth_fbo

GLuint igl::opengl::ViewerCore::shadow_depth_fbo

Shadow map depth framebuffer object.

◆ shadow_color_rbo

GLuint igl::opengl::ViewerCore::shadow_color_rbo

Shadow map color render buffer object.

◆ lighting_factor

float igl::opengl::ViewerCore::lighting_factor

Factor of lighting (0: no lighting, 1: full lighting)

◆ rotation_type

RotationType igl::opengl::ViewerCore::rotation_type

Type of rotation interaction.

◆ trackball_angle

Eigen::Quaternionf igl::opengl::ViewerCore::trackball_angle

View rotation as quaternion.

◆ camera_base_zoom

float igl::opengl::ViewerCore::camera_base_zoom

Base zoom of camera.

◆ camera_zoom

float igl::opengl::ViewerCore::camera_zoom

Current zoom of camera.

◆ orthographic

bool igl::opengl::ViewerCore::orthographic

Whether camera is orthographic (or perspective)

◆ camera_base_translation

Eigen::Vector3f igl::opengl::ViewerCore::camera_base_translation

Base translation of camera.

◆ camera_translation

Eigen::Vector3f igl::opengl::ViewerCore::camera_translation

Current translation of camera.

◆ camera_eye

Eigen::Vector3f igl::opengl::ViewerCore::camera_eye

Current "eye" / origin position of camera.

◆ camera_up

Eigen::Vector3f igl::opengl::ViewerCore::camera_up

Current "up" vector of camera.

◆ camera_center

Eigen::Vector3f igl::opengl::ViewerCore::camera_center

Current "look at" position of camera.

◆ camera_view_angle

float igl::opengl::ViewerCore::camera_view_angle

Current view angle of camera.

◆ camera_dnear

float igl::opengl::ViewerCore::camera_dnear

Near plane of camera.

◆ camera_dfar

float igl::opengl::ViewerCore::camera_dfar

Far plane of camera.

◆ depth_test

bool igl::opengl::ViewerCore::depth_test

Whether testing for depth is enabled.

◆ is_animating

bool igl::opengl::ViewerCore::is_animating

Whether "animating" (continuous drawing) is enabled.

◆ animation_max_fps

double igl::opengl::ViewerCore::animation_max_fps

Max fps of animation loop (e.g. 30fps or 60fps)

◆ object_scale

float igl::opengl::ViewerCore::object_scale

Caches the two-norm between the min/max point of the bounding box.

◆ viewport

Eigen::Vector4f igl::opengl::ViewerCore::viewport

Viewport size.

◆ view

Eigen::Matrix4f igl::opengl::ViewerCore::view

OpenGL view transformation matrix on last render pass.

◆ proj

Eigen::Matrix4f igl::opengl::ViewerCore::proj

OpenGL proj transformation matrix on last render pass.

◆ norm

Eigen::Matrix4f igl::opengl::ViewerCore::norm

OpenGL norm transformation matrix on last render pass.

◆ shadow_view

Eigen::Matrix4f igl::opengl::ViewerCore::shadow_view

OpenGL shadow_view transformation matrix on last render pass.

◆ shadow_proj

Eigen::Matrix4f igl::opengl::ViewerCore::shadow_proj

OpenGL shadow_proj transformation matrix on last render pass.


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