Hi Chenzo,

val chenzo wrote:
> Hi All,
> I will like to change a SimpleMaterial of a loaded VRML file in OpenSG. 
> I have tried three different method and still havent found I a solution 
> and will be very grateful for any help.
> 
> I will like to get a node e.g SQR_1 from my VRML model (code below) and 
> be able to change to the emission color in opensg.
 >
> 1. When I try to retrieve the Geometry of SQR_1 in this case I always 
> get a null pointer.
>      NamedNodeFinder f; //from tutorial 10loading
>   
>     NodePtr sqr = f(scene, "SQR_1");   
>     GeometryPtr geo = GeometryPtr::dcast(seed->getCore()); 

Because SQR_1 is a Transform, casting it to a Geometry doesn't work.

> 2. modifying the NamedNodeFinder class of 10loading tutorial to return a 
> GeometryPtr of SQR_1, changing the material of the Geometry doesnt 
> affect the scenegraph.
> 
> Action::ResultE isGeometry(NodePtr& node){
>     // this tests if the core is derived from geometry
>     if (node->getCore()->getType().isDerivedFrom(Geometry::getClassType())){
>        geo = GeometryPtr::dcast(node->getCore());
>        return Action::Quit;
>     }    
>    
>     return Action::Continue;
> }


True. The problem with VRML Geometry is that in VRML the Appearance is 
independent of the Geometry, while in OpenSG it's not. The workaround that 
OpenSG uses is to create a MaterialGroup and a Geometry for each VRML geometry.

> 3. If I use the MaterialGroup of the node all the other objects of the 
> scenegraph are changed which is not what I want.

Hm, that should not be the case. If you get the MaterialGroup child of SQR_1 
and 
change it's Materials that should only affect the first object. This is the way 
to do it, can you show us the code that doesn't work for this one?

Hope it helps

        Dirk

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to