Hi,
I can not see why you don't see anything. That might have to do with the shader or with what you do with the returned root.
 
However, you set both, geoUtah1 and geoUtah2 geometries to the same object (utah_teapot1->getCore()). So, I think the material for both will be the same. When you set the material on geoUtah2 you also set the material for geoUtah1 and reverse.
 
You either need to make a deep copy of the geometry, load it two times or have a scenegraph like:
 
                              / MaterialGroup with toonShader - Node with geoUtah1 as core
root - switchNode
                              \ MaterialGroup with phongShader - Node with geoUtah1 as core

However, I have not tried that out. So do not blame me if it does not work.
 
Are you sure your shaders and materials are working independently. Do you see something if you instead of root return your utah_teapot2 node?
 
Kind regards,
Bjoern  
----- Ursprüngliche Nachricht -----
Von: Sajjadul Islam <[EMAIL PROTECTED]>
Datum: Montag, 3. März 2008, 12:06
Betreff: [Opensg-users] Using Switch Node with the key press event
An: OpenSG Users <[email protected]>

> Hello Björn,
>
> I did the necessary changes as suggested, unfortunately i am getting the blank screen.
>
>
> So i am providing you the code snippet where i defined the main scenegraph:
>
>
>
>
> *******************************************************************************
>
>     /*
>     Create the whole scene here
>      - now we load the teapot
>     */
>    
>     NodePtr utah_teapot1 = SceneFileHandler::the().read("teapot.obj");
>
>    
>     //set  a string name for that node
>     //we shall use that string to search
>     setName(utah_teapot1,"UTAH_TEAPOT1");
>    
>     /*
>     Check if the data loading
>     operation was ok or not
>
>     */
>     if(utah_teapot1 == NullFC)
>     {
>         cout << "Loading the specified file was
> not possible." << endl;
>         return NullFC;
>     }
>        
>    
>     //the getCore method returns the
> CoredNodePtr,
>
>     //which all other pointer classes derived from
>     GeometryPtr geoUtah1 =
> GeometryPtr::dcast(utah_teapot1->getCore());
>    
>     /*
>     Now create the material
>     for that for that geometry
>     inside the function createToonScene() - i m
> creating the shader chunk
>
>     */
>     beginEditCP(geoUtah1, Geometry::MaterialFieldMask);
>         geoUtah1-
> >setMaterial(createToonScene());   
> endEditCP(geoUtah1, Geometry::MaterialFieldMask);
>
>     /*
>     Set the geometry to
>
>     the node that we have
>     just read
>     */
>     beginEditCP(utah_teapot1, Node::CoreFieldMask);
>         utah_teapot1-
> >setCore(geoUtah1);   
>     endEditCP(utah_teapot1,
> Node::CoreFieldMask);   
>    
>
>    
>    
>     GeometryPtr geoUtah2 =
> GeometryPtr::dcast(utah_teapot1->getCore());   
>    
>     /*
>     Now create the material
>     for that for that geometry
>     */
>     beginEditCP(geoUtah2, Geometry::MaterialFieldMask);
>
>         geoUtah2-
> >setMaterial(createPhongScene());   
> endEditCP(geoUtah2, Geometry::MaterialFieldMask);   
>    
>    
>     /*
>     Now create a Node for that
>     newly created geometry with
>     the material
>
>     */
>     NodePtr utah_teapot2 = Node::create();
>    
>    
>     beginEditCP(utah_teapot2, Node::CoreFieldMask);
>         utah_teapot2-
> >setCore(geoUtah2);    endEditCP(utah_teapot2,
> Node::CoreFieldMask);
>    
>     //crate a node with a switch core
>    // I declared the SwitchPtr sw as global
>     sw = Switch::create();
>        
>        
>     /*
>     Create a Node to hold the switch core
>     */
>     switchNode = Node::create();
>
>
>    
> beginEditCP(switchNode,Node::ChildrenFieldMask |
>            
>            
>    Node::CoreFieldMask);
>         switchNode->setCore(sw);
>         switchNode-
> >addChild(utah_teapot1);       
> switchNode->addChild(utah_teapot2);
>
>     endEditCP(switchNode,Node::ChildrenFieldMask |
>              
>            
>  Node::CoreFieldMask);   
>    
>     /*
>     At last create the root
>     */
>     NodePtr root = Node::create();
>    
>     beginEditCP(root, Node::CoreFieldMask |
>
>            
>           Node::ChildrenFieldMask);
>            
>     root->setCore(Group::create());
>            
>     root->addChild(switchNode);
>     endEditCP(root, Node::CoreFieldMask |
>            
>         Node::ChildrenFieldMask);
>
>    
>    
>     return root;
>
>
>
> ********************************************************************************
>
>
>
>
> And in the key-press event i have as follows:
>
> ************************************
>
>
>     switch(k)
>     {
>         case 27:
>         {
>            
> OSG::osgExit();       
>     exit(0);
>         }
>         break;
>         case 't':
>         {
>
>             cout
> << "toon" << endl;
>
>            
> beginEditCP(sw, Switch::ChoiceFieldMask);
>            
>     /*the first choice is set to mode
>            
>       that will be changed with the
>            
>       key-press event
>            
>     */
>
>            
>     sw->setChoice(0);
>            
> endEditCP(sw, Switch::ChoiceFieldMask);   
>         }
>         break;
>         case 'p':
>         {
>             cout
> << "phong" << endl;
>
>
>            
> beginEditCP(sw, Switch::ChoiceFieldMask);
>            
>     /*the first choice is set to mode
>            
>       that will be changed with the
>            
>       key-press event
>            
>     */
>
>            
>     sw->setChoice(1);
>            
> endEditCP(sw, Switch::ChoiceFieldMask);   
>            
>         }
>         break;
>         default:
>             break;
>
>
> **************************************
>
>

> > -----------------------------------------------------------------
> --------
> 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

Reply via email to