Re: [osg-users] Getting position of transformed object

2015-02-20 Thread Patryk Piotr
Hi Robert, 

It works! Thank you very much!

Cheers,
Patryk

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





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


Re: [osg-users] Getting position of transformed object

2015-02-19 Thread Robert Osfield
HI Patryk,

You code snippets is a bit confusing - it's way overcomplicated for what it
should be.  My best guess is that you've somehow confused how the
osg::computeLocalToMatrix(NodePath) should be used.  Simply give it the
NodePath from root to specific node of interest, computeLocalToMatrix will
do all the matrix accumulation for you, there isn't any need to
individually multiple the paths of every node in the parental chain as you
seem to be trying to do.

Robert.



On 19 February 2015 at 09:36, Patryk Piotr 
wrote:

> Hi,
>
> I want to  get the position of the center of my cone which was transformed
> earlier. My point is I cannot get that position only by multiplying by
> matrices of PositionAttitudeTransforms. Can someone help me?
>
> Here is the code:
>
> Code:
>
> cone = new osg::Geode();
> cs = new osg::Cone(osg::Vec3(0, 0, 0), std::tan(15.0 * M_PI / 180.0) *
> 2660.0, 2660.0);
> shp = new osg::ShapeDrawable(cs);
>
> rootNode -> addChild(mt);
>
> mt -> addChild(rotation1);
>
> rotation1 -> addChild(airplaneModel);
> rotation1 -> addChild(rotation2);
>
> rotation2 -> addChild(cameraModel);
> rotation2 -> addChild(rotation3);
>
> rotation3 -> addChild(cameraModel2);
> rotation3 -> addChild(trans1);
>
> trans1 -> addChild(rotation4);
>
> rotation4 -> addChild(cone);
>
> cone -> addDrawable(shp);
>
> osgEarth::GeoPoint apGPoint(airplaneModel.latLong, airplaneModel.apLen,
> airplaneModel.apLat, airplaneModel.apHeight, osgEarth::ALTMODE_ABSOLUTE);
> osg::Matrix mat;
> apGPoint.createLocalToWorld(mat);
> airplaneModel.mt -> setMatrix(mat);
>
>
>
>
> Other rotation and trans are PositionAttitudeTransform with set
> attitude/position. Here is how I tried to compute the position:
>
>
> Code:
>
> osg::Vec3d endPoint = osg::Vec3d(0,0,0);
> endPoint = endPoint *
> osg::computeLocalToWorld(airplaneModel.rotation4 ->
> getParentalNodePaths()[0]) *
> osg::computeLocalToWorld(airplaneModel.trans1 ->
> getParentalNodePaths()[0]) *
> osg::computeLocalToWorld(airplaneModel.rotation3 ->
> getParentalNodePaths()[0]) *
> osg::computeLocalToWorld(airplaneModel.rotation2 ->
> getParentalNodePaths()[0]) *
> osg::computeLocalToWorld(airplaneModel.rotation1 ->
> getParentalNodePaths()[0]) *
>airplaneModel.mt -> getMatrix();
>
>
>
>
> Thank you!
>
> Cheers,
> Patryk[/code]
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=62728#62728
>
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Getting position of transformed object

2015-02-19 Thread Patryk Piotr
Hi,

I want to  get the position of the center of my cone which was transformed 
earlier. My point is I cannot get that position only by multiplying by matrices 
of PositionAttitudeTransforms. Can someone help me?

Here is the code:

Code:

cone = new osg::Geode();
cs = new osg::Cone(osg::Vec3(0, 0, 0), std::tan(15.0 * M_PI / 180.0) * 
2660.0, 2660.0);
shp = new osg::ShapeDrawable(cs);

rootNode -> addChild(mt);

mt -> addChild(rotation1);

rotation1 -> addChild(airplaneModel);
rotation1 -> addChild(rotation2);

rotation2 -> addChild(cameraModel);
rotation2 -> addChild(rotation3);

rotation3 -> addChild(cameraModel2);
rotation3 -> addChild(trans1);

trans1 -> addChild(rotation4);

rotation4 -> addChild(cone);

cone -> addDrawable(shp);

osgEarth::GeoPoint apGPoint(airplaneModel.latLong, airplaneModel.apLen, 
airplaneModel.apLat, airplaneModel.apHeight, osgEarth::ALTMODE_ABSOLUTE);
osg::Matrix mat;
apGPoint.createLocalToWorld(mat);
airplaneModel.mt -> setMatrix(mat);




Other rotation and trans are PositionAttitudeTransform with set 
attitude/position. Here is how I tried to compute the position:


Code:

osg::Vec3d endPoint = osg::Vec3d(0,0,0);
endPoint = endPoint * 
osg::computeLocalToWorld(airplaneModel.rotation4 -> getParentalNodePaths()[0]) *
osg::computeLocalToWorld(airplaneModel.trans1 -> 
getParentalNodePaths()[0]) *
osg::computeLocalToWorld(airplaneModel.rotation3 -> 
getParentalNodePaths()[0]) *
osg::computeLocalToWorld(airplaneModel.rotation2 -> 
getParentalNodePaths()[0]) *
osg::computeLocalToWorld(airplaneModel.rotation1 -> 
getParentalNodePaths()[0]) *
   airplaneModel.mt -> getMatrix();




Thank you!

Cheers,
Patryk[/code]

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





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