zMol
A viewer for molecular data using OpenGL and ambient occlusion
|
#include <molecule_renderer.hpp>
Inherits zmol::noncopyable_::noncopyable.
Public Types | |
enum | rendering_modes { rendering_mode_space_filling, rendering_mode_balls_and_sticks, rendering_mode_licorice } |
enum | atom_color_modes { atom_color_mode_per_element, atom_color_mode_per_chain } |
typedef cml::matrix44f_c | matrix |
Public Member Functions | |
molecule_renderer (molecule_shaders &p_molecule_shaders, molecule_data const &p_data, unsigned int const p_initial_left_viewport_offset, unsigned int const p_initial_top_viewport_offset, unsigned int const p_initial_viewport_width, unsigned int const p_initial_viewport_height, unsigned int const p_initial_atlas_size, float const p_initial_radius_scale=1.0f, rendering_modes const p_initial_rendering_mode=rendering_mode_space_filling, atom_color_modes const p_initial_atom_color_mode=atom_color_mode_per_element) | |
molecule_renderer (molecule_shaders &p_molecule_shaders, molecule_data &&p_data, unsigned int const p_initial_left_viewport_offset, unsigned int const p_initial_top_viewport_offset, unsigned int const p_initial_viewport_width, unsigned int const p_initial_viewport_height, unsigned int const p_initial_atlas_size, float const p_initial_radius_scale=1.0f, rendering_modes const p_initial_rendering_mode=rendering_mode_space_filling, atom_color_modes const p_initial_atom_color_mode=atom_color_mode_per_element) | |
void | set_rendering_mode (rendering_modes const p_new_rendering_mode) |
void | set_atom_color_mode (atom_color_modes const p_new_atom_color_mode) |
void | set_viewport (unsigned int const p_new_left_viewport_offset, unsigned int const p_new_top_viewport_offset, unsigned int const p_new_viewport_width, unsigned int const p_new_viewport_height) |
void | set_radius_scale (float const p_new_radius_scale) |
void | set_border_width (float const p_new_border_width) |
void | set_border_variance (float const p_new_border_variance) |
void | set_ao_strength (float const p_new_ao_strength) |
void | set_direct_lighting_strength (float const p_new_direct_lighting_strength) |
void | set_shininess (float const p_new_shininess) |
void | set_glossiness (float const p_new_glossiness) |
void | set_flatness (float const p_new_flatness) |
void | set_atlas_size (unsigned int const p_new_atlas_size) |
void | render (cml::quaternionf const &p_rotation) |
matrix const & | get_projection () const |
Class for rendering molecule data.
This class takes molecule_data input, creates impostor geometry data out of it, and renders said impostors. In addition, it calculates ambient occlusion, and stores the results in a texture atlas.
The renderer uses its own orthogonal projection matrix, and paints into a designated viewport region. It is not possible to use a custom projection matrix.
The class is not stateless, but mostly immutable; no other molecule_data can be passed to it after construction. Certain parameters, such as the atlas texture size, the screen size, the rendering mode, are mutable.
typedef cml::matrix44f_c zmol::molecule_renderer::matrix |
4x4 matrix type.
Rendering modes.
|
explicit |
Constructor.
Creates the impostor geometry out of the molecule structure information described by p_data, sets the initial viewport, and calculates the ambient occlusion, whose results are stored in a texture atlas. It uses a molecule_data instance as input. The molecule_data structure referred to by p_data is copied internally, so the referred structure can be destroyed safely after the constructor was executed.
p_molecule_shaders | Shaders structure to use for rendering |
p_data | Input molecule data; an internal copy of it is made by the constructor |
p_initial_left_viewport_offset | Initial left viewport offset |
p_initial_top_viewport_offset | Initial top viewport offset |
p_initial_viewport_width | Initial viewport width |
p_initial_viewport_height | Initial viewport height |
p_initial_atlas_size | Initial texture atlas size (= sidelength; the atlas texture is always a square) |
p_initial_radius_scale | Initial molecule scale, default value 1.0f (= 100%) |
p_initial_rendering_mode | Initial rendering mode, default mode is rendering_mode_space_filling |
p_initial_atom_color_mode | Initial color mode, default mode is atom_color_mode_per_element |
|
explicit |
Constructor.
Creates the impostor geometry out of the molecule structure information described by p_data, sets the initial viewport, and calculates the ambient occlusion, whose results are stored in a texture atlas. It uses a molecule_data instance as input. The molecule_data structure referred to by p_data is moved to an internal instance; after the constructor ran, do not use the referred to by p_data anymore.
p_molecule_shaders | Shaders structure to use for rendering |
p_data | Input molecule data; its contents are moved to an internal molecule_data instance (see C++11 move semantics) |
p_initial_left_viewport_offset | Initial left viewport offset |
p_initial_top_viewport_offset | Initial top viewport offset |
p_initial_viewport_width | Initial viewport width |
p_initial_viewport_height | Initial viewport height |
p_initial_atlas_size | Initial atlas texture size (= sidelength; the atlas texture is always a square) |
p_initial_radius_scale | Initial molecule scale, default value 1.0f (= 100%) |
p_initial_rendering_mode | Initial rendering mode, default mode is rendering_mode_space_filling |
p_initial_atom_color_mode | Initial color mode, default mode is atom_color_mode_per_element |
|
inline |
Retrieves the current projection matrix.
void zmol::molecule_renderer::render | ( | cml::quaternionf const & | p_rotation | ) |
Renders one frame into the current viewport.
p_rotation | Rotation quaternion to use as the molecule rendering's rotation. |
void zmol::molecule_renderer::set_ao_strength | ( | float const | p_new_ao_strength | ) |
Sets the ambient occlusion strength.
p_new_ao_strength | The new ambient occlusion strength to use. |
void zmol::molecule_renderer::set_atlas_size | ( | unsigned int const | p_new_atlas_size | ) |
Sets the atlas texture size.
p_new_atlas_size | The new atlas texture size (= sidelength; the atlas texture is always a square) |
void zmol::molecule_renderer::set_atom_color_mode | ( | atom_color_modes const | p_new_atom_color_mode | ) |
Sets the current atom color mode.
This call reinitialozes the impostor geometry, but does not recalculate the ambient occlusion (since it would not change). If p_new_atom_color_mode equals the currently set atom color mode, this call does nothing.
p_new_atom_color_mode | New atom color mode to use |
void zmol::molecule_renderer::set_border_variance | ( | float const | p_new_border_variance | ) |
Sets the border variance.
p_new_border_variance | The new border variance to use. Minimum valid value is 0.0f. |
void zmol::molecule_renderer::set_border_width | ( | float const | p_new_border_width | ) |
Sets the border width.
p_new_border_width | The new border width to use. Minimum valid value is 0.0f (= no border). |
void zmol::molecule_renderer::set_direct_lighting_strength | ( | float const | p_new_direct_lighting_strength | ) |
Sets the direct lighting strength.
p_new_direct_lighting_strength | The new direct lighting strength to use. |
void zmol::molecule_renderer::set_flatness | ( | float const | p_new_flatness | ) |
Sets the flatness.
p_new_flatness | The new flatness to use. |
void zmol::molecule_renderer::set_glossiness | ( | float const | p_new_glossiness | ) |
Sets the glossiness.
p_new_glossiness | The new glossiness to use. |
void zmol::molecule_renderer::set_radius_scale | ( | float const | p_new_radius_scale | ) |
Sets the radiu´s scale.
p_new_radius_scale | The new relative scale to use. 1.0f means 100% (= the original radius scale). |
void zmol::molecule_renderer::set_rendering_mode | ( | rendering_modes const | p_new_rendering_mode | ) |
Sets the current rendering mode.
This call reinitializes the impostor geometry appropiately, and also recalculates the ambient occlusion. If p_new_rendering_mode equals the currently set rendering mode, this call does nothing.
p_new_rendering_mode | New rendering mode to use |
void zmol::molecule_renderer::set_shininess | ( | float const | p_new_shininess | ) |
Sets the shininess.
p_new_shininess | The new shininess to use. |
void zmol::molecule_renderer::set_viewport | ( | unsigned int const | p_new_left_viewport_offset, |
unsigned int const | p_new_top_viewport_offset, | ||
unsigned int const | p_new_viewport_width, | ||
unsigned int const | p_new_viewport_height | ||
) |
Sets the current viewport.
It does not impostor geometry and ambient occlusion data intact, so it is safe to call this often, for example, when a rendering window gets resized by the user.
p_new_left_viewport_offset | New left viewport offset |
p_new_top_viewport_offset | New top viewport offset |
p_new_viewport_width | New viewport width |
p_new_viewport_height | New viewport height |