Hi,
I create a code to insert an image but doesn't work.
What's wrong?
My core have 3 fields: sizeX, sizeY end Filename.
I create the geometry in this mode
GeometryPtr Image3D::makeImage3D()
{
if (geo != NullFC)
{
subRefCP(geo);
geo = NullFC;
}
ImagePtr imgPtr = Image::create();
imgPtr->read(((std::string)getFilename()).c_str());
addRefCP(imgPtr);
TextureChunkPtr texChunk = TextureChunk::create();
if (texChunk == NULL)
return;
Real32 width = getSizeX(), height = getSizeY();
GeometryPtr geo = makePlaneGeo(width , height , 1, 1);
addRefCP(geo);
beginEditCP(texChunk);
{
texChunk->setScale(true);
texChunk->setWrapS(GL_CLAMP);
texChunk->setWrapT(GL_CLAMP);
texChunk->setMagFilter(GL_NEAREST);
texChunk->setMinFilter(GL_NEAREST);
texChunk->setEnvMode(GL_MODULATE);
}
endEditCP(texChunk);
TextureTransformChunkPtr texTransChunk =
TextureTransformChunk::create();
beginEditCP(texTransChunk);
{
Real32 textureWidth =
osgnextpower2(static_cast<UInt32>(width));
Real32
textureHeight=osgnextpower2(static_cast<UInt32>(height));
Matrix matrix;
matrix.setScale(width / textureWidth,
height / textureHeight, 1.f);
texTransChunk->setMatrix(matrix);
}
endEditCP(texTransChunk);
MaterialChunkPtr matChunk = MaterialChunk::create();
beginEditCP(matChunk);
{
matChunk->setAmbient(Color4f(1.f, 1.f, 1.f, 1.f));
matChunk->setDiffuse(Color4f(1.f, 1.f, 1.f, 1.f));
matChunk->setEmission(Color4f(0.f, 0.f, 0.f, 1.f));
matChunk->setSpecular(Color4f(0.f, 0.f, 0.f, 1.f));
matChunk->setShininess(0);
}
endEditCP(matChunk);
ChunkMaterialPtr m = ChunkMaterial::create();
beginEditCP(m);
{
m->addChunk(texChunk);
m->addChunk(texTransChunk);
m->addChunk(matChunk);
}
endEditCP(m);
beginEditCP(geo, Geometry::MaterialFieldMask);
{
geo->setMaterial(m);
}
endEditCP(geo, Geometry::MaterialFieldMask);
return geo;
}
This core show only a panel but no image!!!
Help me!!
Thanks in advance;
Antonio.
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users