did you ask somebody if that works with the static integer "mode". I do not see how OpenSG should see that you changed the value. I think your "key-press event" function there must be something like:
case 't':
{
beginEditCP(yourSwitchPointer);
yourSwitchPointer->setChoice(1);
endEditCP(yourSwitchPointer);
break;
}
case 'p':
{
beginEditCP(yourSwitchPointer);
yourSwitchPointer->setChoice(2);
endEditCP(yourSwitchPointer);
break;
}
By the way, I guess that the first to objects in a switch have the numbers 0 and 1 instead of 1 and 2, but I am not sure there.
Kind regards,
Bjoern
----- Ursprüngliche Nachricht -----
Von: Sajjadul Islam <[EMAIL PROTECTED]>
Datum: Sonntag, 2. März 2008, 19:47
Betreff: [Opensg-users] Using Switch Node with the key press event
An: OpenSG Users <[email protected]>
> Hello,
>
> I am trying a get quite a simple issue done using the SwitchPtr.
>
> Instead of dumping the whole source-code here i think it would
> be better to
> explain the thing that i want to do.
>
> I want to load an object using one of the loader built-in within
> the system,
>
> attach different shader to it and render it using the Switch by
> selecting different
> shader with keyboard event.
>
> Sound quite simple though, things get complicated if i want to
> refer to the same
> geometry and render it with different shader and select the
> particular shader to be
>
> loaded on the screen using the Switch.
>
> 1. I am loading a teapot with the loader and attached a shader
> to it. STATUS - SUCCESS.
>
> 2. I am creating a new node referring to the same geometry that
> i have loaded in step 1 and attached another
>
> shader to that one.
>
> 3. Then i have created a Switch as follows:
>
>
>
> //crate a node with a switch core
> SwitchPtr sw = Switch::create();
>
> beginEditCP(sw, Switch::ChoiceFieldMask);
>
> /*the first choice is set
> to mode
> that will be
> changed with the
> key-press event
> mode is a
> static ineger value
> that gets
> updated with the key-press event
> */
>
> sw->setChoice(mode);
> endEditCP(sw,
> Switch::ChoiceFieldMask);
>
> /*
> Create a Node to hold the switch core
> */
> NodePtr switchNode = Node::create();
>
> beginEditCP(switchNode);
>
> switchNode->setCore(sw);
> switchNode-
> >addChild(utah_teapot1);
> switchNode->addChild(utah_teapot2);
> endEditCP(switchNode);
>
>
>
> 4. And finally i am attaching the node created at step 3
> to the root node as children.
>
>
> 5. In the keyboard event i have the following code:
>
> switch(k)
> {
> case 27:
> {
>
> OSG::osgExit();
> exit(0);
> }
> break;
> case 't': mode =
> 1; break;
>
> case 'p': mode =
> 2; break;
>
> }
>
>
> The matter of fact is that i am loading all the shaders
> initially while creating the scene graph,
> I just want switch between different shaders with keyboard event.
>
>
> But i get a blank screen.!!!!!!, even with the keyboard event.
>
>
> With single shader shader and without Switch i can load the
> shader and render on the screen.
>
>
>
> Please let me know if any one of you need more information to
> get around that issue.
>
>
>
> Cheers
> Sajjad
>
>
>
> > -----------------------------------------------------------------
> --------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/> _______________________________________________
> Opensg-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/opensg-users
-------------------------------------------------------------------------
Dr. Bjoern Zehner
UFZ Centre for Environmental Research Leipzig-Halle
Permoserstrasse 15
04318 Leipzig
Germany
http://www.ufz.de/index.php?en=5673
Tel: ++49 (341) 235 3979
Fax: ++49 (341) 235 3939
------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________ Opensg-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/opensg-users
