osg.NodeVisitor¶
- class osg.NodeVisitor¶
- Represents
c++ class
- Wraps
osg::NodeVisitor
- Bases
Visitor for type safe operations on
osg.Nodes
. Based on GOF’s Visitor pattern. Theosg.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 appropriateosg.NodeVisitor.apply()
method of theosg.NodeVisitor
. To use this feature one must use theosg.Node.accept(NodeVisitor)()
which is extended in eachosg.Node
subclass, rather than the NodeVisitor apply directly. So useroot:accept(myVisitor)
instead ofmyVisitor:apply(root)
. The later method will bypass the double dispatch and the appropriateNodeVisitor:apply(..)
method will not be called. There are a number of methods with signature likesetApply<NodeType>Cb
(e.g.osg.NodeVisitor.setApplyDrawableCb()
forosg.Drawable
). These methods set callbacks which are called during traversal for corresbonding Node’s type only.Constructors:
- osg.NodeVisitor(osg.NodeVisitor.TraversalMode tm)¶
-
- Параметры
- osg.NodeVisitor(osg.NodeVisitor.VisitorType type, osg.NodeVisitor.TraversalMode tm)
-
- Параметры
type (
osg.NodeVisitor.VisitorType
) –
Methods:
- :reset()¶
Method to call to reset visitor. Useful if your visitor accumulates state during a traversal, and you plan to reuse the visitor. To flush that state for the next traversal: call
reset()
prior to each traversal.
- :setVisitorType(osg.NodeVisitor.VisitorType type)¶
Set the VisitorType, used to distinguish different visitors during traversal of the scene, typically used in the
osg.Node.traverse()
method to select which behaviour to use for different types of traversal/visitors.- Параметры
type (
osg.NodeVisitor.VisitorType
) –
- :getVisitorType()¶
Get the VisitorType of this
osg.NodeVisitor
.- Тип результата
- :setTraversalNumber(unsigned fn)¶
Set the traversal number. Typically used to denote the frame count.
- Параметры
fn (
unsigned
) –
- :getTraversalNumber()¶
Get the traversal number. Typically used to denote the frame count.
- Тип результата
unsigned
- :setFrameStamp(osg.FrameStamp fs)¶
Set the FrameStamp that this traversal is associated with.
- Параметры
fs (
osg.FrameStamp
) –
- :setTraversalMask(unsigned mask)¶
Set the TraversalMask of this
osg.NodeVisitor
. The TraversalMask is used by theosg.NodeVisitor.validNodeMask()
method to determine whether to operate on a node and its subgraph.osg.NodeVisitor.validNodeMask()
is called automatically in theosg.Node.accept()
method before any call toosg.NodeVisitor.apply()
,apply()
is only ever called ifvalidNodeMask
returnstrue
. Note, ifNodeVisitor::_traversalMask
is0
then all operations will be switched off for all nodes. Whereas setting both_traversalMask
and_nodeMaskOverride
to0xffffffff
will allow a visitor to work on all nodes regardless of their ownNode::_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’ingNodeVisitor::_nodeMaskOverride
with the Node’s ownNode::_nodeMask
. Typically used to force on nodes which may have been switched off by their ownNode::_nodeMask
.- Параметры
mask (
unsigned
) –
- :validNodeMask(osg.Node node)¶
Method to called by
osg.Node
and its subclass“osg.Node.accept()
method, if the result istrue
it is used to cull operations of nodes and their subgraphs. Returntrue
if the result of a bit wise and of theNodeVisitor::_traversalMask
with the bit or betweenNodeVistor::_nodeMaskOverride
and theNode::_nodeMask
. Default values for_traversalMask
is0xffffffff
,_nodeMaskOverride
is0x0
, andNode::_nodeMask
is0xffffffff
.- Параметры
node (
osg.Node
) –- Тип результата
bool
- :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 aosg.NodeVisitor
has been attached viasetTraverseVisitor()
and the new mode is notosg.NodeVisitor.TRAVERSE_VISITOR
from then the attached visitor is detached. Default mode isosg.NodeVisitor.TRAVERSE_NONE
.- Параметры
mode (
osg.NodeVisitor.TraversalMode
) –
- :getTraversalMode()¶
-
- Тип результата
- :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 theaccept()
methods call this method unless they handle traversal directly.- Параметры
node (
osg.Node
) –
- :popFromNodePath()¶
- :getNodePath()¶
Get the
osg.NodePath
from the top most node applied down to the currentosg.Node
being visited.- Тип результата
- :getEyePoint()¶
Get the eye point in local coordinates. Note, not all NodeVisitor implement this method, it is mainly cull visitors which will implement.
- Тип результата
- :getViewPoint()¶
Get the view point in local coordinates. Note, not all NodeVisitor implement this method, it is mainly cull visitors which will implement.
- Тип результата
- :getDistanceToEyePoint(osg.Vec3 pos, bool useLODScale)¶
Get the distance from a point to the eye point, distance value in local coordinate system. Note, not all NodeVisitor implement this method, it is mainly cull visitors which will implement. If the
osg.NodeVisitor.getDistanceToEyePoint()
is not implemented then a default value of0.0
is returned.- Параметры
pos (
osg.Vec3
) –useLODScale (
bool
) –
- Тип результата
double
- :getDistanceFromEyePoint(osg.Vec3 pos, bool useLODScale)¶
Get the distance of a point from the eye point, distance value in the eye coordinate system. Note, not all NodeVisitor implement this method, it is mainly cull visitors which will implement. If the
osg.NodeVisitor.getDistanceFromEyePoint()
is not implemented then a default value of0.0
is returned.- Параметры
pos (
osg.Vec3
) –useLODScale (
bool
) –
- Тип результата
double
- :getDistanceToViewPoint(osg.Vec3 pos, bool useLODScale)¶
Get the distance from a point to the view point, distance value in local coordinate system. Note, not all NodeVisitor implement this method, it is mainly cull visitors which will implement. If the
osg.NodeVisitor.getDistanceToViewPoint()
is not implemented then a default value of0.0
is returned.- Параметры
pos (
osg.Vec3
) –useLODScale (
bool
) –
- Тип результата
double
- :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
) –