PDA

View Full Version : <node3d>.save() position and rotation


torbeng
04-16-2012, 05:18 AM
I'm currently trying to apply some transformations (scale, position, rotation) to a model and save it to an .ive file using <node3d>.save(). However, all of these transformations are lost when I open the file.
I played around with the different modes for setting a position, e.g. setPosition(0,0,10,mode=viz.REL_LOCAL), but it does not seem to have any effect. Is there any way to save the model with these transformations applied? Thank you very much for your help in advance.

Jeff
04-16-2012, 06:33 AM
The <node3D>.save command will save a node to either the .ive or .osg format. Transformations made to the node will not be saved.

You'll need to apply the transformation in some modeling software and then export a new version of the model.

farshizzo
04-16-2012, 08:23 AM
If you parent the model to a group node, then saving the group will preserve the transformation of the model. Example:import viz
viz.go()

root = viz.addGroup()
model = viz.add('dojo.osgb',parent=root)
model.setEuler(180,0,0)

root.save('dojo_rotated.osgb')

torbeng
04-16-2012, 08:42 AM
Thanks a lot, this seems to work, at least with some models. For some reason, it does not work with all - I'll have to investigate a bit. Maybe it is a format-specific glitch. Here is an example:

import viz
viz.go()

root = viz.addGroup()
model = viz.add('dojo.osgb',parent=root)
model2 = viz.add('table.wrl',parent=root)
model2.setPosition(2,2,2)
model.setEuler(99,0,0)
model.setPosition(1,1,1)
root.save('dojoandtable.ive')
root.remove()
viz.add("dojoandtable.ive")

If you comment out the last two lines, the table is floating in the air. If you don't, the table is one the floor.

farshizzo
04-16-2012, 08:49 AM
Sorry, I forgot to mention that this will only work with the newer osgb format.

torbeng
04-16-2012, 09:24 AM
Oh, thanks, that clears things up. However, once I have all my models saved as osgb, I cannot open them with any program. Even osgconv fails to convert these models to any other file (including the differnet osg file formats). Do you know of any software product that can successfully open osgb files generated by Vizard except for Vizard?

farshizzo
04-16-2012, 09:53 AM
Unfortunately you won't be able to load the models within an external program. Vizard uses its own osg::Transform derived class for transforming models, so this class can only be serialized within Vizard.

torbeng
04-18-2012, 09:17 AM
Thanks for your help. Does WorldViz have any plans to make a working export/save function a feature of future versions of Vizard?