PDA

View Full Version : Children not accessible after saving to/loading OSGb


torbeng
09-10-2013, 07:10 AM
Is there any way to access groups created in Vizard after saving (to OSGb, IVE, OSG or any other type)?
If I create a group and add other groups or objects to it, I can access the children using getChildren(). After saving to OSGb and loading the file, the children are not accessible - getChildren() returns an empty list.

I also tried to create named parent nodes, so they show up with getNodeNames() and can be retrieved using getChild(name). However, I cannot seem to find a way to name a Vizard group. I tried creating an empty layer with startLayer(name) and retrieving it with endLayer(). I then tried adding children to this layer, but it doesn't seem to work. While the layer shows up after saving/loading, the children are not there. I also tried insertGroupAbove and insertGroupBelow, which also failed. As groups do not seem to have a name, I cannot specify the node name to insert the group above or below.

I don't understand why it is impossible to change the name of a group node as this seems to be a part of the internal representation Vizard uses. Is there any way to expose this data to the python code? Can you please show me a way to access groups and there children after saving and loading? Thanks in advance for your help!

torbeng
09-10-2013, 08:57 AM
The only solution to work around this problem I found so far is to save every group to an individual file. However, this introduces some problems. If I use the significantly faster OSGb format, the textures are all duplicated and the GPU memory consumption rises. As I cannot tell Vizard not to embed textures when saving as OSGb, I have to use the OSG format - the city model I used, split into individual blocks, is about 6GB - models only, which takes a while to load. If there is any way to get Vizard to understand that textures in two files are identical to save GPU memory, that would solve some of the issues.

farshizzo
09-11-2013, 02:23 PM
There is an undocumented plugin that allows changing the name of underlying scene graph nodes. Here is sample code showing how to name groups nodes using it:# Load extension
osg = viz.add('SceneGraphTools.dle')

# Set name of group node
group = viz.addGroup()
osg.getRootNode(group).setName('MyGroup')

Regarding saving out OSGB files with images, you can use the following options to have it save the images to file or reference existing image files:"""
OSGB options:

WriteImageHint=<hint>
IncludeData - embed image data
IncludeFile - embed image file
UseExternal - reference existing external file
WriteOut -writes image to external file
"""
viz.res.setFileLoaderOption('WriteImageHint=Includ eData')
model.save('model.osgb')

torbeng
09-12-2013, 03:36 AM
Thanks, that solved it for me!