[osg-users] Edit 3D (osgt) model to add DOFTransform and perform "node" rotation

OpenSceneGraph Users osg-users at lists.openscenegraph.org
Thu Apr 16 06:41:36 PDT 2020


Hi Jeremy, 

 

Yes programmatically. You simply create a  Transform, DOFTransform, whatever and set all the children of the original Group as childs of the new one (transforms, as you surely know are groups too).

Lastly you want to want to set the parent as well. I haven’t used OSG in a while, but this pattern for sure works. 

If you have more questions fell free to ask.

 

Cheers 

Sebastian 

 

From: osg-users <osg-users-bounces at lists.openscenegraph.org> On Behalf Of OpenSceneGraph Users
Sent: Donnerstag, 16. April 2020 14:36
To: OpenSceneGraph Users <osg-users at googlegroups.com>
Subject: Re: [osg-users] Edit 3D (osgt) model to add DOFTransform and perform "node" rotation

 

Sebastian, I've used the nodevisitor to find the node by name, the node just happens to be a osg::group. Could you explain what you mean by "replace them with a DOF-Transform"? I'm optimistic that you mean programmatically. My current approach is to replace it manually in the osgt file.

 

Thanks

Jeremy

On Thursday, April 16, 2020 at 7:14:18 AM UTC-4, OpenSceneGraph Users wrote:

Hi Jeremy, 

 

As your geometry-parts are usually under a transform /group you can use a NodeVisitor to collect those (Find the nodes by name) and replace them with a DOF-Transform. 

You could of course also mess with the osgt-files, but that would be a last resort. 

 

Cheers

Sebastian 

 

From: osg-users <osg-user... at lists.openscenegraph.org <javascript:> > On Behalf Of OpenSceneGraph Users
Sent: Mittwoch, 15. April 2020 21:54
To: OpenSceneGraph Users <osg-... at googlegroups.com <javascript:> >
Subject: [osg-users] Edit 3D (osgt) model to add DOFTransform and perform "node" rotation

 

First off, I hope everyone is staying sane and healthy during this pandemic.

 

I’m working with a collection of 3D models that have come from a variety of different source but are now all in osgb format. For several of the models I’d like to grab a “node” and apply rotation.

 

As I’m working through my understanding of the approach, I’ve created a simple application that loads the model, traverses the scene, returns a pointer to the “node”, casts to a DOFTransform and manipulate the “node” (DOFTransform). Snippet:

FindNamedNodeVisitor fnnv("turret");

scene->accept(fnnv);

osg::ref_ptr<osgSim::DOFTransform> dofTrans = new osgSim::DOFTransform();

dofTrans = dynamic_cast<osgSim::DOFTransform*>(fnnv.getFoundNode()->asTransform());

if(dofTrans != NULL)

                                //manipulate (rotate)   

 

This approach works for the tank.osg model. Now I’m trying to apply this approach to a different model (helicopter for example). When I access the “node” of interest, “Main_Hub” which is an osg::Group I obviously can’t cast that to a osgSim::DOFTransform. I’m trying to get an understand of how I can change the model, now in osgt (readable) format, to a structure that can be used. I’ve been using the tank.osg as a guide and attempted to recreate a similar structure in the helicopter.osgt. I’m trying to take logical stabs in the dark, in the helicopter model I’ve attempted to simply renamed the “node” of interest from an osg::Group to osgSim::DOFTransform. The model still displays correctly, but the cast to osgSim::DOFTransform returns NULL. I thought there may be some required variables at are needed as part of the osgSim::DOFTransform structure, so I began adding currentHPR, currentTranslate, and currentScale and continued to add more bringing it in line with the tank.osg example. Through all the attempts I still getting NULL when casting.

 

I’m looking for any guidance/suggestions/lessons learned on how to properly do this.

 

Thanks in advance

 

Jeremy

-- 
You received this message because you are subscribed to the Google Groups "OpenSceneGraph Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to  <javascript:> osg-users+unsubscribe at googlegroups.com.
To view this discussion on the web visit  <https://groups.google.com/d/msgid/osg-users/cbb4b132-24a7-4e75-b10f-7474c1a99378%40googlegroups.com?utm_medium=email&utm_source=footer> https://groups.google.com/d/msgid/osg-users/cbb4b132-24a7-4e75-b10f-7474c1a99378%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups "OpenSceneGraph Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osg-users+unsubscribe at googlegroups.com <mailto:osg-users+unsubscribe at googlegroups.com> .
To view this discussion on the web visit https://groups.google.com/d/msgid/osg-users/5fcaac09-655d-44f9-bf97-47eee2a19b97%40googlegroups.com <https://groups.google.com/d/msgid/osg-users/5fcaac09-655d-44f9-bf97-47eee2a19b97%40googlegroups.com?utm_medium=email&utm_source=footer> .

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20200416/c3119cb5/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5593 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20200416/c3119cb5/attachment.bin>


More information about the osg-users mailing list