devnull wrote:
> Hi all,
> I need to color vertexes of a wrl file. This file has a ChunkMaterial with 
> one MaterialChunk.
> Here is the code I use to do that:
> 
> *********************************************
> ...
> 
> ChunkMaterialPtr chunkMaterial = ChunkMaterialPtr::dcast(geo->getMaterial());
> MaterialChunkPtr chunk = 
> MaterialChunkPtr::dcast((chunkMaterial->getChunks()).front());
> chunk->setLit(true);
> chunk->setColorMaterial(GL_DIFFUSE);
> chunk->setBackColorMaterial(GL_DIFFUSE);
> 
> ...
> 
> GeoColors3fPtr colors = GeoColors3f::create()
> beginEditCP(colors);
> while(...)
>   if(...)
>      colors->addValue(Color3f(1, 0, 0));
>   else(...)
>      colors->addValue(Color3f(0, 1, 0));
> endEditCP(colors);   
> 
> ...
> beginEditCP(geo);
>    geo->setColors(colori);
> endEditCP(geo);
> 
> ********************************************************
> 
> 
> The result is always a gray-colored mesh. I tried also to change material 
> into SimpleMaterial but no changes.
> I have no problem if I use a .raw file.
> 
> Can anybody write down a simple example?

the VRML loader creates Nodes with MaterialGroup cores, because that 
better matches the formats semantics. In that case the materials set on 
geometries below a MaterialGroup are ignored.
Since you are saying your code works for .RAW files changing the 
materials in the MaterialGroups instead of the Geometry should do the trick.

        Hope it helps,
                Carsten

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to