1#include "cone_renderer.h"
2#include <cgv_gl/gl/gl.h>
3#include <cgv_gl/gl/gl_tools.h>
8 static int ref_count = 0;
26 remove_attribute_array(ctx,
"radius");
40 bool cone_renderer::set_albedo_texture(
texture* tex) {
46 bool cone_renderer::set_density_texture(texture* tex) {
47 if(!tex || tex->get_nr_dimensions() != 3)
49 density_texture = tex;
66 if(crs.enable_texturing && !albedo_texture)
69 if(crs.enable_ambient_occlusion && !density_texture)
72 if(crs.enable_ambient_occlusion) {
89 albedo_texture->
enable(ctx, 0);
91 if(density_texture) density_texture->
enable(ctx, 1);
97 if(albedo_texture) albedo_texture->
disable(ctx);
98 if(density_texture) density_texture->
disable(ctx);
113 draw_impl(ctx, PT_LINES, start, count, use_strips, use_adjacency, strip_restart_index);
118 albedo_texture =
nullptr;
119 density_texture =
nullptr;
128#include <cgv/gui/provider.h>
136 void* value_ptr,
const std::string& value_type,
137 const std::string& gui_type,
const std::string& options,
bool*) {
143 p->
add_member_control(b,
"Default Radius", crs_ptr->
radius,
"value_slider",
"min=0.001;step=0.0001;max=10.0;log=true;ticks=true");
149 if(p->
begin_tree_node(
"Texturing", crs_ptr->enable_texturing,
false,
"level=3")) {
152 p->
add_member_control(b,
"Blend Mode", crs_ptr->texture_blend_mode,
"dropdown",
"enums='Mix,Tint,Multiply,Inverse Multiply,Add'");
153 p->
add_member_control(b,
"Blend Factor", crs_ptr->texture_blend_factor,
"value_slider",
"min=0.0;step=0.0001;max=1.0;ticks=true");
155 p->
add_member_control(b,
"Tile from Center", crs_ptr->texture_tile_from_center,
"check");
157 p->
add_member_control(b,
"Offset", crs_ptr->texture_offset[0],
"value",
"w=95;min=-1;max=1;step=0.001",
" ");
158 p->
add_member_control(b,
"", crs_ptr->texture_offset[1],
"value",
"w=95;min=-1;max=1;step=0.001");
159 p->
add_member_control(b,
"", crs_ptr->texture_offset[0],
"slider",
"w=95;min=-1;max=1;step=0.001;ticks=true",
" ");
160 p->
add_member_control(b,
"", crs_ptr->texture_offset[1],
"slider",
"w=95;min=-1;max=1;step=0.001;ticks=true");
162 p->
add_member_control(b,
"Tiling", crs_ptr->texture_tiling[0],
"value",
"w=95;min=-5;max=5;step=0.001",
" ");
163 p->
add_member_control(b,
"", crs_ptr->texture_tiling[1],
"value",
"w=95;min=-5;max=5;step=0.001");
164 p->
add_member_control(b,
"", crs_ptr->texture_tiling[0],
"slider",
"w=95;min=-5;max=5;step=0.001;ticks=true",
" ");
165 p->
add_member_control(b,
"", crs_ptr->texture_tiling[1],
"slider",
"w=95;min=-5;max=5;step=0.001;ticks=true");
167 p->
add_member_control(b,
"Use Reference Length", crs_ptr->texture_use_reference_length,
"check");
168 p->
add_member_control(b,
"Reference Length", crs_ptr->texture_reference_length,
"value_slider",
"min=0.0;step=0.0001;max=5.0;log=true;ticks=true");
174 if(p->
begin_tree_node(
"Ambient Occlusion", crs_ptr->enable_ambient_occlusion,
false,
"level=3")) {
177 p->
add_member_control(b,
"Offset", crs_ptr->ao_offset,
"value_slider",
"min=0.0;step=0.0001;max=0.2;log=true;ticks=true");
178 p->
add_member_control(b,
"Distance", crs_ptr->ao_distance,
"value_slider",
"min=0.0;step=0.0001;max=1.0;log=true;ticks=true");
179 p->
add_member_control(b,
"Strength", crs_ptr->ao_strength,
"value_slider",
"min=0.0;step=0.0001;max=10.0;log=true;ticks=true");
188#include "gl/lib_begin.h"
base class for all classes that can be registered with support for dynamic properties (see also secti...
helper template for registration of gui creators
derive from this class to provide a gui to the current viewer
bool add_gui(const std::string &label, T &value, const std::string &gui_type="", const std::string &options="")
Add a composed gui of the given gui_type for the given value.
void align(const std::string &_align)
send pure alignment information
bool begin_tree_node(const std::string &label, const T &value, bool initial_visibility=false, const std::string &options="", gui_group_ptr ggp=gui_group_ptr())
Begin a sub tree of a tree structured gui.
data::ref_ptr< control< T > > add_member_control(cgv::base::base *base_ptr, const std::string &label, T &value, const std::string &gui_type="", const std::string &options="", const std::string &align="\n")
add control with callback to cgv::base::on_set method on cgv::gui::control::value_change
void end_tree_node(const T &value)
template specialization that allows to specify value reference plus node_instance by using the result...
the self reflection handler is passed to the virtual self_reflect() method of cgv::base::base.
bool reflect_base(B &base_ref)
reflect a base class with its members
bool reflect_member(const std::string &member_name, T &member_ref, bool hard_cast=false)
call this to reflect a member by member name and reference to the member.
attribute array manager used to upload arrays to gpu
renderer that supports raycasting of cones
void clear(const context &ctx) override
the clear function destructs the shader program and resets the texture pointers
void update_shader_program_options(shader_compile_options &options) const override
update shader program compile options based on render style
void draw(context &ctx, size_t start, size_t count, bool use_strips=false, bool use_adjacency=false, uint32_t strip_restart_index=-1) override
convenience function to render with default settings
bool enable(context &ctx) override
enables renderer
bool validate_attributes(const context &ctx) const override
call to validate, whether essential position attribute is defined
void disable_attribute_array_manager(const context &ctx, attribute_array_manager &aam) override
call this after last render/draw call to ensure that no other users of renderer change attribute arra...
bool disable(context &ctx) override
disable renderer
void enable_attribute_array_manager(const context &ctx, attribute_array_manager &aam) override
call this before setting attribute arrays to manage attribute array in given manager
void remove_radius_array(const context &ctx)
remove the radius attribute
base class for all drawables, which is independent of the used rendering API.
bool validate_attributes(const context &ctx) const
check additionally the group attributes
void manage_singleton(context &ctx, const std::string &renderer_name, int &ref_count, int ref_count_change)
used by derived classes to manage singletons
bool has_attribute(const context &ctx, const std::string &name)
check for attribute
shader_program & ref_prog()
derived renderer classes have access to shader program
virtual void clear(const context &ctx)
the clear function destructs the shader program
bool attributes_persist() const
return whether attributes persist after a call to disable
void draw_impl(context &ctx, PrimitiveType pt, size_t start, size_t count, bool use_strips=false, bool use_adjacency=false, uint32_t strip_restart_index=-1)
default implementation of draw method with support for indexed rendering and different primitive type...
Stores preprocessor options used for conditionally compiling shader programs.
void define_macro_if_true(bool predicate, const std::string &identifier)
Conditionally define identifier as a macro with replacement text 1.
bool set_uniform(const context &ctx, const std::string &name, const T &value, bool generate_error=false)
Set the value of a uniform by name, where the type can be any of int, unsigned, float,...
bool set_uniform_array(const context &ctx, const std::string &name, const T &array)
set uniform array from array array where number elements can be derived from array through array_desc...
bool set_attribute(const context &ctx, const std::string &name, const T &value)
set constant default value of a vertex attribute by attribute name, if name does not specify an attri...
void enable_attribute_array_manager(const context &ctx, attribute_array_manager &aam) override
call this before setting attribute arrays to manage attribute array in given manager
void disable_attribute_array_manager(const context &ctx, attribute_array_manager &aam) override
call this after last render/draw call to ensure that no other users of renderer change attribute arra...
bool enable(context &ctx) override
overload to activate group style
bool disable(context &ctx) override
disable renderer
the texture class encapsulates all functionality independent of the rendering api.
bool disable(const context &ctx)
disable texture and restore state from before last enable call
bool enable(const context &ctx, int tex_unit=-1)
enable this texture in the given texture unit, -1 corresponds to the current unit.
cone_renderer & ref_cone_renderer(context &ctx, int ref_count_change)
reference to a singleton cone renderer that is shared among drawables
bool create(provider *p, const std::string &label, void *value_ptr, const std::string &value_type, const std::string &gui_type, const std::string &options, bool *)
attempt to create a gui and return whether this was successful
interface for gui creators
this reflection traits implementation is used for external self_reflect implementations of instances ...
float radius
default value assigned to radius attribute in enable method of cone renderer
float radius_scale
multiplied to the cone radii
traits class with a static function get_name() of type const char* that returns the type name of the ...