Newbie: how to get coordinates of SoNode object?

Newbie: how to get coordinates of SoNode object?

Post by a.. » Wed, 14 Mar 2001 15:50:18



Hi all,
I've this small problem getting coordinates of a SoNode Object. Could u pl
tell me how to get coordinates when i have SoNode object with me?

SoNode* pPickedNode;
pPickedNode = pPath->getNode(pPath->getLength()-3);

Here I'm getting pointer to a node and I can do other operations using
pPickedNode but i did not find a method in SoNode class that gives me
coordinates of this pointer....

Pl help me how should i get coordinates of pPickedNode?

Tx in adv
Deepesh

 -----  Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web  -----
  http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
   NewsOne.Net prohibits users from posting spam.  If this or other posts

 
 
 

Newbie: how to get coordinates of SoNode object?

Post by MattVeron » Wed, 14 Mar 2001 18:18:06


Hello Deepesh,

If your node is an SoTransform or SoTranslation, you can downcast to that
type, and access the "translation field", which contains the XYZ coordinates.
 Also note that the orientation (right-handed rotation quaternion) can be
accessed from the SoTransform::rotation field.  
Here's an example of how we update the SoTransform or SoTranslation node
that's associated with a "material particle", in our simulation.  
Hope this helps,
Matt Verona
Sugarland Software, Inc.

***
#include "ParticleUpdator.h"
#include <Inventor/nodes/SoTranslation.h>
#include <Inventor/nodes/SoTransform.h>

void ParticleUpdator::handle(Subject*, Execute*)
{
        Vector r(subject.positionWrt(*frame));
        if(transformation->isOfType(SoTranslation::getClassTypeId())) {
                ((SoTranslation*)transformation)->translation.setValue(
                        r[0], r[1], r[2]);
        }
        else if(transformation->isOfType(SoTransform::getClassTypeId()))
{
                ((SoTransform*)transformation)->translation.setValue(
                        r[0], r[1], r[2]);
        }

Quote:}

***


>Hi all,
>I've this small problem getting coordinates of a SoNode Object. Could u
pl
>tell me how to get coordinates when i have SoNode object with me?

>SoNode* pPickedNode;
>pPickedNode = pPath->getNode(pPath->getLength()-3);

>Here I'm getting pointer to a node and I can do other operations using
>pPickedNode but i did not find a method in SoNode class that gives me
>coordinates of this pointer....

>Pl help me how should i get coordinates of pPickedNode?

>Tx in adv
>Deepesh

> -----  Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web
 -----
>  http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
>   NewsOne.Net prohibits users from posting spam.  If this or other posts


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----

 
 
 

Newbie: how to get coordinates of SoNode object?

Post by Rémy Desligne » Wed, 14 Mar 2001 19:12:49


Maybe you sould keep your path and then apply a SoGetMatrixAction on that path in
order to get the cumulated matrix from root to that node. Then you should get the
translation component of that matrix.

Hope this will help

Rmy.


> Hi all,
> I've this small problem getting coordinates of a SoNode Object. Could u pl
> tell me how to get coordinates when i have SoNode object with me?

> SoNode* pPickedNode;
> pPickedNode = pPath->getNode(pPath->getLength()-3);

> Here I'm getting pointer to a node and I can do other operations using
> pPickedNode but i did not find a method in SoNode class that gives me
> coordinates of this pointer....

> Pl help me how should i get coordinates of pPickedNode?

> Tx in adv
> Deepesh

>  -----  Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web  -----
>   http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
>    NewsOne.Net prohibits users from posting spam.  If this or other posts


 
 
 

Newbie: how to get coordinates of SoNode object?

Post by deepe.. » Thu, 15 Mar 2001 14:26:46




>Maybe you sould keep your path and then apply a SoGetMatrixAction on that
path in
>order to get the cumulated matrix from root to that node. Then you should get
the
>translation component of that matrix.

>Hope this will help

>Rmy.


>> Hi all,
>> I've this small problem getting coordinates of a SoNode Object. Could u pl
>> tell me how to get coordinates when i have SoNode object with me?

>> SoNode* pPickedNode;
>> pPickedNode = pPath->getNode(pPath->getLength()-3);

>> Here I'm getting pointer to a node and I can do other operations using
>> pPickedNode but i did not find a method in SoNode class that gives me
>> coordinates of this pointer....

>> Pl help me how should i get coordinates of pPickedNode?

>> Tx in adv
>> Deepesh

>>  -----  Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web
-----
>>   http://newsone.net/ -- Free reading and anonymous posting to 60,000+
groups
>>    NewsOne.Net prohibits users from posting spam.  If this or other posts
>> made through NewsOne.Net violate posting guidelines, email


 -----  Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web  -----
  http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
   NewsOne.Net prohibits users from posting spam.  If this or other posts

 
 
 

Newbie: how to get coordinates of SoNode object?

Post by <matt_ver.. » Thu, 15 Mar 2001 17:11:32


Hello Deepesh,

Another method involves using SoGetMatrixAction on the path to your "picked
node" - you can get this path using SoSearchAction.  Also note that shape
nodes in Inventor have standard "Object coordinate systems", with the geometric
center at the origin of the Object reference frame.  
SoGetMatrixAction computes the 6x6 transformation matrix (homogeneous coordinates),
containing the position (in World coordinates) of the shape's Object frame
origin, as well as the World-to-Object frame rotation
quaternion.
After applying the SoGetMatrixAction to the path, you can access the SbMatrix
object using SoGetMatrixAction::getMatrix() ... then use the SbMatrix::getTransform(...)
method to get the current translation vector, which is the position of the
shape node's object frame origin, in World coordinates.
good luck,
-MV


>Hi all,
>I've this small problem getting coordinates of a SoNode Object. Could u
pl
>tell me how to get coordinates when i have SoNode object with me?

>SoNode* pPickedNode;
>pPickedNode = pPath->getNode(pPath->getLength()-3);

>Here I'm getting pointer to a node and I can do other operations using
>pPickedNode but i did not find a method in SoNode class that gives me
>coordinates of this pointer....

>Pl help me how should i get coordinates of pPickedNode?

>Tx in adv
>Deepesh

> -----  Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web
 -----
>  http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
>   NewsOne.Net prohibits users from posting spam.  If this or other posts


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----