Hi Maria,

The way this works is that the StateSets are concatenated together during traversal.  The StateSets themselves are not affected by each other (parent or otherwise). 

The Cull traverser, for example, concatenates the rootNode stateSet features with the dcs1 stateSet features and then applies them when a drawable is encountered. 

Let me illustrate this more specifically.  Consider that geode1 is a child of dcs1 and contains a Drawable, drawable1 and geode2 is a child of dcs2 and contains a Drawable drawable2.  When the Cull traversal traverses the scene graph, it carries a currentStateSet that is popluated with the features in each of the StateSets encountered in the traversal.

Starting at the rootNode, pushes the currentStateSet  onto the StateSetStack, and gathers FEATURE1, FEATURE2, FEATURE3, FEATURE7, FEATURE8, FEATURE9, FEATURE13, FEATURE14, FEATURE15 from the StateSet contained in rootNode;

Continuing traversal to the next node, dcs1, it then pushes the currentStateSet onto the StateSetStack and adds FEATURE4, FEATURE5, and FEATURE6 to its currentStateSet. 

Continuing traversal, it encounteres the geode1 and a Drawable, which it places into a bin for alter drawing, along with the currentStateSet.  This Drawable will be drawn during the render stage with
FEATURE1, FEATURE2, FEATURE3, FEATURE4, FEATURE5, FEATURE6, FEATURE7, FEATURE8, FEATURE9, FEATURE13, FEATURE14, FEATURE15,

Returning up the scene graph from the traversal, the currentStateSet is set to what is poppped from the StateSetStack, such that back at the rootNode, it is equivalent to rootStateSet.

Continuing traversal now to dcs2, the currentStateSet is pushed to the StateSetStack and concatenated with FEATURE10, FEATURE11, and FEATURE12.  When drawable2 is encountered, it is placed in the draw bin with the currentStateSet.  drawable2 will be drawn with
FEATURE1, FEATURE2, FEATURE3, FEATURE7, FEATURE8, FEATURE9, FEATURE10, FEATURE11, FEATURE12, FEATURE13, FEATURE14, FEATURE15.

It does not matter what order you add StateAttributes (what we've been calling FEATURES) to the StateSets before traversal, as they are not contatenated together until traversal begins.

I hope that answers both questions.

-don




On 10/19/06, [EMAIL PROTECTED] < [EMAIL PROTECTED]> wrote:



Hi all,

I have a very simple question about "
inheritance",  If I define a root with some StateSet features and then some "bins"(then are added to the root) with some others features… Those bin have the  features defined exactly to it or those and the roots features?..

Example:

///////////////////////////////////////////////////////////////////////////////////////////////////////

osg::MatrixTransform* rootNode =
new osg::MatrixTransform;
osg::StateSet* rootStateSet =
new osg::StateSet();
rootStateSet->FEATURE1;

rootStateSet->FEATURE2;

rootStateSet->FEATURE3;

rootNode->setStateSet(rootStateSet);


osg::MatrixTransform* dcs1 =
new osg::MatrixTransform;
osg::StateSet* modelStateSet1 =
new osg::StateSet();
modelStateSet1 ->FEATURE4;

modelStateSet1 ->FEATURE5;

modelStateSet1 ->FEATURE6;


dcs1->setStateSet(modelStateSet1);

rootNode->addChild(dcs1);


rootStateSet->FEATURE7;

rootStateSet->FEATURE8;

rootStateSet->FEATURE9;

rootNode->setStateSet(rootStateSet);


osg::MatrixTransform* dcs2 =
new osg::MatrixTransform;
osg::StateSet* modelStateSet2 =
new osg::StateSet();
modelStateSet2 ->FEATURE10;

modelStateSet2 ->FEATURE11;

modelStateSet2 ->FEATURE12;


dcs2->setStateSet(modelStateSet2);

rootNode->addChild(dcs2);



rootStateSet->FEATURE13;

rootStateSet->FEATURE14;

rootStateSet->FEATURE15;

rootNode->setStateSet(rootStateSet);



//////////////////////////////////////////////////////////////



At the end, Question1 :


rootNode had the features: FEATURE1, FEATURE2, FEATURE3, FEATURE7, FEATURE8, FEATURE9, FEATURE13, FEATURE14, FEATURE15


dcs1: FEATURE1 FEATURE2, FEATURE3, FEATURE4, FEATURE5, FEATURE6


dcs2: FEATURE1, FEATURE2, FEATURE3, FEATURE7, FEATURE8, FEATURE9, FEATURE10, FEATURE11, FEATURE12


..Correct???

Question2:  If I do NOT add any child to the rootnode in the last step( when I add the features13,14,15) do they have effect?


Thanks for all,

Maria.

_____________________________________
María Aróstegui.
Unidad de Siderurgia -- Steel Unit
LABEIN  - Tecnalia



C/Geldo - Parque Tecnológico de Bizkaia
Edifico 700
48160-Derio


Email: [EMAIL PROTECTED]
Tel: +34 94 6073300
Fax: +34 94 6073349
www.labein.es
_____________________________________


_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/


_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to