Hi, Ive got a Problem. I have a Texture file loaded to a osg::Geometry. It is rendered completely different to what it looks like in the gimp. Why?
Here is the code:
Code:
osg::Geometry* WidgElementGeometry = new osg::Geometry();
osg::Vec3Array* WidgElementVert = new osg::Vec3Array;
WidgElementVert->push_back(osg::Vec3(750,550,-1));
WidgElementVert->push_back(osg::Vec3(800,550,-1));
WidgElementVert->push_back(osg::Vec3(800,600,-1));
WidgElementVert->push_back(osg::Vec3(750,600,-1));
osg::DrawElementsUInt* WidgElementInd = new
osg::DrawElementsUInt(osg::PrimitiveSet::POLYGON,0);
WidgElementInd->push_back(0);
WidgElementInd->push_back(1);
WidgElementInd->push_back(2);
WidgElementInd->push_back(3);
osg::Vec2Array* texcoords = new osg::Vec2Array(4);
(*texcoords)[0].set(0.0f, 0.0f);
(*texcoords)[0].set(1.0f, 0.0f);
(*texcoords)[0].set(1.0f, 1.0f);
(*texcoords)[0].set(0.0f, 1.0f);
WidgElementGeometry->setTexCoordArray(0,texcoords);
osg::Texture2D* WidgElementTexture = new osg::Texture2D;
WidgElementTexture->setDataVariance(osg::Object::DYNAMIC);
osg::Image* WidgElementImage;
WidgElementImage = osgDB::readImageFile("WidgElementCorner.tga");
WidgElementTexture->setImage(WidgElementImage);
osg::Vec3Array* WidgElementNormals = new osg::Vec3Array;
WidgElementNormals->push_back(osg::Vec3(0.0f, 0.0f, 1.0f));
WidgElementGeometry->setNormalArray(WidgElementNormals);
WidgElementGeometry->setNormalBinding(osg::Geometry::BIND_OVERALL);
WidgElementGeometry->addPrimitiveSet(WidgElementInd);
WidgElementGeometry->setVertexArray(WidgElementVert);
osg::Geode* WidgGeode = new osg::Geode();
WidgGeode->addDrawable(WidgElementGeometry);
osg::StateSet* WidgElementStateSet = new osg::StateSet();
WidgGeode->setStateSet(WidgElementStateSet);
WidgElementStateSet->setTextureAttributeAndModes(0,WidgElementTexture,
osg::StateAttribute::ON);
WidgElementStateSet->setMode(GL_BLEND, osg::StateAttribute::ON);
WidgElementStateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF);
WidgElementStateSet->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
Thank you!
Cheers,
Thorsten
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=19331#19331
<<attachment: Bildschirmfoto.png>>
<<attachment: WidgElementCorner.png>>
_______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

