On 8/30/06, GMD GammerMaxyandex.ru <[EMAIL PROTECTED]> wrote:
The following code draws a rectangular, but the texture is not visible. In osggeometry.cpp all OK. Where my BUG)?
group = new osg::Group;
{
geom = new osg::Geometry();
vertices = new osg::Vec3Array;
geom->setVertexArray(vertices);
vertices->push_back(osg::Vec3(_left,_top,_depth));
vertices->push_back(osg::Vec3(_left+_width,_top,_depth));
vertices->push_back(osg::Vec3(_left+_width,_top+_height,_depth));
vertices->push_back(osg::Vec3(_left,_top+_height,_depth));
//нормали
osg::Vec3Array* normals = new osg::Vec3Array;
normals->push_back(osg::Vec3(0.0f,0.0f,1.0f));
geom->setNormalArray(normals);
geom->setNormalBinding(osg::Geometry::BIND_OVERALL);
//цвет
colors = new osg::Vec4Array;
geom->setColorArray(colors);
colors->clear();
colors->push_back(osg::Vec4(_R,_G,_B,_A));
geom->setColorBinding(osg::Geometry::BIND_OVERALL);
//координаты текстуры
myTexCoords = new osg::Vec2Array;
myTexCoords->clear();
myTexCoords->push_back(osg::Vec2(0,1));
myTexCoords->push_back(osg::Vec2(0,0));
myTexCoords->push_back(osg::Vec2(1,0));
myTexCoords->push_back(osg::Vec2(1,1));
geom->setTexCoordArray(0,myTexCoords);
//индексы
unsigned short myIndices[] =
{
0,
1,
2,
3
};
int numIndices = sizeof(myIndices)/sizeof(unsigned short);
geom->addPrimitiveSet(new osg::DrawElementsUShort(osg::PrimitiveSet::QUADS,numIndices,myIndices));
//добавляем все это в геометрию
//geom->addPrimitiveSet(new osg::DrawArrays(GL_QUADS,0,4));
//настраиваем режимы...
stateset = geom->getOrCreateStateSet();
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
stateset->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF);//?
stateset->setMode(GL_BLEND,osg::StateAttribute::ON);
stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
// set up the texture.
osg::Texture2D* texture = new osg::Texture2D;
image = osgDB::readImageFile("images/zad.png");
texture->setImage(image);
stateset->setTextureAttributeAndModes(0, texture,osg::StateAttribute::ON);
//вставляем все в Geode
geode = new osg::Geode();
geode->addDrawable(geom);
geom->setUpdateCallback(new MyGeometryCallback());
//затем в группу
group->addChild(geode);
}
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/
_______________________________________________ osg-users mailing list [email protected] http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/
