[osg-submissions] some changes to osgdb_dae (Collada plugin)

Mattias Linde linde at acc.umu.se
Mon Sep 3 09:29:04 PDT 2007


Hi Robert,

Your thoughts about PositionAttitudeTransform are good and I agree that conditional
use would be better. 

The reason it always picked PositionAttitudeTransform was because I wanted to 
make it easy to reposition the nodes when using Collada Physics (which can 
specify that a visual node should be moved according to a ridig body). If the 
nodes outputted from the plugin placed some visual nodes, that are to be updated by a 
rigid bodies, in Group nodes, one would need to replace the nodes before the 
simulation can start.

But of course not all visual nodes are simulated so it's a bit overkill to just go 
for P.A.T.

So I suggest instead that the code should use a P.A.T. if one or more of 
rotate/scale/translate are present OR if a instance_ridig_body targets the 
node, otherwise a Group node.

Then the same functionality will be provided and Group-nodes used as often as possible.

This will handle cases such as:

<node name="VisualCube" id="VisualCube"><instance_geometry url="#cube_geometry"></node> 
...
<instance_ridig_body name="MyCube" body="CubeBody" target="#VisualCube">
...


I can make the changes and resubmit the code if you want to.


/ Mattias

On Mon, Sep 03, 2007 at 10:55:31AM +0100, Robert Osfield wrote:
> Hi Mattias,
> 
> I'm just reviewing your changes and need to get a few things clarified
> as I'm not sure the changes are always appropriate.  I'm not too
> familiar with Collada so can't make quick decisions on it.
> 
> First up, collapsing COLLADA scale, translation, rotation node into a
> single PositionAttitudeTransform certainly makes sense to me.
> 
> However, I am concerned that the code now assumes that a
> PositionAttitudeTransform is required, and looks to me after a quick
> scan with always use one even if there are not transform related nodes
> in the COLLADA graph.  I would have expected a conditional use of
> PositionAttitudeTransform.
> 
> Robert.
> 
> On 8/28/07, Mattias Linde <linde at acc.umu.se> wrote:
> > Hello,
> >
> > We are using Collada and OpenSceneGraph and how the current plugin handles nodes makes
> > the visual stuff hard to control.
> >
> >
> > Collada is a xml-based file format for content exchange. In the files (named .dae) one can
> > have <node> .. </node>.  These nodes can have zero or more rotate, scale and translate tags
> > inside them. Nodes can also contain nodes.
> >
> >
> > The node hierarchy returned from the plugin is deeper than it should be (and loading and saving the
> > same scene a couple of time will make a real mess out of things).
> >
> > I'll give an example to show the problem (some xml remove to make it more readable):
> >
> > <node layer="L1" id="Cube" name="Cube">
> >         <translate sid="translate">0.00000 0.00000 0.00000</translate>
> >         <rotate sid="rotateZ">0 0 1 0.00000</rotate>
> >         <rotate sid="rotateY">0 1 0 -0.00000</rotate>
> >         <rotate sid="rotateX">1 0 0 0.00000</rotate>
> >         <scale sid="scale">1.00000 1.00000 1.00000</scale>
> >         (removed stuff)
> > </node>
> >
> >
> > This will be read in as: (name and node-types)
> >
> >    Cube (Group)
> >       translate (PositionAttitudeTransform)
> >          rotateZ (PositionAttitudeTransform)
> >             rotateY (PositionAttitudeTransform)
> >                rotateX (PositionAttitudeTransform)
> >                   scale (PositionAttitudeTransform)
> >                      Cube-Geometry (Group)
> >                         Material (Geode)
> >
> >
> > If one also wants to use the physics part of collada there can be rigid_body-tags which specify the
> > position of a (visual) node. Now that the node rotation and translation are split into several different
> > PositionAttitudeTransforms there are some problems updating the visual node so it has the same position and
> > rotation as the rigid body. (there is also a comment in the code, "TODO: I am doing transforms wrong. ...")
> >
> >
> > With the changes made to the plugin the example above would be read in as:
> >
> >    Cube (PositionAttitudeTransform)
> >       Cube-Geometry (Group)
> >          Material (Geode)
> >
> >
> >
> > I've attached the changes for review.
> >
> > The code have been tested with a some different collada files.
> >
> > / Mattias
> >
> >
> >
> > _______________________________________________
> > osg-submissions mailing list
> > osg-submissions at lists.openscenegraph.org
> > http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
> >
> >
> >
> _______________________________________________
> osg-submissions mailing list
> osg-submissions at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org


More information about the osg-submissions mailing list