47 std::set< ref<Renderable> > ren;
48 std::set< ref<Actor> > act;
49 std::set< ref<Transform> > tr;
50 std::set< ref<Effect> > fx;
51 std::set< ref<Shader> > sh;
52 std::set< ref<RenderState> > rs;
53 std::set< ref<Uniform> > un;
54 std::set< ref<Viewport> > vp;
55 std::set< ref<Camera> > cam;
56 std::set< ref<Object> > misc;
59 std::vector< ref<RenderState> > sortRenderStates(
const std::set<
ref<RenderState> >& rs_set)
61 std::vector< ref<RenderState> > rs;
62 rs.insert( rs.end(), rs_set.begin(), rs_set.end() );
73 std::sort( rs.begin(), rs.end(), rs_less::compare );
77 void expandShader(
Shader* shader, expanded_res&
set)
80 set.sh.insert( shader );
83 for(
size_t i=0; i<shader->
uniforms().size(); ++i)
84 set.un.insert(shader->
uniforms()[i].get());
91 void expandEffect(
Effect* fx, expanded_res&
set)
96 for(
int i=0; i<VL_MAX_EFFECT_LOD; ++i)
100 for(
size_t j=0; j<fx->
lod(i)->size(); ++j)
103 set.sh.insert( shader );
104 expandShader(shader,
set);
110 void expandActor(
Actor* actor, expanded_res&
set)
113 set.act.insert( actor );
119 for(
size_t i=0; i<actor->
uniforms().size(); ++i)
120 set.un.insert(actor->
uniforms()[i].get());
122 for(
int i=0; i<VL_MAX_ACTOR_LOD; ++i)
124 set.ren.insert( actor->
lod(i) );
127 expandEffect(actor->
effect(),
set);
136 for(
size_t i=0; i<db->
resources().size(); ++i)
140 if( res->isOfType( Renderable::Type() ) )
143 if( res->isOfType( Actor::Type() ) )
144 expandActor(res->
as<
Actor>(),
set);
146 if( res->isOfType( Transform::Type() ) )
149 if( res->isOfType( Effect::Type() ) )
150 expandEffect( res->
as<
Effect>(), set );
152 if( res->isOfType( Shader::Type() ) )
153 expandShader( res->
as<
Shader>(), set );
155 if( res->isOfType( RenderState::Type() ) )
158 if( res->isOfType( Uniform::Type() ) )
161 if( res->isOfType( Viewport::Type() ) )
164 if( res->isOfType( Camera::Type() ) )
167 set.cam.insert( camera );
169 set.vp.insert( camera->
viewport() );
174 set.misc.insert( res );
182 std::vector< ref<RenderState> > sorted_rs = sortRenderStates(
set.rs );
Associates a Renderable object to an Effect and Transform.
const Renderable * lod(int lod_index) const
Returns the Renderable object representing the LOD level specifed by lod_index.
const std::vector< ref< Uniform > > & uniforms() const
Equivalent to getUniformSet()->uniforms()
Transform * transform()
Returns the Transform bound tho an Actor.
const Transform * boundTransform() const
Returns the Transform bound to a camera.
const std::vector< ref< Uniform > > & uniforms() const
Equivalent to gocUniformSet()->uniforms(...)
const UniformSet * getUniformSet() const
Returns the installed UniformSet.
size_t renderStatesCount() const
Viewport * viewport()
The viewport bound to a camera.
Visualization Library main namespace.
VLGRAPHICS_EXPORT void expandResourceDatabase(ResourceDatabase *db)
Extracts and sorts Shaders, Effects, Renderables, RenderStates, Transforms etc. from their parent obj...
Base class for most of the OpenGL render state wrapper classes.
const std::vector< ref< Object > > & resources() const
The base class for all the reference counted objects.
An abstract class that represents all the objects that can be rendered.
Implements the viewport and clearing settings associated to a Camera.
T * as()
Casts an Object to the specified class.
Manages most of the OpenGL rendering states responsible of the final aspect of the rendered objects...
Defines the sequence of Shader objects used to render an Actor.
Effect * effect()
Returns the Effect bound to an Actor.
UniformSet * getUniformSet()
Returns the UniformSet installed.
RenderStateSet * getRenderStateSet()
The ref<> class is used to reference-count an Object.
virtual ERenderState type() const
Represents a virtual camera defining, among other things, the point of view from which scenes can be ...
const RenderStateSlot * renderStates() const
The ResourceDatabase class contains and manipulates a set of resources.
const ref< ShaderPasses > & lod(int lod_level) const
Returns the ShaderPasses representing the specified LOD level.