[osg-users] Getting the combined matrix from a Node?

Robert Osfield robert.osfield at gmail.com
Tue May 8 00:23:47 PDT 2018


Hi Marlin,

The Transform class and it's subclasses are designed to be used as part of
scene graph, this allow Transform subclasses that are absolute (ignore
transforms+camera matrices above them) or relative (multiple the inherited
modelview matrix) to enable this in a generic way the Transform class has
two helper methods Transform::computeLocalToWorld(osg::Matrix& matrix,
NodeVistor*) and computeWorldToLocal(osg::Matrix& matrix, NodeVisior*).
Only some Transform implementations need to check the NodeVisitor for extra
data, most will just ignore that parameter and just do the matrix maths
required.

The computeLocalToWorld() method returns a bool on success, and you pass in
the matrix you want to apply,  You're code segment appears to confuse
things in this regard.


If you want to transform of any node in the scene graph you can do
Node::getWorldMatrices(), this finds all the parental NodePaths of that
node and then returns a vector containing a matrix for each NodePath
found.

Robert.



On 7 May 2018 at 19:58, Rowley, Marlin R <marlin.r.rowley at lmco.com> wrote:

> Hello,
>
>
>
> I’m trying to figure out how to retrieve the combined matrix from a node
> that is of a PositionAttitudeTransform node type.  I can get it converted
> to a Transform() class, but there is no clear way of getting the combined
> matrix from local to world.  For example,
>
>
>
> Osg::PositionAttitudeTransform trans;
>
> Trans.setScale(2,2,2);
>
> Trans.setPosition(0,10,0);
>
>
>
> Osg::Matrixd temp = getCombinedTransform(trans);
>
> Osg::Matrixd getCombinedTransform(const osg::ref_ptr<osg::Node> & mat)
>
> {
>
>               Auto m = mat->asTransform();
>
>               Return m->computeLocalToWorldMatrix (m, ???); << ====== why
> use a node visitor on yourself?
>
>
>
>               Or
>
>
>
>               Return m->getCombinedMatrix()?? <<  ===== is there such a
> thing?
>
> }
>
>
>
> ----------------------------------------
>
> Marlin Rowley
>
> Software Engineer, Staff
>
> [image: cid:image002.jpg at 01D39374.DEC5A2E0]
>
> *Missiles and Fire Control*
>
> 972-603-1931 (office)
>
> 214-926-0622 (mobile)
>
> marlin.r.rowley at lmco.com
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20180508/421c771c/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 3114 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20180508/421c771c/attachment.jpg>


More information about the osg-users mailing list