Hi List.
Two questions today:
1)
I want to apply a texture (water caustics, there already was a posting
of me about this) to all objects in my Scene. I wrote a little prototype
that creates some TextureChunkPtrs and TexGenChunkPtrs and applies them
to OpenSG default objects like plane, box, torus, etc. Works fine, also
with multiple TextureChunks/TexGenChunks added to a SimpleMaterial /
MaterialGroup.
The problem appears when I try to add a TexGenChunk and a TextureChunk
to a loaded Geometry with a MaterialGroup that already has a Texture or
to a SimpleTexturedMaterial: The added TexGenChunk seems to change the
original TextureCoordinates.
I use this (brute-force) approach to traverse the graph and add the Chunks:
void applyTCtoGeo(NodePtr node,TexGenChunkPtr tg, TextureChunkPtr tx){
OSG::NodeCorePtr pCore = node->getCore();
if ( pCore != OSG::NullFC &&
pCore->getType().isDerivedFrom(OSG::MaterialGroup::getClassType()) ){
MaterialGroupPtr g=MaterialGroupPtr::dcast(pCore);
ChunkMaterialPtr cm=ChunkMaterialPtr::dcast(g->getMaterial());
beginEditCP(cm);
cm->addChunk(tg);
cm->addChunk(tx);
endEditCP(cm);
}
// recursive call to children
for (int i=0; i<node->getNChildren(); i++)
applyTCtoGeo(node->getChild(i),tg,tx);
}
}
As I said, if I've got a loaded object without a texture and I call this
method two times with different Ptrs, it works as expected.
Doesn't work:
SimpleTexturedMaterialPtr mat1 = SimpleTexturedMaterial::create();
beginEditCP(mat1);
mat1->setImage(img);
mat1->setDiffuse(Color3f(1,1,1));
mat1->setLit(true);
mat1->addChunk(tg);//Add TexGenChunkPtr
mat1->addChunk(tx);//Add TexturePtr
endEditCP(mat1);
Works as expected:
SimpleMaterialPtr mat1 = SimpleMaterial::create();
beginEditCP(mat1);
mat1->setDiffuse(Color3f(1,1,1));
mat1->setLit(true);
mat1->addChunk(tg1);
mat1->addChunk(tx1);
mat1->addChunk(tg2);
mat1->addChunk(tx2);
endEditCP(mat1);
Is there something missing?
2)
I've got a MultiDisplayWindow and want to enable GL_FOG. Is there
another way to do this than adding glEnable(GL_FOG) etc. to the render
server application? How can I control the fog settings from the render
client?
Thanks & regards,
Dominik
-------------------------------------------------------
This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
Conference, June 28 - July 1 at the Moscone Center in San Francisco, CA
REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code NWMGYKND
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users