hi,
I'm quite new to both Collada and OSG, but recently I spent some time
understanding the Collada schema a bit more.
As far as I know (please correct me if I'm wrong), you can not inherit
materials in collada's scenegraph-model. you bind an instance of a material
to an instance of geometry, like this:
<node id="Box" name="Box">
...
<instance_geometry url="#box-lib">
<bind_material>
<technique_common>
<instance_material symbol="BlueSG" target="#Blue"/>
</technique_common>
</bind_material>
</instance_geometry>
</node>
As you said the main question is whether we can reproduce the OSG's
StateSet inheriting in collada, or are we forced to create one
material for each geometry that has a different list of statesets
attached to it.
Looking at the Collada-scheme, the element <bind_material> in
<instance_geometry> is not mandatory. You could say, if you do not
define a <bind_material> element, to an instance of geometry, you take
the binding inherited from somewhere else. But I don't think that's
common sense (in Collada). Also, you can define varying input for the
materials in here, like which UVset to use, pervertex-color,
tangents/bitangents, etc..
So it does not make a lot of sense to "inherit" this element from
another geometry....
I guess from the Collada Point-Of-View you should define a bind_material
for each geometry. But that's not at all inefficient. Materials in collada
actually reflect a way of state-inheritance, but from an effect-centric
view. A definition of a material is just an instance of an effect with
the necessary changes
of some parameters to override the default-values, it could be even as
short as this one:
<material id="Blue" name="Blue">
<instance_effect url="#Blue-fx"/>
</material>
So, for example, if you have a stateset with a GLSL-program defined,
and a child-element which inherits it from its parent geode, and locally
changes the uniform value
specular-power only, you would have to define the bound material to this
child element like this:
<material id="GlossyBlue" name="GlossyBlue">
<instance_effect url="#Blue-fx"/>
<setparam ref="specularexp">
<float>80.0</float>
</setparam>
</instance_effect>
</material>
I think, in general, this kind of effect - inheritages makes more sense
than a geode-centric inheritage. It's much easier to reuse this new
material defintion
somewhere else in the scenegraph.
There are a lot of examples with basic-material useage on
http://sourceforge.net/project/showfiles.php?group_id=157838&package_id=204570
posted originally on www.collada.org
greets,
- h
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/