Cleaned up BIND_PER_PRIMITIVE and array indice usage
This commit is contained in:
parent
caa3a06c70
commit
bab251fc59
@ -306,7 +306,7 @@ osg::Node* createHUD()
|
|||||||
colors = new osg::Vec4Array;
|
colors = new osg::Vec4Array;
|
||||||
colors->push_back(osg::Vec4(0.8-0.1*i,0.1*i,0.2*i, 1.0));
|
colors->push_back(osg::Vec4(0.8-0.1*i,0.1*i,0.2*i, 1.0));
|
||||||
quad->setColorArray(colors);
|
quad->setColorArray(colors);
|
||||||
quad->setColorBinding(osg::Geometry::BIND_PER_PRIMITIVE);
|
quad->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||||
(*vertices)[0]=position;
|
(*vertices)[0]=position;
|
||||||
(*vertices)[1]=position+dx;
|
(*vertices)[1]=position+dx;
|
||||||
(*vertices)[2]=position+dx+dy;
|
(*vertices)[2]=position+dx+dy;
|
||||||
|
@ -208,27 +208,39 @@ Page::Page(Album* album, unsigned int pageNo, const std::string& frontFileName,
|
|||||||
osg::Geometry* geom = new osg::Geometry;
|
osg::Geometry* geom = new osg::Geometry;
|
||||||
geom->setStateSet(album->getBackgroundStateSet());
|
geom->setStateSet(album->getBackgroundStateSet());
|
||||||
|
|
||||||
osg::Vec3Array* coords = new osg::Vec3Array(4);
|
osg::Vec3Array* coords = new osg::Vec3Array(8);
|
||||||
(*coords)[0].set(0.0f,0.0,height);
|
(*coords)[0].set(0.0f,0.0f,0.0f);
|
||||||
(*coords)[1].set(0.0f,0.0,0);
|
(*coords)[1].set(0.0f,0.0f,height);
|
||||||
(*coords)[2].set(width,0.0,0);
|
(*coords)[2].set(0.0f,0.0f,height);
|
||||||
(*coords)[3].set(width,0.0,height);
|
(*coords)[3].set(width,0.0f,height);
|
||||||
|
(*coords)[4].set(width,0.0f,height);
|
||||||
|
(*coords)[5].set(width,0.0f,0.0f);
|
||||||
|
(*coords)[6].set(width,0.0f,0.0f);
|
||||||
|
(*coords)[7].set(0.0f,0.0f,0.0f);
|
||||||
geom->setVertexArray(coords);
|
geom->setVertexArray(coords);
|
||||||
|
|
||||||
|
|
||||||
osg::Vec3Array* normals = new osg::Vec3Array(4);
|
osg::Vec3Array* normals = new osg::Vec3Array(8);
|
||||||
(*normals)[0].set(-1.0f,0.0f,0.0f);
|
(*normals)[0].set(-1.0f,0.0f,0.0f);
|
||||||
(*normals)[1].set(0.0f,0.0f,-1.0f);
|
(*normals)[1].set(-1.0f,0.0f,0.0f);
|
||||||
(*normals)[2].set(1.0f,0.0f,0.0f);
|
(*normals)[2].set(0.0f,0.0f,-1.0f);
|
||||||
(*normals)[3].set(0.0f,0.0f,1.0f);
|
(*normals)[3].set(0.0f,0.0f,-1.0f);
|
||||||
|
(*normals)[4].set(1.0f,0.0f,0.0f);
|
||||||
|
(*normals)[5].set(1.0f,0.0f,0.0f);
|
||||||
|
(*normals)[6].set(0.0f,0.0f,1.0f);
|
||||||
|
(*normals)[7].set(0.0f,0.0f,1.0f);
|
||||||
geom->setNormalArray(normals);
|
geom->setNormalArray(normals);
|
||||||
geom->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE);
|
geom->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
|
||||||
|
|
||||||
osg::Vec2Array* tcoords = new osg::Vec2Array(4);
|
osg::Vec2Array* tcoords = new osg::Vec2Array(8);
|
||||||
(*tcoords)[0].set(0.0f,1.0f);
|
(*tcoords)[0].set(0.0f,0.0f);
|
||||||
(*tcoords)[1].set(0.0f,0.0f);
|
(*tcoords)[1].set(0.0f,1.0f);
|
||||||
(*tcoords)[2].set(1.0f,0.0f);
|
(*tcoords)[2].set(0.0f,1.0f);
|
||||||
(*tcoords)[3].set(1.0f,1.0f);
|
(*tcoords)[3].set(1.0f,1.0f);
|
||||||
|
(*tcoords)[4].set(1.0f,1.0f);
|
||||||
|
(*tcoords)[5].set(0.0f,1.0f);
|
||||||
|
(*tcoords)[6].set(0.0f,1.0f);
|
||||||
|
(*tcoords)[7].set(0.0f,0.0f);
|
||||||
geom->setTexCoordArray(0,tcoords);
|
geom->setTexCoordArray(0,tcoords);
|
||||||
|
|
||||||
osg::Vec4Array* colours = new osg::Vec4Array(1);
|
osg::Vec4Array* colours = new osg::Vec4Array(1);
|
||||||
@ -236,19 +248,6 @@ Page::Page(Album* album, unsigned int pageNo, const std::string& frontFileName,
|
|||||||
geom->setColorArray(colours);
|
geom->setColorArray(colours);
|
||||||
geom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
geom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||||
|
|
||||||
osg::UByteArray* vindices = new osg::UByteArray(8);
|
|
||||||
(*vindices)[0]=0;
|
|
||||||
(*vindices)[1]=1;
|
|
||||||
(*vindices)[2]=1;
|
|
||||||
(*vindices)[3]=2;
|
|
||||||
(*vindices)[4]=2;
|
|
||||||
(*vindices)[5]=3;
|
|
||||||
(*vindices)[6]=3;
|
|
||||||
(*vindices)[7]=0;
|
|
||||||
|
|
||||||
geom->setVertexIndices(vindices);
|
|
||||||
geom->setTexCoordIndices(0,vindices);
|
|
||||||
|
|
||||||
geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES,0,8));
|
geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES,0,8));
|
||||||
|
|
||||||
// set up the geode.
|
// set up the geode.
|
||||||
|
@ -196,7 +196,7 @@ osg::Node* createHUD(osgText::Text* updateText)
|
|||||||
colors = new osg::Vec4Array;
|
colors = new osg::Vec4Array;
|
||||||
colors->push_back(osg::Vec4(0.8-0.1*i,0.1*i,0.2*i, 1.0));
|
colors->push_back(osg::Vec4(0.8-0.1*i,0.1*i,0.2*i, 1.0));
|
||||||
quad->setColorArray(colors);
|
quad->setColorArray(colors);
|
||||||
quad->setColorBinding(osg::Geometry::BIND_PER_PRIMITIVE);
|
quad->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||||
(*vertices)[0]=position;
|
(*vertices)[0]=position;
|
||||||
(*vertices)[1]=position+dx;
|
(*vertices)[1]=position+dx;
|
||||||
(*vertices)[2]=position+dx+dy;
|
(*vertices)[2]=position+dx+dy;
|
||||||
|
Loading…
Reference in New Issue
Block a user