WorldViz User Forum

WorldViz User Forum (
-   Vizard (
-   -   Loading OSG models and orientation (

Joran 05-28-2009 07:06 AM

Loading OSG models and orientation

I have a question about orientation and loading OpenSceneGraph models.

It seems that the OSGExp that can be downloaded from the worldviz site exports the model rotated and calls the root of the scene __VIZARD_NODE__. When loading the model, it will show correctly in vizard, but as soon as you rename this Root node, it will load the model rotated.

I think this mechanism is used by Vizard to detect how the model is rotated. If it does not contain the __VIZARD_NODE__ root, it will applies a modifier so it is orientated correctly for use in Vizard.

I already have a lot of models exported with another exporter. When you just load up the model it works fine, but when you change the parent of child objects, the orientation goes wrong. Here is some example code:


scene = viz.add('data/testscene.ive')
target = scene.getChild('Test1')

This piece of code rotates the Test1 child of testscene.ive. What I do is to attach the object back to the parent it already belonged to. This should not change anything in the orientation.

It this behavior a bug? Is there a workaround (without exporting all the models again)?

Greetings, Joran.

farshizzo 05-28-2009 09:58 PM

The original OSGExp exporter uses a Z-up convention, as opposed to the Y-up convention Vizard uses. The version of the exporter available on our site will export the model using the Y-up convention and name the root node __VIZARD_NODE__. When loading a model in Vizard, if this name is not present, then it will assume the model is using a Z-up convention and insert a transform node to rotate the model into a Y-up convention.

If you detach one of the children from the parent, then the transformation won't be applied to the node, and it will go back to using a Z-up convention.

Other than re-exporting your models, you could create a group node that contains the transformation from Z-up to Y-up (rotate 90 degrees along x-axis) and insert the children underneath this group node.

I could also provide you with the code that is used within our exporter that converts the model from Z-up to Y-up. Using this code you can write a small program that batch converts all your models. This code was written specifically for OSGExp, so it might not work correctly on models that were exported from other programs. Let me know if you want to try this out.

Joran 05-29-2009 05:40 AM



Originally Posted by farshizzo (Post 8013)
If you detach one of the children from the parent, then the transformation won't be applied to the node, and it will go back to using a Z-up convention.

I understand that when I detach a child that it will go back to a Z-up convention. But when I reattach the child to the same parent, shouldn't it be in a Y-up position again?

Greetings, Joran.

farshizzo 05-29-2009 04:58 PM

When you reattach the child to the parent, you need to attach it underneath it's original parent node, or the __VIZARD_NODE__:

This should preserve the Y-up convention.

Joran 06-18-2009 06:43 AM

But doesn't the sample in the first post attach it to the original parent?

All times are GMT -7. The time now is 04:24 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2021, vBulletin Solutions, Inc.
Copyright 2002-2018 WorldViz LLC