Hi Robert
Thanks for the assistance.
I tried using the switch statement as suggested as I think this may
work. However when I switch from one node to another the node doesn't
get displayed.
I've written a simple code to alternate between two node( models) every
time step which is shown below. The problem is the first model is
displayed then for the next 1000 time steps the screen is just blank
with no nodes displayed.
If possible could you check if I'm using the Switch class incorrectly?
Thanks
Tristan
sample code:
int main( int argc, char **argv )
{
Producer::ref_ptr<osg::Group> model1Node;
Producer::ref_ptr<osg::Group> model2Node;
osg::Switch *Switchg = new osg::Switch();
rootNode = new osg::Group();
osgDB::FilePathList pathList = osgDB::getDataFilePathList();
pathList.push_back("/opt/OpenSceneGraph-Data/models/");
osgDB::setDataFilePathList(pathList);
Producer::ref_ptr<osg::Node> model1Node =
osgDB::readNodeFile("model1.OSG");
if (!model1Node)
{
std::cout << " no model1 " << std::endl;
abort();
}
model2Node = (osg::Group*) osgDB::readNodeFile("model2.OSG");
if( ! model2Node)
{
std::cout << "no model2Node" << std::endl;
abort();
}
Switchg->insertChild(2,model2Node.get());
Switchg->insertChild(1,model2Node.get());
rootNode->addChild(Switchg);
.
osgProducer::Viewer viewer;
viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS);
viewer.setSceneData( rootNode.get() );
viewer.realize();
int counter = 0;
bool temp = false;
while( !viewer.done() )
{
viewer.sync();
viewer.update();
if ( counter > 1000)
{
counter = 0;
temp = !temp;
}
else
{
counter++;
}
if (temp == false )
{
Switchg->setSingleChildOn(1);
}
else if (temp == true)
{
Switchg->setSingleChildOn(2);
}
cout << " Counter: " <<counter<<endl;
// fire off the cull and draw traversals of the scene.
viewer.frame();
}
// wait for all cull and draw threads to complete before exit.
viewer.sync();
return 0;
}
On Fri, 2006-11-17 at 09:22 +0000, Robert Osfield wrote:
> HI Tristan,
>
> A node mask is basically a bit mask that undergoes a logical AND with
> the traversal mask, each different traversal can have its own mask.
> Typically in the traversal mask you'll pick out a single bit, and then
> in the node mask switch this bit on or off.
>
> Node masks arn't the only option for switch nodes on and off, there is
> osg::Switch, it turns things on or off for all traversal rather than
> allow switching based on traversal, but it may well suit your needs,
> or perhaps a combination of NodeMask and osg::Switch would be best.
>
> Robert.
>
> On 11/17/06, Tristan McMillan <[EMAIL PROTECTED]> wrote:
> > Hi Osg Users
> >
> > I was wondering if someone could give me a quick run through on how node
> > mask numbering works.
> >
> > I have tried reading up on it and just random implementation but I can't
> > get my numbering system to operate.
> >
> > The task I want to create is somewhat similar to the email sent by Ben
> > regarding a node always visible.
> >
> > My node mask is as follows:
> >
> > I need the terrain to always displayed so I set this as the highest node
> > mask say 0x7. Then I need an explosion to display which at a certain
> > period when collision has occurred so I gave this the node mask 0x4.
> > Also when the collision occurs I need to hide the missile so I gave it
> > the node mask 0x1.
> >
> > The above works fine in that I cull 0x4 on collision and it seems all
> > node mask's less than 0x4 are culled and the explosion is displayed.
> >
> > However now I have implemented multiple camera and I want a hud
> > displayed in one of them. But no matter what combination I can't get the
> > Hud displayed in one window for the whole duration of the visualization.
> >
> > Thanks
> > Tristan
> >
> > _______________________________________________
> > 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/
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/