Hi Olivier,
a SimpleTexturedMaterial already creates internaly a TextureChunk. You
can add another one but I don't think that's what you want to do. Just
use a ChunkMaterial and for the transparency you need a extra
BlendChunk. I added some example code.
Andreas
ImagePtr img = Image::create();
img->set(Image::OSG_RGBA_PF,640,480,1, 1, 1, 0, tab_rgba);
MaterialChunkPtr matc = MaterialChunk::create();
beginEditCP(matc);
matc->setAmbient(Color4f(0.3f, 0.3f, 0.3f, 1.0f));
matc->setDiffuse(Color4f(1.0f, 1.0f, 1.0f, 1.0f));
matc->setSpecular(Color4f(0.8f, 0.8f, 0.8f, 1.0f));
matc->setShininess(100);
endEditCP(matc);
TextureChunkPtr texc = TextureChunk::create();
beginEditCP(volume_tex);
texc->setImage (img);
texc->setWrapS (GL_CLAMP);
texc->setWrapT (GL_CLAMP);
texc->setMinFilter (GL_LINEAR);
texc->setMagFilter (GL_LINEAR);
texc->setEnvMode (GL_MODULATE);
texc->setScale (false);
endEditCP(volume_tex);
BlendChunkPtr blendc = BlendChunk::create();
beginEditCP(blendc);
blendc->setSrcFactor ( GL_SRC_ALPHA );
blendc->setDestFactor ( GL_ONE_MINUS_SRC_ALPHA );
endEditCP(blendc);
ChunkMaterialPtr cmat = ChunkMaterial::create();
beginEditCP(cmat);
// if you don't need the MaterialChunk just comment the next line
// out and change the TextureChunk env mode to GL_REPLACE
cmat->addChunk(matc);
cmat->addChunk(texc);
cmat->addChunk(blendc);
endEditCP(cmat);
// now modify the image
UInt8 *data = img->getData();
beginEditCP(img, Image::PixelFieldMask);
for(UInt32 i=0;i < img->getSize();++i)
{
*data++ = ...
}
texc->imageContentChanged();
endEditCP(img, Image::PixelFieldMask);
Hello,
I'm new with OpenSG.
I want to apply a texture on a plane and modify it in real time.
So I create a SimpleTexturedMaterial,and add a TextureChunk to it (addChunk) To
modify the RGBA image data(imageContentChange methode on the TextureChunk),but
the alpha component seems never be taken into account(from the initialisation to
the image changes,no transaparancy can be seen...):
extern SimpleTexturedMaterialPtr TX_Plan;
extern TextureChunkPtr TXChunk_Plan;
extern ImagePtr IX_Plan;
(...)
IX_Plan->set(Image::OSG_RGBA_PF,640,480,1, 1, 1, 0,tab_rgba);
beginEditCP(TXChunk_Plan);
TXChunk_Plan->setImage(IX_Plan);
TXChunk_Plan->setInternalFormat(Image::OSG_RGBA_PF);
TXChunk_Plan->setExternalFormat(Image::OSG_RGBA_PF);
TXChunk_Plan->setScale(false);
endEditCP(TXChunk_Plan);
beginEditCP(TX_Plan);
TX_Plan->addChunk(TXChunk_Plan);
endEditCP(TX_Plan);
beginEditCP(Plan);
Plan->setMaterial(TX_Plan);
endEditCP(Plan);
(...)
//I modify the image data
beginEditCP(IX_Plan);
IX_Plan->setData(modified_RGBA_array);
TXChunk_Plan->imageContentChanged(0,640,0,480);
endEditCP(IX_Plan);
Thank you in advance for your help!
olivier
-------------------------------------------------------
This SF.net email is sponsored by Demarc:
A global provider of Threat Management Solutions.
Download our HomeAdmin security software for free today!
http://www.demarc.com/Info/Sentarus/hamr30
_______________________________________________
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
-------------------------------------------------------
This SF.net email is sponsored by Demarc:
A global provider of Threat Management Solutions.
Download our HomeAdmin security software for free today!
http://www.demarc.com/Info/Sentarus/hamr30
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users