Package org.robwork.sdurw_graphics
Class SceneGraph
- java.lang.Object
-
- org.robwork.sdurw_graphics.SceneGraph
-
public class SceneGraph extends java.lang.Objectinterface for a minimalistic scenegraph that does not depend on the frame structure.
See WorkCellScene for an implementation that wraps this interface to enable a more RobWork
specific use.
Cameras - SceneCameras define how the world is rendered from a specific point of view,
render setting, projection matrix, viewport and so on.
Cameras are ordered in CameraGroups. Each camera group can contain multiple cameras that
are ordered according to how they should render the scene. A typical setup of one group would
be: first camera - clear color and depth buffers, render background ibn orthographic
projection second camera - render all 3D scene elements in perspective projection third
camera - render foreground such as logo in orthographic projection
As can be seen the ordering is of high importance since the first camera clears the frame
buffers.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSceneGraph.SceneGraphRenderInfoall general render information is located in this struct
-
Constructor Summary
Constructors Constructor Description SceneGraph(long cPtr, boolean cMemoryOwn)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCameraGroup(SWIGTYPE_p_rw__core__PtrT_rw__graphics__CameraGroup_t cgroup)Add a camera group.voidaddChild(SceneNodePtr child, GroupNodePtr parent)add a drawable to a nodevoidclear()Clear the scene graph.voiddelete()voiddraw(SceneGraph.SceneGraphRenderInfo info)draws the scene, using the specified render informationSWIGTYPE_p_rw__core__PtrT_rw__graphics__CameraGroup_tfindCameraGroup(java.lang.String name)Find a camera group.DrawableNodePtrfindDrawable(java.lang.String name)Find a drawable node in the scene graph.DrawableNodePtrfindDrawable(java.lang.String name, SceneNodePtr node)std::string&)SWIGTYPE_p_std__vectorT_rw__core__PtrT_rw__graphics__DrawableNode_t_tfindDrawables(java.lang.String name)Find multiple drawable nodes in the scene graph.SWIGTYPE_p_std__listT_rw__core__PtrT_rw__graphics__CameraGroup_t_tgetCameraGroups()Get all camera groups.static longgetCPtr(SceneGraph obj)SWIGTYPE_p_std__vectorT_rw__core__PtrT_rw__graphics__DrawableNode_t_tgetDrawables()get all drawables in the scene.SWIGTYPE_p_std__vectorT_rw__core__PtrT_rw__graphics__DrawableNode_t_tgetDrawables(SceneNodePtr node)get a vector of drawables attached to a nodeSWIGTYPE_p_std__vectorT_rw__core__PtrT_rw__graphics__DrawableNode_t_tgetDrawablesRec(SceneNodePtr node)get all drawable nodes in the subtree of node.GroupNodePtrgetRoot()Get the root of the scene graph.SWIGTYPE_p_rw__core__PtrT_rw__graphics__SceneCamera_tmakeCamera(java.lang.String name)Create a new scene camera.SWIGTYPE_p_rw__core__PtrT_rw__graphics__CameraGroup_tmakeCameraGroup(java.lang.String name)Create a camera group.DrawableNodePtrmakeDrawable(java.lang.String filename)Create a drawable node from a file.DrawableNodePtrmakeDrawable(java.lang.String filename, int dmask)Create a drawable node from a file.DrawableNodePtrmakeDrawable(java.lang.String name, java.lang.String text, FramePtr labelFrame)Create a drawable node for a text label.DrawableNodePtrmakeDrawable(java.lang.String name, java.lang.String text, FramePtr labelFrame, int dmask)Create a drawable node for a text label.DrawableGeometryNodePtrmakeDrawable(java.lang.String name, GeometryPtr geom)Create a drawable node for a geometry.DrawableGeometryNodePtrmakeDrawable(java.lang.String name, GeometryPtr geom, int dmask)Create a drawable node for a geometry.DrawableNodePtrmakeDrawable(java.lang.String name, Model3DPtr model)Create a drawable node for a 3d model.DrawableNodePtrmakeDrawable(java.lang.String name, Model3DPtr model, int dmask)Create a drawable node for a 3d model.DrawableNodePtrmakeDrawable(java.lang.String name, PointCloud scan)Create a drawable node for a point cloud.DrawableNodePtrmakeDrawable(java.lang.String name, PointCloud scan, int dmask)Create a drawable node for a point cloud.DrawableGeometryNodePtrmakeDrawable(java.lang.String name, VectorLine lines)Create a drawable node for lines.DrawableGeometryNodePtrmakeDrawable(java.lang.String name, VectorLine lines, int dmask)Create a drawable node for lines.DrawableNodePtrmakeDrawable(java.lang.String name, RenderPtr render)Create a drawable node for a render.DrawableNodePtrmakeDrawable(java.lang.String name, RenderPtr render, int dmask)Create a drawable node for a render.DrawableNodePtrmakeDrawable(java.lang.String name, Image img)Create a drawable node for an image.DrawableNodePtrmakeDrawable(java.lang.String name, Image img, int dmask)Create a drawable node for an image.DrawableGeometryNodePtrmakeDrawableFrameAxis(java.lang.String name, double size)Create a drawable node for a frame axis coordinate system.DrawableGeometryNodePtrmakeDrawableFrameAxis(java.lang.String name, double size, int dmask)Create a drawable node for a frame axis coordinate system.GroupNodePtrmakeGroupNode(java.lang.String name)Make a group node.DrawableNodePtrpickDrawable(SceneGraph.SceneGraphRenderInfo info, int x, int y)picks the drawable in the scene that intersects with the ray (x,y,-1) in
camera coordinates.
Vector3Dproject(SWIGTYPE_p_rw__core__PtrT_rw__graphics__SceneCamera_t camera, double x, double y, double z)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.voidremoveCameraGroup(java.lang.String name)Remove a camera group.voidremoveCameraGroup(SWIGTYPE_p_rw__core__PtrT_rw__graphics__CameraGroup_t cgroup)Remove a camera group.booleanremoveChild(java.lang.String name, GroupNodePtr node)Removes child with the specified name from the node.
booleanremoveDrawable(java.lang.String name)Remove a specific drawable with a given name.booleanremoveDrawable(DrawableNodePtr drawable)Remove a specific drawable.booleanremoveDrawable(DrawableNodePtr drawable, SceneNodePtr node)Remove a specific drawable.booleanremoveDrawables(java.lang.String name)Remove all drawables with a given name.booleanremoveDrawables(GroupNodePtr node)Remove a node.voidsetRoot(GroupNodePtr node)Set the root of the scene graph.Vector3Dunproject(SWIGTYPE_p_rw__core__PtrT_rw__graphics__SceneCamera_t camera, int x, int y)this method unprojects a 2D screen coordinate to 3D coordinates from the last
draw'n scene.voidupdate()should be called after the structure of the scene
has been changed
-
-
-
Method Detail
-
getCPtr
public static long getCPtr(SceneGraph obj)
-
delete
public void delete()
-
draw
public void draw(SceneGraph.SceneGraphRenderInfo info)
draws the scene, using the specified render information- Parameters:
info- documentation missing !
-
pickDrawable
public DrawableNodePtr pickDrawable(SceneGraph.SceneGraphRenderInfo info, int x, int y)
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.
-
unproject
public Vector3D unproject(SWIGTYPE_p_rw__core__PtrT_rw__graphics__SceneCamera_t 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.
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,
-
project
public Vector3D project(SWIGTYPE_p_rw__core__PtrT_rw__graphics__SceneCamera_t camera, double x, double y, double z)
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,
-
update
public void update()
should be called after the structure of the scene
has been changed
-
clear
public void clear()
Clear the scene graph.
-
makeDrawableFrameAxis
public DrawableGeometryNodePtr makeDrawableFrameAxis(java.lang.String name, double size, int dmask)
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.
-
makeDrawableFrameAxis
public DrawableGeometryNodePtr makeDrawableFrameAxis(java.lang.String name, double size)
Create a drawable node for a frame axis coordinate system.- Parameters:
name- [in] name of the drawable.size- [in] size of the axis.
- Returns:
- a drawable geometry node.
-
makeDrawable
public DrawableGeometryNodePtr makeDrawable(java.lang.String name, GeometryPtr geom, int dmask)
Create a drawable node for a geometry.- Parameters:
name- [in] name of the drawable.geom- [in] the geometry to draw.dmask- [in] (optional) the type of drawable. Default is DrawableNode::Physical.- Returns:
- a drawable geometry node.
-
makeDrawable
public DrawableGeometryNodePtr makeDrawable(java.lang.String name, GeometryPtr geom)
Create a drawable node for a geometry.- Parameters:
name- [in] name of the drawable.geom- [in] the geometry to draw.
- Returns:
- a drawable geometry node.
-
makeDrawable
public DrawableGeometryNodePtr makeDrawable(java.lang.String name, VectorLine lines, int dmask)
Create a drawable node for lines.- Parameters:
name- [in] name of the drawable.lines- [in] the lines to draw.dmask- [in] (optional) the type of drawable. Default is DrawableNode::Physical.- Returns:
- a drawable geometry node.
-
makeDrawable
public DrawableGeometryNodePtr makeDrawable(java.lang.String name, VectorLine lines)
Create a drawable node for lines.- Parameters:
name- [in] name of the drawable.lines- [in] the lines to draw.
- Returns:
- a drawable geometry node.
-
makeDrawable
public DrawableNodePtr makeDrawable(java.lang.String name, Image img, int dmask)
Create a drawable node for an image.- Parameters:
name- [in] name of the drawable.img- [in] the image to draw.dmask- [in] (optional) the type of drawable. Default is DrawableNode::Physical.- Returns:
- a drawable node.
-
makeDrawable
public DrawableNodePtr makeDrawable(java.lang.String name, Image img)
Create a drawable node for an image.- Parameters:
name- [in] name of the drawable.img- [in] the image to draw.
- Returns:
- a drawable node.
-
makeDrawable
public DrawableNodePtr makeDrawable(java.lang.String name, PointCloud scan, int dmask)
Create a drawable node for a point cloud.- Parameters:
name- [in] name of the drawable.scan- [in] the point cloud to draw.dmask- [in] (optional) the type of drawable. Default is DrawableNode::Physical.- Returns:
- a drawable node.
-
makeDrawable
public DrawableNodePtr makeDrawable(java.lang.String name, PointCloud scan)
Create a drawable node for a point cloud.- Parameters:
name- [in] name of the drawable.scan- [in] the point cloud to draw.
- Returns:
- a drawable node.
-
makeDrawable
public DrawableNodePtr makeDrawable(java.lang.String name, Model3DPtr model, int dmask)
Create a drawable node for a 3d model.- Parameters:
name- [in] name of the drawable.model- [in] the 3d model to draw.dmask- [in] (optional) the type of drawable. Default is DrawableNode::Physical.- Returns:
- a drawable node.
-
makeDrawable
public DrawableNodePtr makeDrawable(java.lang.String name, Model3DPtr model)
Create a drawable node for a 3d model.- Parameters:
name- [in] name of the drawable.model- [in] the 3d model to draw.
- Returns:
- a drawable node.
-
makeDrawable
public DrawableNodePtr makeDrawable(java.lang.String name, java.lang.String text, FramePtr labelFrame, int dmask)
Create a drawable node for a text label.- 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.
-
makeDrawable
public DrawableNodePtr makeDrawable(java.lang.String name, java.lang.String text, FramePtr labelFrame)
Create a drawable node for a text label.- Parameters:
name- [in] name of the drawable.text- [in] the text to draw.labelFrame- [in] the frame the label belongs to.
- Returns:
- a drawable node.
-
makeDrawable
public DrawableNodePtr makeDrawable(java.lang.String name, RenderPtr render, int dmask)
Create a drawable node for a render.- Parameters:
name- [in] name of the drawable.render- [in] the render to draw.dmask- [in] (optional) the type of drawable. Default is DrawableNode::Physical.- Returns:
- a drawable node.
-
makeDrawable
public DrawableNodePtr makeDrawable(java.lang.String name, RenderPtr render)
Create a drawable node for a render.- Parameters:
name- [in] name of the drawable.render- [in] the render to draw.
- Returns:
- a drawable node.
-
makeDrawable
public DrawableNodePtr makeDrawable(java.lang.String filename, int dmask)
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.
-
makeDrawable
public DrawableNodePtr makeDrawable(java.lang.String filename)
Create a drawable node from a file.- Parameters:
filename- [in] a filename (alternatively a string for a geometric primitive).
- Returns:
- a drawable node.
-
makeCamera
public SWIGTYPE_p_rw__core__PtrT_rw__graphics__SceneCamera_t makeCamera(java.lang.String name)
Create a new scene camera.- Parameters:
name- [in] name of the camera.- Returns:
- the new scene camera.
-
makeGroupNode
public GroupNodePtr makeGroupNode(java.lang.String name)
Make a group node.- Parameters:
name- [in] name of the node.- Returns:
- new group node.
-
makeCameraGroup
public SWIGTYPE_p_rw__core__PtrT_rw__graphics__CameraGroup_t makeCameraGroup(java.lang.String name)
Create a camera group.- Parameters:
name- [in] name of the group.- Returns:
- a new camera group.
-
findCameraGroup
public SWIGTYPE_p_rw__core__PtrT_rw__graphics__CameraGroup_t findCameraGroup(java.lang.String name)
Find a camera group.- Parameters:
name- [in] name of the group.- Returns:
- the camera group if found, else NULL.
-
addCameraGroup
public void addCameraGroup(SWIGTYPE_p_rw__core__PtrT_rw__graphics__CameraGroup_t cgroup)
Add a camera group.- Parameters:
cgroup- [in] the group to add.
-
removeCameraGroup
public void removeCameraGroup(SWIGTYPE_p_rw__core__PtrT_rw__graphics__CameraGroup_t cgroup)
Remove a camera group.- Parameters:
cgroup- [in] the group to remove.
-
removeCameraGroup
public void removeCameraGroup(java.lang.String name)
Remove a camera group.- Parameters:
name- [in] the name of the group.
-
getCameraGroups
public SWIGTYPE_p_std__listT_rw__core__PtrT_rw__graphics__CameraGroup_t_t getCameraGroups()
Get all camera groups.- Returns:
- a list of camera groups.
-
setRoot
public void setRoot(GroupNodePtr node)
Set the root of the scene graph.- Parameters:
node- [in] the root node.
-
getRoot
public GroupNodePtr getRoot()
Get the root of the scene graph.- Returns:
- the root group node.
-
addChild
public void addChild(SceneNodePtr child, GroupNodePtr parent)
add a drawable to a node
-
getDrawables
public SWIGTYPE_p_std__vectorT_rw__core__PtrT_rw__graphics__DrawableNode_t_t getDrawables()
get all drawables in the scene.- Returns:
-
getDrawables
public SWIGTYPE_p_std__vectorT_rw__core__PtrT_rw__graphics__DrawableNode_t_t getDrawables(SceneNodePtr node)
get a vector of drawables attached to a node- Parameters:
node-- Returns:
-
getDrawablesRec
public SWIGTYPE_p_std__vectorT_rw__core__PtrT_rw__graphics__DrawableNode_t_t getDrawablesRec(SceneNodePtr node)
get all drawable nodes in the subtree of node. nodes of type camera will
not be traversed- Parameters:
node- [in]- Returns:
-
findDrawable
public DrawableNodePtr findDrawable(java.lang.String name)
Find a drawable node in the scene graph.- Parameters:
name- [in] the name of the drawable node.- Returns:
- the node if found, NULL otherwise.
-
findDrawable
public DrawableNodePtr findDrawable(java.lang.String name, SceneNodePtr node)
std::string&)- Parameters:
node- [in] search only this node and all children recursively.
-
findDrawables
public SWIGTYPE_p_std__vectorT_rw__core__PtrT_rw__graphics__DrawableNode_t_t findDrawables(java.lang.String name)
Find multiple drawable nodes in the scene graph.- Parameters:
name- [in] the name of the drawable node(s).- Returns:
- a vector of all nodes with the given name.
-
removeDrawables
public boolean removeDrawables(GroupNodePtr node)
Remove a node.- Parameters:
node- [in] the group node to remove.- Returns:
- true if removed, false otherwise.
-
removeDrawables
public boolean removeDrawables(java.lang.String name)
Remove all drawables with a given name.- Parameters:
name- [in] the name.- Returns:
- true if removed, false otherwise.
-
removeDrawable
public boolean removeDrawable(DrawableNodePtr drawable)
Remove a specific drawable.- Parameters:
drawable- [in] the drawable.- Returns:
- true if removed, false otherwise.
-
removeDrawable
public boolean removeDrawable(DrawableNodePtr drawable, SceneNodePtr node)
Remove a specific drawable.- Parameters:
drawable- [in] the drawable.node- [in] only search this node and children recursively.- Returns:
- true if removed, false otherwise.
-
removeDrawable
public boolean removeDrawable(java.lang.String name)
Remove a specific drawable with a given name.- Parameters:
name- [in] the name.- Returns:
- true if removed, false otherwise.
-
removeChild
public boolean removeChild(java.lang.String name, GroupNodePtr node)Removes child with the specified name from the node.
- Parameters:
name- [in] Name of child to removenode- [in] Node to remove from- Returns:
- true if found and successfully removed.
-
-