Hi Timo,
looks ok but
// core of the cg_node
if (rebuild == false)
_cgMatGroup = MaterialGroup::create();
...
where do you set the new core?
something like
beginEditCP(materialgroupnode);
materialgroupnode->setCore(_cgMatGroup);
endEditCP(materialgroupnode);
Andreas
Hi all,
in my scenegraph, I have a MaterialGroup (member variable of my class)
above the Node, which contains some geometry. I now want to be able to
switch between wireframe rendering and textured rendering of my geometry
and in order to do so, I wrote a fuction, which replaces the
ChunkMaterial of the MaterialGroup with a new ChunkMaterial. According
to a parameter (which is set properly) the needed chunks are added to
the new material. Both settings work, as long as I preset the parameter
with one of the settings, but switching the parameter doesn't have any
impact on the rendered output.
Simple question: why? ;-) And how can I tell opensg, that the material
of the MaterialGroup has changed.
Thanks in advance for any hint.
Timo
So here is the function:
void WaterScene::createMaterial(ParameterContainer* par, bool rebuild)
{
ChunkMaterialPtr cmat = ChunkMaterial::create();
// ----------------------
// --- Texture Image ----
//-----------------------
//Load the image we want to use as a texture
ImagePtr image = Image::create();
image->read("../../../images/texture01.jpg");
TextureChunkPtr tex = TextureChunk::create();
beginEditCP(tex);
tex->setImage(image);
tex->setMinFilter(GL_LINEAR_MIPMAP_LINEAR);
tex->setMagFilter(GL_LINEAR);
tex->setWrapS(GL_REPEAT);
tex->setWrapT(GL_REPEAT);
tex->setEnvMode(GL_REPLACE);
endEditCP(tex);
// if parameter is set, render wireframe
if (par->getRenderWireframe()){
PolygonChunkPtr polyChunk = PolygonChunk::create();
beginEditCP(polyChunk, PolygonChunk::FrontModeFieldMask |
PolygonChunk::BackModeFieldMask);
{
polyChunk->setFrontMode(GL_LINE);
polyChunk->setBackMode(GL_LINE);
}
endEditCP(polyChunk, PolygonChunk::FrontModeFieldMask |
PolygonChunk::BackModeFieldMask);
beginEditCP(cmat);
{
cmat->addChunk(polyChunk);
}
endEditCP(cmat);
}
else{
beginEditCP(cmat);
{
cmat->addChunk(tex);
}
endEditCP(cmat);
}
// core of the cg_node
if (rebuild == false)
_cgMatGroup = MaterialGroup::create();
beginEditCP(_cgMatGroup);
{
_cgMatGroup->setMaterial(cmat);
}
endEditCP(_cgMatGroup);
}
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users
--
Andreas Zieringer [EMAIL PROTECTED]
Fraunhofer IGD - A4 phone +49 (0)6151 155 289
Fraunhoferstr. 5 fax +49 (0)6151 155 196
D-64283 Darmstadt www.igd.fhg.de/www/igd-a4
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users