OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

How to get Node object from PositionAttitudeTransform object


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
nghien_rbc
Newbie


Joined: 20 Jul 2016
Posts: 9

PostPosted: Sat Apr 15, 2017 3:05 am    Post subject:
How to get Node object from PositionAttitudeTransform object
Reply with quote

Hi,

I use PositionAttitudeTransform object to store and set position for my Node object. Like that:
Code:
osg::ref_ptr< osg::PositionAttitudeTransform> pt = new osg::PositionAttitudeTransform;
pt->setPosition( osg::Vec3( Vertex[0], Vertex[1], Vertex[2] ) );
pt->addChild(myNode);


It OK. But after that i can't get my Node from that PositionAttitudeTransform. I try to use dynamic_cast but not success:
Code:
osg::Node* myNode = dynamic_cast<osg::Node*>(pt);

// it return PositionAttitudeTransform type for MyNode, then MyNode become PositionAttitudeTransform object, I want it return Node Object

Please help me how can i get Node from PositionAttitudeTransform object

...

Thank you!

Cheers,
duc
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 10892

PostPosted: Sat Apr 15, 2017 8:26 am    Post subject:
How to get Node object from PositionAttitudeTransform object
Reply with quote

Hi Duc,

You appear a bit confused as to what dynamic_cast does so I'd
recommend looking C++ resources online on the subject, there's such a
wealth of information on C++ usage online it's best place to go for
guidance rather have us try to do the same here.

On the OSG side, to get a child of a group (include a child of
PositionAttitudeTransform), so in you case you simple go :

Node* child = pt->getChild(i); // i is the index number of the
child, 0 for the first

Robert.



On 15 April 2017 at 04:05, duc nguyen <> wrote:
Quote:
Hi,

I use PositionAttitudeTransform object to store and set position for my Node object. Like that:

Code:
osg::ref_ptr< osg::PositionAttitudeTransform> pt = new osg::PositionAttitudeTransform;
pt->setPosition( osg::Vec3( Vertex[0], Vertex[1], Vertex[2] ) );
pt->addChild(myNode);



It OK. But after that i can't get my Node from that PositionAttitudeTransform. I try to use dynamic_cast but not success:

Code:
osg::Node* myNode = dynamic_cast<osg::Node*>(pt);


// it return PositionAttitudeTransform type for MyNode, then MyNode become PositionAttitudeTransform object, I want it return Node Object

Please help me how can i get Node from PositionAttitudeTransform object

...

Thank you!

Cheers,
duc

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








------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts scene object not receiving/casting sh... Meldryt General 0 Thu May 11, 2017 8:01 am View latest post
No new posts Scale problem while transforming obje... YuraIU02 General 1 Sat Apr 15, 2017 4:26 pm View latest post
No new posts How to get the orientation of 3d object? Jiechang Guo General 2 Mon Apr 10, 2017 2:14 pm View latest post
No new posts How do I get a node from a .osg file? MrHypercube General 0 Wed Apr 05, 2017 10:11 pm View latest post
No new posts How to replace the texture data in th... xdfanfan General 1 Wed Apr 05, 2017 12:44 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP