Developer Documentation
|
#include <ACG/Scenegraph/BaseNode.hh>
Classes | |
struct | ShaderSet |
Public Types | |
enum | StatusMode { Active = 0x1, HideNode = 0x2, HideChildren = 0x4, HideSubtree = 0x8 } |
Status modi. More... | |
enum | TraverseMode { NodeFirst = 0x1, ChildrenFirst = 0x2, SecondPass = 0x4 } |
Node traverse types. More... | |
typedef std::vector< BaseNode * >::const_iterator | ConstChildIter |
allows to iterate over children | |
typedef std::vector< BaseNode * >::iterator | ChildIter |
allows to iterate over children | |
typedef std::vector< BaseNode * >::const_reverse_iterator | ConstChildRIter |
allows to reverse iterate over children | |
typedef std::vector< BaseNode * >::reverse_iterator | ChildRIter |
allows to reverse iterate over children | |
Public Member Functions | |
BaseNode (BaseNode *_parent=0, std::string _name="<unknown>") | |
Default constructor. | |
BaseNode (BaseNode *_parent, BaseNode *_child, std::string _name="<unknown>") | |
Put this node between _parent and _child. | |
virtual | ~BaseNode () |
Destructor. | |
void | delete_subtree () |
Delete the whole subtree of this node. More... | |
virtual const std::string & | className () const =0 |
Return class name (implemented by the ACG_CLASSNAME macro) | |
virtual DrawModes::DrawMode | availableDrawModes () const |
virtual void | boundingBox (Vec3d &, Vec3d &) |
virtual void | enter (GLState &, const DrawModes::DrawMode &) |
virtual void | enter (IRenderer *, GLState &_state, const DrawModes::DrawMode &_drawMode) |
virtual void | draw (GLState &, const DrawModes::DrawMode &) |
Draw this node using the draw modes _drawMode. More... | |
virtual void | getRenderObjects (IRenderer *_renderer, GLState &_state, const DrawModes::DrawMode &_drawMode, const Material *_mat) |
Deferred draw call with shader based renderer. More... | |
virtual void | leave (GLState &, const DrawModes::DrawMode &) |
virtual void | leave (IRenderer *, GLState &_state, const DrawModes::DrawMode &_drawMode) |
virtual void | enterPick (GLState &_state, PickTarget _target, const DrawModes::DrawMode &_drawMode) |
virtual void | pick (GLState &, PickTarget) |
virtual void | leavePick (GLState &_state, PickTarget _target, const DrawModes::DrawMode &_drawMode) |
void | enablePicking (bool _enable) |
bool | pickingEnabled () |
virtual void | mouseEvent (GLState &, QMouseEvent *) |
Handle mouse event (some interaction, e.g. modeling) | |
void | setDirty (bool _dirty=true) |
mark node for redrawn | |
bool | isDirty () const |
Check if node should be redrawn. | |
ChildIter | childrenBegin () |
Returns: begin-iterator of children. | |
ConstChildIter | childrenBegin () const |
Same but cont . | |
ChildIter | childrenEnd () |
Returns: end-iterator of children. | |
ConstChildIter | childrenEnd () const |
Same but const . | |
ChildRIter | childrenRBegin () |
Returns: reverse begin-iterator of children. | |
ConstChildRIter | childrenRBegin () const |
Same but const. | |
ChildRIter | childrenREnd () |
Returns: reverse end-iterator of children. | |
ConstChildRIter | childrenREnd () const |
Same but const . | |
void | push_back (BaseNode *_node) |
Insert _node at the end of the list of children. | |
void | remove (ChildIter _pos) |
size_t | nChildren () const |
number of children | |
ChildIter | find (BaseNode *_node) |
BaseNode * | find (const std::string &_name) |
BaseNode * | parent () |
Get the nodes parent node. | |
const BaseNode * | parent () const |
Get the nodes parent node. | |
void | set_parent (BaseNode *_parent) |
Set the parent of this node. More... | |
StatusMode | status () const |
Get node's status. | |
void | set_status (StatusMode _s) |
Set the status of this node. | |
void | hide () |
Hide Node: set status to HideNode. | |
void | show () |
Show node: set status to Active. | |
bool | visible () |
Is node visible (status == Active)? | |
bool | hidden () |
Is node not visible (status != Active)? | |
std::string | name () const |
Returns: name of node (needs not be unique) | |
void | name (const std::string &_name) |
rename a node | |
unsigned int | id () const |
DrawModes::DrawMode | drawMode () const |
Return the own draw modes of this node. | |
void | drawMode (DrawModes::DrawMode _drawMode) |
unsigned int | traverseMode () const |
Return how the node should be traversed. | |
void | setTraverseMode (unsigned int _mode) |
Set traverse mode for node. | |
Private Member Functions | |
BaseNode (const BaseNode &) | |
Copy constructor. Disabled. | |
void | operator= (const BaseNode &) |
Assignment operator. Disabled. | |
Private Attributes | |
BaseNode * | parent_ |
pointer to parent node | |
std::string | name_ |
name of node | |
StatusMode | status_ |
node status() | |
std::vector< BaseNode * > | children_ |
list of children | |
unsigned int | id_ |
ID of node. | |
DrawModes::DrawMode | drawMode_ |
private draw mode | |
bool | pickingEnabled_ |
bool | dirty_ |
Flag indicating that the node has to be redrawn. | |
unsigned int | traverseMode_ |
traverse mode | |
std::map< DrawModes::DrawModePrimitive, ShaderSet > | shaderSettings_ |
shader settings for primitive modes | |
std::map< int, RenderObject::Texture > | textureSettings_ |
texture settings for shader based rendering | |
const GLSL::UniformPool * | uniformPool_ |
user provided uniform pool for shader constants | |
RenderObjectModifier * | renderModifier_ |
render-object modifier | |
Static Private Attributes | |
static unsigned int | last_id_used__ |
used to provide unique IDs to nodes | |
Render pass controls | |
The render pass controls are only used during multipass traversal. There are two types of multipass controls. One type controls if the enter and leave functions of the nodes are used (RenderStatusPass) or if the actual draw function is called (RenderDrawPass). The bitmasks define if the functions are called by the traverse_multipass operation. The bitmask are initialized to run in the first path. | |
enum | PASSES { NOPASS = 0, ALLPASSES = 1 << 0, PASS_1 = 1 << 1, PASS_2 = 1 << 2, PASS_3 = 1 << 3, PASS_4 = 1 << 4, PASS_5 = 1 << 5, PASS_6 = 1 << 6, PASS_7 = 1 << 7, PASS_8 = 1 << 8 } |
This enum should be used to enable rendering of a node in different. | |
typedef unsigned int | MultipassBitMask |
Multipass pass bit mask type. | |
MultipassBitMask | multipassStatus () const |
Get the current multipass settings for the nodes status functions. More... | |
void | setMultipassStatus (const MultipassBitMask _passStatus) |
Set multipass settings for the nodes status functions. More... | |
void | multipassStatusSetActive (const unsigned int _i, bool _active) |
Set multipass status to traverse in a specific pass. More... | |
bool | multipassStatusActive (const unsigned int _i) const |
Get multipass status to traverse in a specific pass. More... | |
MultipassBitMask | multipassNode () const |
Get the current multipass settings for the node. More... | |
void | setMultipassNode (const MultipassBitMask _passNode) |
Set multipass settings for the node. More... | |
void | multipassNodeSetActive (const unsigned int _i, bool _active) |
Set Node status to traverse in a specific pass. More... | |
bool | multipassNodeActive (const unsigned int _i) const |
Get Node status to traverse in a specific pass. More... | |
RenderObject controls | |
The render pass controls are only used during shader-based rendering with render-objects. It is possible to provide shader and state settings that are copied to render-objects. These functions do not affect the fixed-function pipeline implementation of the scenegraph (enter() draw() leave()). | |
MultipassBitMask | multipassStatus_ |
MultipassBitMask | multipassNode_ |
void | setRenderObjectShaders (const std::string &_vertexShaderFile, const std::string &_geometryShaderFile, const std::string &_fragmentShaderFile, bool _relativePaths=true, DrawModes::DrawModePrimitive _primitiveType=DrawModes::PRIMITIVE_POLYGON) |
Set custom shaders. More... | |
void | setRenderObjectShaders (const std::string &_vertexShaderFile, const std::string &_tessControlShaderFile, const std::string &_tessEvalShaderFile, const std::string &_geometryShaderFile, const std::string &_fragmentShaderFile, bool _relativePaths=true, DrawModes::DrawModePrimitive _primitiveType=DrawModes::PRIMITIVE_POLYGON) |
Set custom shaders. More... | |
void | setRenderObjectUniformPool (const GLSL::UniformPool *_pool) |
Set uniforms for shader based rendering. More... | |
const GLSL::UniformPool * | getRenderObjectUniformPool () |
Get uniforms for shader based rendering. More... | |
void | setRenderObjectTexture (int _samplerSlot, GLuint _texId, GLenum _texType=GL_TEXTURE_2D) |
Set textures for shader based rendering. More... | |
void | setRenderObjectModifier (RenderObjectModifier *_modifier) |
Set modifier for render objects. More... | |
RenderObjectModifier * | getRenderObjectModifier () |
Get render-object modifier. More... | |
void | applyRenderObjectSettings (DrawModes::DrawModePrimitive _primitive, RenderObject *_obj) const |
Set shaders, textures and uniforms as provided by user to a render-object. More... | |
This is the base for all scenegraph nodes. All virtual functions should be reimplemented when inheriting from this class.
Definition at line 104 of file BaseNode.hh.
Status modi.
Enumerator | |
---|---|
Active | Draw node & children. |
HideNode | Hide this node, but draw children. |
HideChildren | Draw this node, but hide children. |
HideSubtree | Hide this node and its children. |
Definition at line 389 of file BaseNode.hh.
Node traverse types.
Enumerator | |
---|---|
NodeFirst | Execute action on node first and then on its children. |
ChildrenFirst | Execute action the children first and then on this node. |
SecondPass | Draw node in second pass. |
Definition at line 438 of file BaseNode.hh.
void ACG::SceneGraph::BaseNode::applyRenderObjectSettings | ( | DrawModes::DrawModePrimitive | _primitive, |
RenderObject * | _obj | ||
) | const |
Set shaders, textures and uniforms as provided by user to a render-object.
A derived node can use this convenience function to copy shader, uniform and texture settings to a render-object.
_primitive | the primitive type of the render-object |
_obj | the render-object [in/out] |
|
inlinevirtual |
Return a list of available draw modes for this node: should be OR'ed from the items of the enum DrawModeIDs.
Reimplemented in PlaneNode.
Definition at line 136 of file BaseNode.hh.
Compute the bounding box of this node and update the values _bbMin and _bbMax accordingly. Do not initialize _bbMin and _bbMax since they may already store values of previous nodes' bounding box computation.
Reimplemented in PlaneNode.
Definition at line 143 of file BaseNode.hh.
void ACG::SceneGraph::BaseNode::delete_subtree | ( | ) |
Delete the whole subtree of this node.
This function will remove the whole subtree below this node. All children in this nodes bubtree will be automatically removed from the tree and their destructor is called. The node itself will be removed from the list of its parents children. Afterwards it will also call its own destructor.
|
inlinevirtual |
Draw this node using the draw modes _drawMode.
This function is called when the scenegraph is traversed by the classical draw routines.
In this call the node should draw it's content via OpenGL.
Reimplemented in PlaneNode.
Definition at line 192 of file BaseNode.hh.
|
inline |
Set this node's own draw mode. It will be used for drawing instead of the the global draw mode.
Definition at line 433 of file BaseNode.hh.
|
inline |
Enable or Disable picking for this node ( default: enabled )
Definition at line 265 of file BaseNode.hh.
|
inlinevirtual |
This function is called when traversing the scene graph and arriving at this node. It can be used to store GL states that will be changed in order to restore then in the leave() function.
There are two overloads of the enter() function, one with IRenderer* parameter, the other one without. As long the overload with IRenderer* parameter is not being overridden, all renderers will make use of the overload without the IRenderer* parameter. If the overload with IRenderer* parameter is being overridden, only legacy renderers will use the version without the additional parameter and new renderers implementing the IRenderer interface will use the version with the additional parameter.
Definition at line 160 of file BaseNode.hh.
|
inlinevirtual |
This function is called when traversing the scene graph and arriving at this node. It can be used to store GL states that will be changed in order to restore then in the leave() function.
If you do not need the IRenderer* argument in your override of this function, simply use the override without the additional parameter.
There are two overloads of the enter() function, one with IRenderer* parameter, the other one without. As long the overload with IRenderer* parameter is not being overridden, all renderers will make use of the overload without the IRenderer* parameter. If the overload with IRenderer* parameter is being overridden, only legacy renderers will use the version without the additional parameter and new renderers implementing the IRenderer interface will use the version with the additional parameter.
Definition at line 178 of file BaseNode.hh.
|
virtual |
This function is called when traversing the scene graph during picking and arriving at this node. It can be used to store GL states that will be changed in order to restore then in the leavePick() function. Its default implementation will call the enter() function.
Find a specific node in the list of children.
This method is designed to convert a node pointer to an iterator that may be used e.g. for insert()'ing a new node at a distinct position.
Returns childrenEnd() if no appropriate node is found.
Definition at line 346 of file BaseNode.hh.
|
inline |
Find a node of a given name
Definition at line 355 of file BaseNode.hh.
|
inline |
Get render-object modifier.
Definition at line 670 of file BaseNode.hh.
|
inlinevirtual |
Deferred draw call with shader based renderer.
The renderer calls this function to collect the geometry that should be rendered from the nodes.
Add any renderable geometry to the renderer via _renderer->addRenderObject()
The material is fetched from the last active material node and may be used to setup Renderobjects, but may as well be ignored.
_renderer | The renderer which will be used. Add your geometry into this class |
_state | The current GL State when this object is called |
_drawMode | The active draw mode |
_mat | Current material |
Reimplemented in PlaneNode.
Definition at line 210 of file BaseNode.hh.
|
inline |
Get uniforms for shader based rendering.
Definition at line 641 of file BaseNode.hh.
|
inline |
Get unique ID of node. IDs are always positive and may be used e.g. for picking.
Definition at line 423 of file BaseNode.hh.
|
inlinevirtual |
The leave function is used to restore GL states the have been changed. This function must restore the status before enter()!
There are two overloads of the leave() function, one with IRenderer* parameter, the other one without. As long the overload with IRenderer* parameter is not being overridden, all renderers will make use of the overload without the IRenderer* parameter. If the overload with IRenderer* parameter is being overridden, only legacy renderers will use the version without the additional parameter and new renderers implementing the IRenderer interface will use the version with the additional parameter.
Definition at line 223 of file BaseNode.hh.
|
inlinevirtual |
The leave function is used to restore GL states the have been changed. This function must restore the status before enter()!
If you do not need the IRenderer* argument in your override of this function, simply use the override without the additional parameter.
There are two overloads of the leave() function, one with IRenderer* parameter, the other one without. As long the overload with IRenderer* parameter is not being overridden, all renderers will make use of the overload without the IRenderer* parameter. If the overload with IRenderer* parameter is being overridden, only legacy renderers will use the version without the additional parameter and new renderers implementing the IRenderer interface will use the version with the additional parameter.
Definition at line 239 of file BaseNode.hh.
|
virtual |
The leavePick function is used to restore GL states the have been changed. This function must restore the status before enterPick() ! Its default implementation will call the leave() function.
|
inline |
Get the current multipass settings for the node.
Get a bitmask defining in which traverse path an action is applied to the node. (1-indexed) Use the PASSES enum above to control multipass rendering!
Definition at line 537 of file BaseNode.hh.
bool ACG::SceneGraph::BaseNode::multipassNodeActive | ( | const unsigned int | _i | ) | const |
Get Node status to traverse in a specific pass.
Check multipass setting for the node if an action will be applied in the given pass. Use the PASSES enum above to control multipass rendering!
_i | Check this pass if an action will be applied to the node. |
void ACG::SceneGraph::BaseNode::multipassNodeSetActive | ( | const unsigned int | _i, |
bool | _active | ||
) |
Set Node status to traverse in a specific pass.
Change multipass setting for the node. An action will be applied to this node in the given pass. Use the PASSES enum above to control multipass rendering!
_i | Pass in which the node should be rendered |
_active | Enable or disable node in this pass? |
|
inline |
Get the current multipass settings for the nodes status functions.
Get a bitmask defining in which traverse pass the enter and leave nodes are used. Use the PASSES enum above to control multipass rendering!
Definition at line 493 of file BaseNode.hh.
bool ACG::SceneGraph::BaseNode::multipassStatusActive | ( | const unsigned int | _i | ) | const |
Get multipass status to traverse in a specific pass.
Check multipass setting for the nodes status functions if they should be called in the given render pass. Use the PASSES enum above to control multipass rendering!
_i | Check this pass if the nodes enter/leave functions are active |
void ACG::SceneGraph::BaseNode::multipassStatusSetActive | ( | const unsigned int | _i, |
bool | _active | ||
) |
Set multipass status to traverse in a specific pass.
Change multipass setting for the nodes status functions. The node will call its enter and leave functions in the given pass if its set active. Use the PASSES enum above to control multipass rendering!
_i | Pass in which the node should be rendered |
_active | Activate or deactivate in this pass? |
|
inlinevirtual |
Draw the node using the GL picking name stack. The node's ID will already be on the name stack, so only names identifying e.g. faces should be used ( by pick_set_name() ).
Reimplemented in PlaneNode.
Definition at line 254 of file BaseNode.hh.
|
inline |
Check if picking is enabled for this node
Definition at line 269 of file BaseNode.hh.
|
inline |
Remove child node at position _pos. This _pos must be reachable from childrenBegin().
This method has no effect if called with childrenEnd() as parameter.
Definition at line 330 of file BaseNode.hh.
void ACG::SceneGraph::BaseNode::set_parent | ( | BaseNode * | _parent | ) |
Set the parent of this node.
This function will remove this node from its original parents children, if the parent exists. And will add it to the new parents children.
|
inline |
Set multipass settings for the node.
Set a bitmask defining in which traverse path an action is applied to the node. (1-indexed) Set to ALLPASSES if you want to render in all passes. Use the PASSES enum above to control multipass rendering!
_passNode | Bitmask defining in which traverse passes an action is applied to the node. |
Definition at line 549 of file BaseNode.hh.
|
inline |
Set multipass settings for the nodes status functions.
Set a bitmask defining in which traverse pass the enter and leave nodes are used. Use the PASSES enum above to control multipass rendering!
Set to ALLPASSES if you want to render in all passes
_passStatus | Bitmask defining in which traverse pass the enter and leave nodes are used |
Definition at line 505 of file BaseNode.hh.
|
inline |
Set modifier for render objects.
Render-objects can be modified, if the implementation of a node supports this. The currently active modifier should be applied directly before adding an object to the renderer.
_modifier | pointer to address of modifier, address must be valid whenever the node creates render-objects |
Definition at line 665 of file BaseNode.hh.
void ACG::SceneGraph::BaseNode::setRenderObjectShaders | ( | const std::string & | _vertexShaderFile, |
const std::string & | _geometryShaderFile, | ||
const std::string & | _fragmentShaderFile, | ||
bool | _relativePaths = true , |
||
DrawModes::DrawModePrimitive | _primitiveType = DrawModes::PRIMITIVE_POLYGON |
||
) |
Set custom shaders.
Assigns a set of shaders to a primitive type of a node. For instance, it is possible to render faces with a different shaders than lines. Default shaders are used instead if no other shaders are provided. Note: the derived node has to actually make use of shaders provided here
Example: set shaders in OpenFlipper/Shaders/MyWireShaders for rendering the line parts of a node: node->setRenderobjectShaders("MyWireShaders/v.glsl", "MyWireShaders/g.glsl", "MyWireShaders/f.glsl", true, ACG::SceneGraph::DrawModes::PRIMITIVE_WIREFRAME);
_vertexShaderFile | filename of vertex shader template compatible with ACG::ShaderGenerator |
_geometryShaderFile | filename of geometry shader template compatible with ACG::ShaderGenerator |
_fragmentShaderFile | filename of fragment shader template compatible with ACG::ShaderGenerator |
_relativePaths | filenames are relative or absolute |
_primitiveType | assign shaders to rendering this type of primitive of the polyline |
void ACG::SceneGraph::BaseNode::setRenderObjectShaders | ( | const std::string & | _vertexShaderFile, |
const std::string & | _tessControlShaderFile, | ||
const std::string & | _tessEvalShaderFile, | ||
const std::string & | _geometryShaderFile, | ||
const std::string & | _fragmentShaderFile, | ||
bool | _relativePaths = true , |
||
DrawModes::DrawModePrimitive | _primitiveType = DrawModes::PRIMITIVE_POLYGON |
||
) |
Set custom shaders.
Assigns a set of shaders to a primitive type of a node. For instance, it is possible to render faces with a different shaders than lines. Default shaders are used instead if no other shaders are provided. Note: the derived node has to actually make use of shaders provided here
Example: set shaders in OpenFlipper/Shaders/MyWireShaders for rendering the line parts of a node: node->setRenderObjectShaders("MyWireShaders/v.glsl", "MyWireShaders/g.glsl", "MyWireShaders/f.glsl", true, ACG::SceneGraph::DrawModes::PRIMITIVE_WIREFRAME);
_vertexShaderFile | filename of vertex shader template compatible with ACG::ShaderGenerator |
_tessControlShaderFile | filename of tessellation-control shader template compatible with ACG::ShaderGenerator |
_tessEvalShaderFile | filename of tessellation-eval shader template compatible with ACG::ShaderGenerator |
_geometryShaderFile | filename of geometry shader template compatible with ACG::ShaderGenerator |
_fragmentShaderFile | filename of fragment shader template compatible with ACG::ShaderGenerator |
_relativePaths | filenames are relative or absolute |
_primitiveType | assign shaders to rendering this type of primitive of the polyline |
void ACG::SceneGraph::BaseNode::setRenderObjectTexture | ( | int | _samplerSlot, |
GLuint | _texId, | ||
GLenum | _texType = GL_TEXTURE_2D |
||
) |
Set textures for shader based rendering.
Assign textures to sampler slots. Note: Fixed-function drawing ignores these textures. Also, it is still necessary to set the according sampler index in a UniformPool to access this texture in a shader.
_samplerSlot | sampler slot to bind the texture to, zero-based index |
_texId | gl texture id |
_texType | gl texture type ie. GL_TEXTURE_1D, .. |
|
inline |
Set uniforms for shader based rendering.
Uniforms are copied from a pool when rendering with shader-based render-objects. The specified pool has to be a valid memory address whenever the objects are rendered. It does not make a copy of the pool.
_pool | pointer to address of a uniform pool |
Definition at line 636 of file BaseNode.hh.
|
private |
multi pass bit mask (1-indexed) Defines in which multipass runs an action should be applied to the node. (Only applies during multipass traversal!)
Definition at line 696 of file BaseNode.hh.
|
private |
multi pass bit mask (1-indexed) Defines in which multipass runs the enter and leave functions should be called. (Only applies during multipass traversal!)
Definition at line 690 of file BaseNode.hh.
|
private |
Flag indicating if picking should be done for this object This flag has to be checked by your node if you implement picking
Definition at line 733 of file BaseNode.hh.