RobWorkProject  23.9.11-
Public Types | Public Member Functions | Static Public Member Functions | List of all members
SceneOpenGL Class Reference

Helps with Visualizing a Workcell. SceneOpenGL is OpenGL specific. More...

#include <SceneOpenGL.hpp>

Inherits SceneGraph.

Public Types

typedef rw::core::Ptr< SceneOpenGLPtr
 Smart pointer type for SceneOpenGL.
 
- Public Types inherited from SceneGraph
typedef rw::core::Ptr< SceneGraphPtr
 smart pointer type of this class
 
typedef DrawableNode::DrawType DrawType
 Drawing types.
 
using RenderInfo = SceneGraphRenderInfo
 
typedef boost::function< bool(rw::core::Ptr< rw::graphics::SceneNode > &node, rw::core::Ptr< rw::graphics::SceneNode > &parent)> NodeVisitor
 Type of a visitor function. Returns true if visit is done.
 
typedef boost::function< bool(const rw::core::Ptr< rw::graphics::SceneNode > &node)> NodeFilter
 Type of a filter function.
 

Public Member Functions

 SceneOpenGL ()
 Creates object.
 
virtual ~SceneOpenGL ()
 Destroys object.
 
void clearCache ()
 Clears the drawable cache by deleting all drawables.
 
void draw (rw::graphics::SceneGraph::RenderInfo &info)
 draws the scene, using the specified render information More...
 
void draw (rw::graphics::SceneGraph::RenderInfo &info, rw::graphics::SceneNode::Ptr node)
 draws the scene, using the specified render information More...
 
rw::graphics::DrawableNode::Ptr pickDrawable (rw::graphics::SceneGraph::RenderInfo &info, int x, int y)
 picks the drawable in the scene that intersects with the ray (x,y,-1) in camera coordinates. More...
 
rw::math::Vector3D unproject (rw::graphics::SceneCamera::Ptr camera, int x, int y)
 this method unprojects a 2D screen coordinate to 3D coordinates from the last draw'n scene. Which is the closest 3d point from the intersection of the ray (x,y,-1) and the objects drawn in the scene. More...
 
rw::math::Vector3D project (rw::graphics::SceneCamera::Ptr camera, double x, double y, double z)
 this method projects a 3D coordinate to 2D screen coordinates from the last draw'n scene. More...
 
void update ()
 should be called after the structure of the scene has been changed More...
 
rw::graphics::DrawableGeometryNode::Ptr makeDrawableFrameAxis (const std::string &name, double size, int dmask)
 Create a drawable node for a frame axis coordinate system. More...
 
rw::graphics::DrawableGeometryNode::Ptr makeDrawable (const std::string &name, rw::core::Ptr< rw::geometry::Geometry > geom, int dmask)
 
rw::graphics::DrawableGeometryNode::Ptr makeDrawable (const std::string &name, const std::vector< rw::geometry::Line > &lines, int dmask)
 
rw::graphics::DrawableNode::Ptr makeDrawable (const std::string &name, rw::core::Ptr< rw::geometry::Model3D > model, int dmask)
 
rw::graphics::DrawableNode::Ptr makeDrawable (const std::string &name, const class rw::sensor::Image &img, int dmask)
 
rw::graphics::DrawableNode::Ptr makeDrawable (const std::string &name, const rw::geometry::PointCloud &scan, int dmask)
 
rw::graphics::DrawableNode::Ptr makeDrawable (const std::string &name, const std::string &text, const rw::core::Ptr< rw::kinematics::Frame > labelFrame, int dmask)
 
rw::graphics::DrawableNode::Ptr makeDrawable (const std::string &name, rw::core::Ptr< rw::graphics::Render > render, int dmask)
 
rw::graphics::DrawableNode::Ptr makeDrawable (const std::string &filename, int dmask)
 Create a drawable node from a file. More...
 
rw::core::Ptr< rw::graphics::SceneCameramakeCamera (const std::string &name)
 Create a new scene camera. More...
 
rw::core::Ptr< rw::graphics::CameraGroupmakeCameraGroup (const std::string &name)
 Create a camera group. More...
 
void clear ()
 Clear the scene graph.
 
- Public Member Functions inherited from SceneGraph
virtual ~SceneGraph ()
 Destructor.
 
virtual GroupNode::Ptr makeGroupNode (const std::string &name)
 Make a group node. More...
 
virtual rw::core::Ptr< rw::graphics::CameraGroupfindCameraGroup (const std::string &name)
 Find a camera group. More...
 
virtual void addCameraGroup (rw::core::Ptr< rw::graphics::CameraGroup > cgroup)
 Add a camera group. More...
 
virtual void removeCameraGroup (rw::core::Ptr< rw::graphics::CameraGroup > cgroup)
 Remove a camera group. More...
 
virtual void removeCameraGroup (const std::string &name)
 Remove a camera group. More...
 
virtual std::list< rw::core::Ptr< rw::graphics::CameraGroup > > getCameraGroups ()
 Get all camera groups. More...
 
virtual void setRoot (rw::graphics::GroupNode::Ptr node)
 Set the root of the scene graph. More...
 
virtual rw::graphics::GroupNode::Ptr getRoot ()
 Get the root of the scene graph. More...
 
virtual void addChild (rw::core::Ptr< rw::graphics::SceneNode > child, rw::graphics::GroupNode::Ptr parent)
 add a drawable to a node
 
virtual std::vector< rw::graphics::DrawableNode::PtrgetDrawables ()
 get all drawables in the scene. More...
 
virtual std::vector< rw::graphics::DrawableNode::PtrgetDrawables (rw::core::Ptr< rw::graphics::SceneNode > node)
 get a vector of drawables attached to a node More...
 
virtual std::vector< rw::graphics::DrawableNode::PtrgetDrawablesRec (rw::core::Ptr< rw::graphics::SceneNode > node)
 get all drawable nodes in the subtree of node. nodes of type camera will not be traversed More...
 
virtual rw::graphics::DrawableNode::Ptr findDrawable (const std::string &name)
 Find a drawable node in the scene graph. More...
 
virtual rw::graphics::DrawableNode::Ptr findDrawable (const std::string &name, rw::core::Ptr< SceneNode > node)
 Find a drawable node in the scene graph. More...
 
virtual std::vector< rw::graphics::DrawableNode::PtrfindDrawables (const std::string &name)
 Find multiple drawable nodes in the scene graph. More...
 
virtual bool removeDrawables (rw::graphics::GroupNode::Ptr node)
 Remove a node. More...
 
virtual bool removeDrawables (const std::string &name)
 Remove all drawables with a given name. More...
 
virtual bool removeDrawable (rw::graphics::DrawableNode::Ptr drawable)
 Remove a specific drawable. More...
 
virtual bool removeDrawable (rw::graphics::DrawableNode::Ptr drawable, rw::core::Ptr< rw::graphics::SceneNode > node)
 Remove a specific drawable. More...
 
virtual bool removeDrawable (const std::string &name)
 Remove a specific drawable with a given name. More...
 
virtual bool removeChild (const std::string &name, rw::graphics::GroupNode::Ptr node)
 Removes child with the specified name from the node. More...
 
void traverse (rw::core::Ptr< rw::graphics::SceneNode > &node, NodeVisitor &visitor)
 Traverse all nodes in the subtree under node recursively. More...
 
void traverse (rw::core::Ptr< rw::graphics::SceneNode > &node, NodeVisitor &visitor, NodeVisitor &postvisitor)
 Traverse all nodes in the subtree under node recursively. More...
 
void traverse (rw::core::Ptr< rw::graphics::SceneNode > &node, NodeVisitor &visitor, const NodeFilter &filter)
 Traverse all nodes in the subtree under node recursively. More...
 
void traverse (rw::core::Ptr< rw::graphics::SceneNode > &node, NodeVisitor &visitor, NodeVisitor &postvisitor, const NodeFilter &filter)
 Traverse all nodes in the subtree under node recursively. More...
 

Static Public Member Functions

static std::string detectGLerror ()
 Check if there has been any OpenGL errors since last call to this function or to glGetError. More...
 

Additional Inherited Members

- Protected Member Functions inherited from SceneGraph
 SceneGraph ()
 Construct new scene graph with only a root node "Root".
 
 SceneGraph (rw::graphics::GroupNode::Ptr root)
 Construct a new scene graph with a given root node. More...
 
- Protected Attributes inherited from SceneGraph
rw::graphics::GroupNode::Ptr _root
 The root node of the graph.
 
std::list< rw::core::Ptr< rw::graphics::CameraGroup > > _cameraGroups
 The camera groups in the graph.
 

Detailed Description

Helps with Visualizing a Workcell. SceneOpenGL is OpenGL specific.

Member Function Documentation

◆ detectGLerror()

static std::string detectGLerror ( )
static

Check if there has been any OpenGL errors since last call to this function or to glGetError.

Returns
a string representation of the error, or empty string if there is no error.

◆ draw() [1/2]

void draw ( rw::graphics::SceneGraph::RenderInfo info)
virtual

draws the scene, using the specified render information

Parameters
infodocumentation missing !

Implements SceneGraph.

◆ draw() [2/2]

draws the scene, using the specified render information

Parameters
infodocumentation missing !
node[in] draw only this subtree.

◆ makeCamera()

rw::core::Ptr<rw::graphics::SceneCamera> makeCamera ( const std::string &  name)
virtual

Create a new scene camera.

Parameters
name[in] name of the camera.
Returns
the new scene camera.

Implements SceneGraph.

◆ makeCameraGroup()

rw::core::Ptr<rw::graphics::CameraGroup> makeCameraGroup ( const std::string &  name)
virtual

Create a camera group.

Parameters
name[in] name of the group.
Returns
a new camera group.

Reimplemented from SceneGraph.

◆ makeDrawable() [1/8]

rw::graphics::DrawableNode::Ptr makeDrawable ( const std::string &  filename,
int  dmask 
)
virtual

Create a drawable node from a file.

Parameters
filename[in] a filename (alternatively a string for a geometric primitive).
dmask[in] (optional) the type of drawable. Default is DrawableNode::Physical.
Returns
a drawable node.

Implements SceneGraph.

◆ makeDrawable() [2/8]

rw::graphics::DrawableNode::Ptr makeDrawable ( const std::string &  name,
const class rw::sensor::Image img,
int  dmask 
)
virtual

Implements SceneGraph.

◆ makeDrawable() [3/8]

rw::graphics::DrawableNode::Ptr makeDrawable ( const std::string &  name,
const rw::geometry::PointCloud scan,
int  dmask 
)
virtual

Implements SceneGraph.

◆ makeDrawable() [4/8]

rw::graphics::DrawableNode::Ptr makeDrawable ( const std::string &  name,
const std::string &  text,
const rw::core::Ptr< rw::kinematics::Frame labelFrame,
int  dmask 
)
virtual

Parameters
name[in] name of the drawable.
text[in] the text to draw.
labelFrame[in] the frame the label belongs to.
dmask[in] (optional) the type of drawable. Default is DrawableNode::Virtual.
Returns
a drawable node.

Implements SceneGraph.

◆ makeDrawable() [5/8]

rw::graphics::DrawableGeometryNode::Ptr makeDrawable ( const std::string &  name,
const std::vector< rw::geometry::Line > &  lines,
int  dmask 
)
virtual

Implements SceneGraph.

◆ makeDrawable() [6/8]

rw::graphics::DrawableGeometryNode::Ptr makeDrawable ( const std::string &  name,
rw::core::Ptr< rw::geometry::Geometry geom,
int  dmask 
)
virtual

Implements SceneGraph.

◆ makeDrawable() [7/8]

rw::graphics::DrawableNode::Ptr makeDrawable ( const std::string &  name,
rw::core::Ptr< rw::geometry::Model3D model,
int  dmask 
)
virtual

Implements SceneGraph.

◆ makeDrawable() [8/8]

rw::graphics::DrawableNode::Ptr makeDrawable ( const std::string &  name,
rw::core::Ptr< rw::graphics::Render render,
int  dmask 
)
virtual

Implements SceneGraph.

◆ makeDrawableFrameAxis()

rw::graphics::DrawableGeometryNode::Ptr makeDrawableFrameAxis ( const std::string &  name,
double  size,
int  dmask 
)
virtual

Create a drawable node for a frame axis coordinate system.

Parameters
name[in] name of the drawable.
size[in] size of the axis.
dmask[in] (optional) the type of drawable. Default is DrawableNode::Physical.
Returns
a drawable geometry node.

Implements SceneGraph.

◆ pickDrawable()

rw::graphics::DrawableNode::Ptr pickDrawable ( rw::graphics::SceneGraph::RenderInfo info,
int  x,
int  y 
)
virtual

picks the drawable in the scene that intersects with the ray (x,y,-1) in camera coordinates.

Parameters
info[in] rendering information.
x[in] first camera coordinate.
y[in] second camera coordinate.
Returns
the picked drawable.

Implements SceneGraph.

◆ project()

rw::math::Vector3D project ( rw::graphics::SceneCamera::Ptr  camera,
double  x,
double  y,
double  z 
)
virtual

this method projects a 3D coordinate to 2D screen coordinates from the last draw'n scene.

Note
this method relies on a previously drawn scene, eg. call to draw(). Any thing drawn in the scene can be "picked" by this method.

(0,0) is located in the upper left corner, with x-axis increasing to the right and y-axis increasing to the bottom. The negative z-axis points into the scene-

Parameters
camera[in] the SceneCamera.
x[in] x coordinate [0;viewport.width]
y[in] y coordinate [0;viewport.height]
z[in] z coordinate
Returns
the 2D point,

Implements SceneGraph.

◆ unproject()

rw::math::Vector3D unproject ( rw::graphics::SceneCamera::Ptr  camera,
int  x,
int  y 
)
virtual

this method unprojects a 2D screen coordinate to 3D coordinates from the last draw'n scene. Which is the closest 3d point from the intersection of the ray (x,y,-1) and the objects drawn in the scene.

Note
this method relies on a previously drawn scene, eg. call to draw(). Any thing drawn in the scene can be "picked" by this method.

(0,0) is located in the upper left corner, with x-axis increasing to the right and y-axis increasing to the bottom. The negative z-axis points into the scene-

Parameters
camera[in] the scene camera.
x[in] x coordinate [0;viewport.width]
y[in] y coordinate [0;viewport.height]
Returns
the 3D point,

Implements SceneGraph.

◆ update()

void update ( )
virtual

should be called after the structure of the scene has been changed

Implements SceneGraph.


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