| 1 |
NAME SoSurroundScale SoSurroundScale "" { transformation node that adjusts the current matrix so a default cube will surround other objects } |
| 2 |
|
| 3 |
INCLUDE nodes/SoSurroundScale.h |
| 4 |
|
| 5 |
DESC { |
| 6 |
When traversed by an action, this node |
| 7 |
appends a transformation to the current transformation matrix |
| 8 |
so that a default size cube will surround the objects specified |
| 9 |
by its fields. Transform manipulators, such as \cSoHandleBoxManip\., |
| 10 |
use these nodes to make themselves surround other objects. |
| 11 |
\p |
| 12 |
This node only recalculates after the |
| 13 |
\m\+invalidate()\.\-SoSurroundScaleInvalidate()\.\. method has been |
| 14 |
called. Otherwise it uses a saved scale and translation. |
| 15 |
\p |
| 16 |
When calculating what to surround, the \cSoSurroundScale\. |
| 17 |
looks at the current path in |
| 18 |
the action and at its own field values. |
| 19 |
Then \cSoSurroundScale\. applies an \cSoGetBoundingBoxAction\. |
| 20 |
to the node that is |
| 21 |
\vnumNodesUpToContainer\. nodes above it on the path. |
| 22 |
\cSoSurroundScale\. also tells the action to reset |
| 23 |
the bounding box upon traversal of the |
| 24 |
node located \vnumNodesUpToReset\. nodes above it in the path. |
| 25 |
The \cSoSurroundScale\. then appends a translation and scale |
| 26 |
to the current transformation |
| 27 |
so that a default size \cSoCube\. will translate and scale to fit this |
| 28 |
bounding box. |
| 29 |
\p |
| 30 |
For example, when an \cSoHandleBoxManip\. wants to surround the objects it |
| 31 |
is going to move, the scene graph will look something like this: |
| 32 |
\b\k\*(Cr |
| 33 |
RootNode |
| 34 |
------------------------- |
| 35 |
| | |
| 36 |
handleBoxManip movingStuff |
| 37 |
| |
| 38 |
handleBoxDragger |
| 39 |
| |
| 40 |
separator |
| 41 |
----------------------------------- |
| 42 |
| | | |
| 43 |
motionMatrix surroundScale cubeGeom |
| 44 |
\.\. |
| 45 |
The \cSoHandleBoxDragger\. wants to transform the \ecubeGeom\. so that it |
| 46 |
surrounds the \emovingStuff\.. So it sets the \esurroundScale\. fields to: |
| 47 |
\b |
| 48 |
\vnumNodesUpToContainer\. = 4; |
| 49 |
\vnumNodesUpToReset\. = 3; |
| 50 |
\. |
| 51 |
The \cSoBoundingBoxAction\. will then be applied to \eRootNode\., |
| 52 |
with a reset after traversing the \cSoHandleBoxManip\.. |
| 53 |
So the \cSoSurroundScale\. will surround the objects below \eseparator\., and |
| 54 |
to the right of \ehandleBoxManip\., producing the desired effect. |
| 55 |
} |
| 56 |
|
| 57 |
FIELD numNodesUpToContainer { |
| 58 |
When traversed by an action, if surroundScale needs to |
| 59 |
calculate a new box, surroundScale |
| 60 |
looks at the current path in |
| 61 |
the action. It travels up this path a distance of \vnumNodesUpToContainer\. |
| 62 |
and applies an \cSoGetBoundingBoxAction\. to the node that it finds |
| 63 |
there. |
| 64 |
} |
| 65 |
|
| 66 |
FIELD numNodesUpToReset { |
| 67 |
Before applying the \cSoGetBoundingBoxAction\. (see the |
| 68 |
\vnumNodesUpToContainer\. field aove) the surroundScale node |
| 69 |
travels up the path a distance of \vnumNodesUpToReset\. |
| 70 |
and tells the action to reset |
| 71 |
the bounding box upon traversal of that node. |
| 72 |
} |
| 73 |
|
| 74 |
METHOD "" SoSurroundScale() { |
| 75 |
Creates a surround scale node with default settings. |
| 76 |
} |
| 77 |
|
| 78 |
METHOD "" void invalidate() { |
| 79 |
If you call this, then next time an action is applied the node will re-calculate |
| 80 |
it's cached translation and scale values. |
| 81 |
} |
| 82 |
|
| 83 |
METHOD "" static SoType getClassTypeId() { |
| 84 |
Returns type identifier for this class. |
| 85 |
} |
| 86 |
|
| 87 |
ACTION SoGLRenderAction, SoCallbackAction, |
| 88 |
SoGetBoundingBoxAction, SoRayPickAction { |
| 89 |
Accumulates scaling and translation transformations into |
| 90 |
the current transformation. |
| 91 |
} |
| 92 |
|
| 93 |
ACTION SoGetMatrixAction { |
| 94 |
Returns the matrix corresponding to the scaling and translation. |
| 95 |
} |
| 96 |
|
| 97 |
ALSO { SoTransformation, SoTransformManip, |
| 98 |
SoCenterballDragger, SoCenterballManip, |
| 99 |
SoHandleBoxDragger, SoHandleBoxManip, |
| 100 |
SoJackDragger, SoJackManip, |
| 101 |
SoTabBoxDragger, SoTabBoxManip, |
| 102 |
SoTrackballDragger, SoTrackballManip, |
| 103 |
SoTransformBoxDragger, SoTransformBoxManip |
| 104 |
} |
| 105 |
|