osg.NodeVisitor

class osg.NodeVisitor
Represents

c++ class

Wraps

osg::NodeVisitor

Bases

osg.Object

Visitor for type safe operations on osg.Nodes. Based on GOF’s Visitor pattern. The osg.NodeVisitor is useful for developing type safe operations to nodes in the scene graph (as per Visitor pattern), and adds to this support for optional scene graph traversal to allow operations to be applied to whole scenes at once. The Visitor pattern uses a technique of double dispatch as a mechanism to call the appropriate osg.NodeVisitor.apply() method of the osg.NodeVisitor. To use this feature one must use the osg.Node.accept(NodeVisitor)() which is extended in each osg.Node subclass, rather than the NodeVisitor apply directly. So use root:accept(myVisitor) instead of myVisitor:apply(root). The later method will bypass the double dispatch and the appropriate NodeVisitor:apply(..) method will not be called. There are a number of methods with signature like setApply<NodeType>Cb (e.g. osg.NodeVisitor.setApplyDrawableCb() for osg.Drawable). These methods set callbacks which are called during traversal for corresbonding Node’s type only.

-- Example of osg.NodeVisitor usage.
-- Show complete subgraph of Scene object.
-- See results in the console (script will be evaluated Immediately during project startup).

local scene = reactorController:getReactorByName("Scene") -- must be presented in the project

local depth = 0
local nv = osg.NodeVisitor(osg.NodeVisitor.TRAVERSE_ALL_CHILDREN)
nv:setNodeMaskOverride(0xffffffff)
nv:setApplyNodeCb(function(aNode)
    local prefix = ""
    for i = 0, depth do prefix = prefix .. "  " end

    loginfo(string.format("%s'%s' (%s.%s)", prefix, aNode:name(), aNode:libraryName(), aNode:className()))

    depth = depth + 1
    nv:traverse(aNode)
    depth = depth - 1
end)

loginfo("******* Complete subgraph of Scene object *******")
scene.node:accept(nv)
loginfo("*************************************************")

Constructors:

osg.NodeVisitor(osg.NodeVisitor.TraversalMode tm)

Параметры

tm (osg.NodeVisitor.TraversalMode) –

osg.NodeVisitor(osg.NodeVisitor.VisitorType type, osg.NodeVisitor.TraversalMode tm)

Параметры

Methods:

:getVisitorType()

Get the VisitorType of this osg.NodeVisitor.

Тип результата

osg.NodeVisitor.VisitorType

:traverse(osg.Node node)

Method for handling traversal of a nodes. If you intend to use the osg.NodeVisitor for actively traversing the scene graph then make sure the accept() methods call this method unless they handle traversal directly.

Параметры

node (osg.Node) –

:setTraversalMode(osg.NodeVisitor.TraversalMode mode)

Set the traversal mode for osg.Node.traverse() to use when deciding which children of a node to traverse. If a osg.NodeVisitor has been attached via setTraverseVisitor() and the new mode is not osg.NodeVisitor.TRAVERSE_VISITOR from then the attached visitor is detached. Default mode is osg.NodeVisitor.TRAVERSE_NONE.

Параметры

mode (osg.NodeVisitor.TraversalMode) –

:getTraversalMode()

Тип результата

osg.NodeVisitor.TraversalMode

:setTraversalMask(unsigned mask)

Set the TraversalMask of this osg.NodeVisitor. The TraversalMask is used by the osg.NodeVisitor.validNodeMask() method to determine whether to operate on a node and its subgraph. osg.NodeVisitor.validNodeMask() is called automatically in the osg.Node.accept() method before any call to osg.NodeVisitor.apply(), apply() is only ever called if validNodeMask returns true. Note, if NodeVisitor::_traversalMask is 0 then all operations will be switched off for all nodes. Whereas setting both _traversalMask and _nodeMaskOverride to 0xffffffff will allow a visitor to work on all nodes regardless of their own Node::_nodeMask state.

Параметры

mask (unsigned) –

:getTraversalMask()

Get the TraversalMask.

Тип результата

unsigned

:getNodeMaskOverride()

Тип результата

unsigned

:setNodeMaskOverride(unsigned mask)

Set the NodeMaskOverride mask. Used in osg.NodeVisitor.validNodeMask() to determine whether to operate on a node or its subgraph, by OR’ing NodeVisitor::_nodeMaskOverride with the Node’s own Node::_nodeMask. Typically used to force on nodes which may have been switched off by their own Node::_nodeMask.

Параметры

mask (unsigned) –

:validNodeMask(osg.Node node)

Method to called by osg.Node and its subclass“ osg.Node.accept() method, if the result is true it is used to cull operations of nodes and their subgraphs. Return true if the result of a bit wise and of the NodeVisitor::_traversalMask with the bit or between NodeVistor::_nodeMaskOverride and the Node::_nodeMask. Default values for _traversalMask is 0xffffffff, _nodeMaskOverride is 0x0, and Node::_nodeMask is 0xffffffff.

Параметры

node (osg.Node) –

Тип результата

bool

:getNodePath()

Get the osg.NodePath from the top most node applied down to the current osg.Node being visited.

Тип результата

osg.NodePath

:setApplyDrawableCb(luafunction__ cb)

Параметры

cb (luafunction) –

:setApplyGeometryCb(luafunction__ cb)

Параметры

cb (luafunction) –

:setApplyNodeCb(luafunction__ cb)

Параметры

cb (luafunction) –

:setApplyGeodeCb(luafunction__ cb)

Параметры

cb (luafunction) –

:setApplyBillboardCb(luafunction__ cb)

Параметры

cb (luafunction) –

:setApplyGroupCb(luafunction__ cb)

Параметры

cb (luafunction) –

:setApplyProxyNodeCb(luafunction__ cb)

Параметры

cb (luafunction) –

:setApplyProjectionCb(luafunction__ cb)

Параметры

cb (luafunction) –

:setApplyCoordinateSystemNodeCb(luafunction__ cb)

Параметры

cb (luafunction) –

:setApplyClipNodeCb(luafunction__ cb)

Параметры

cb (luafunction) –

:setApplyTexGenNodeCb(luafunction__ cb)

Параметры

cb (luafunction) –

:setApplyLightSourceCb(luafunction__ cb)

Параметры

cb (luafunction) –

:setApplyTransformCb(luafunction__ cb)

Параметры

cb (luafunction) –

:setApplyCameraCb(luafunction__ cb)

Параметры

cb (luafunction) –

:setApplyCameraViewCb(luafunction__ cb)

Параметры

cb (luafunction) –

:setApplyMatrixTransformCb(luafunction__ cb)

Параметры

cb (luafunction) –

:setApplyPositionAttitudeTransformCb(luafunction__ cb)

Параметры

cb (luafunction) –

:setApplyAutoTransformCb(luafunction__ cb)

Параметры

cb (luafunction) –

:setApplySwitchCb(luafunction__ cb)

Параметры

cb (luafunction) –

:setApplySequenceCb(luafunction__ cb)

Параметры

cb (luafunction) –

:setApplyLODCb(luafunction__ cb)

Параметры

cb (luafunction) –

:setApplyPagedLODCb(luafunction__ cb)

Параметры

cb (luafunction) –

:setApplyClearNodeCb(luafunction__ cb)

Параметры

cb (luafunction) –

:setApplyOccluderNodeCb(luafunction__ cb)

Параметры

cb (luafunction) –

:setApplyOcclusionQueryNodeCb(luafunction__ cb)

Параметры

cb (luafunction) –