[osg-users] PositionAttitudeTransform - rotation and translation

642 views
Skip to first unread message

Ash Pat

unread,
Oct 23, 2009, 11:34:22 AM10/23/09
to osg-...@lists.openscenegraph.org
Hi,

I'm using PositionAttitudeTransform to add multiple instances of a geometry node. It appears that the rotation and translation are specified with separate methods, setAttitude() and setPosition() respectively. Is that correct?
Can it somehow be done with a single matrix like in homogeneous coordinates?

Thanks in advance,

Regards,
AP

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=18629#18629

_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Andrew Burnett-Thompson

unread,
Oct 23, 2009, 11:40:50 AM10/23/09
to osg-...@lists.openscenegraph.org
Hi there,

I don't have an answer for you but I'm working on the same thing now. This is my thread (with no answer yet)

http://forum.openscenegraph.org/viewtopic.php?t=3845

The solution I proposed there doesn't quite work. If you get/set the individual components then it breaks it. I am also trying to use Matrix::decompose to get the components out of a matrix, but so far no luck.

I'll be listening in here and if I find anything I'll post.

Cheers,
Andrew

Mourad Boufarguine

unread,
Oct 23, 2009, 12:06:21 PM10/23/09
to osg-...@lists.openscenegraph.org
Hi Ash,

You can use MatrixTransform instead of PositionAttitudeTransform. Then you have access to the transform matrix.

Cheers,

Mourad

Andrew Burnett-Thompson

unread,
Oct 23, 2009, 12:55:56 PM10/23/09
to OpenSceneGraph Users
Yes i'm probably trying to do something different to you.

I want to get/set by matrix as well as position, attitude, scale. If you want just to set/get by matrix alone then as mentioned osg::MatrixTransform does the job.

Cheers!
Andrew

Adam Weiss

unread,
Oct 23, 2009, 1:36:13 PM10/23/09
to osg-...@lists.openscenegraph.org

Andrew Burnett-Thompson wrote:
> Yes i'm probably trying to do something different to you.
>
> I want to get/set by matrix as well as position, attitude, scale. If you want just to set/get by matrix alone then as mentioned osg::MatrixTransform does the job.


If you use a MatrixTransform you specify a matrix. I believe you can create the matrix you want (representing all 3 operations) using:

Code:

void makeTranslate( const Vec3f& );
void setRotate(const Quat& q);
void setTrans( const Vec3f& v );


Check the matrix include for the full list of functions. Then:

Code:

void setMatrix(const Matrix& mat)


------------------
Read this topic online here:

http://forum.openscenegraph.org/viewtopic.php?p=18635#18635

Ash Pat

unread,
Oct 23, 2009, 4:28:03 PM10/23/09
to osg-...@lists.openscenegraph.org
Hi,
So I tried the MatrixTransform but it seems to skew the geometry.
When I tried a matrix shown below, I was expecting a simple rigid body translation. But instead I got a display with massive extents.

osg::Matrixd mat;
mat.set ( 1, 0, 0, 0
0, 1, 0, 20,
0, 0, 1, 0,
0, 0, 0, 1 );

Then I tried the following to get some rigid body rotation. What I'm seeing is almost like a rotation with a shear.

osg::Matrixd mat;
mat2.set ( 1, 1.57, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1 );

What am I doing wrong?

Thanks,

Regards,

Ash

------------------
Read this topic online here:

http://forum.openscenegraph.org/viewtopic.php?p=18641#18641

Mourad Boufarguine

unread,
Oct 23, 2009, 4:55:15 PM10/23/09
to osg-...@lists.openscenegraph.org
Hi Ash,

The OSG matrices are treated as row-major matrices (unlike OpenGL). So, you should write :

osg::Matrixd mat;
mat.set ( 1, 0, 0, 0
             0, 1, 0, 0,
             0, 0, 1, 0,
             0, 20, 0, 1 );

to get a rigid translation. The second matrix isn't a rotation matrix, for a rotation around the z axis, you should have something like :

osg::Matrixd mat;
mat.set ( cos(alpha), sin(alpha), 0, 0
             -sin(alpha), cos(alpha), 0, 0,

             0, 0, 1, 0,
             0, 0, 0, 1 );

Hope this helps,
Mourad

Ash Pat

unread,
Oct 27, 2009, 7:14:18 PM10/27/09
to osg-...@lists.openscenegraph.org
Hi Mourad ,
I got it to work. Thank you very much for your prompt responses.

Regards,
Ash

------------------
Read this topic online here:

http://forum.openscenegraph.org/viewtopic.php?p=18788#18788

Reply all
Reply to author
Forward
0 new messages