Hi Nicolas

Your 3 last plan have vertices order for a QUAD and not for TRIANGLE_STRIP,
except this, i see you 6 planes in my example (attached) based on your code.


HTH
David


2012/3/15 Nico DeLarge <[email protected]>

> Hi folks,
>
> I have a strange problem: I want to draw a cube out of 6 PrimitiveSets
> containing Triangle Strips. Unfortunately, only the one PrimitiveSet out of
> the first 4 vertices is displayed.
>
> It does not matter, if I set a different starting index than 0 in the
> DrawArrays (seems to be ignored), only the first 4 vertices are used.
>
> If I switch the order of the push_back instruction e.g. for the back and
> the top plane (so that the top plane vertices are at the beginning of the
> array), then only the top plane will be displayed.
>
> If I set the start index in the first DrawArrays e.g. to 4 and comment out
> all other PrimitiveSets, still the back plane is displayed, not the top
> plane as expected.
>
> Does anyone know what is wrong with my code? Or any other suggestions?
>
>
>
> Code:
>
> double f64HalfCarLength = 2.0;
> double f64HalfCarWidth = 1.0;
> double f64CarHeight = 1.5;
>
> m_pCarModelBoxGeode = new osg::Geode();
> m_pCarModelTrafo->addChild(m_pCarModelBoxGeode);
>
> m_pCarModelBoxDrawable = new osg::Geometry();
> m_pCarModelBoxGeode->addDrawable(m_pCarModelBoxDrawable);
> m_pCarModelBoxDrawable->setUseDisplayList(true);
>
> //Set Vertices
> m_pCarModelBoxVertices = new osg::Vec3Array();
> m_pCarModelBoxVertices->reserve(24);
> m_pCarModelBoxDrawable->setVertexArray(m_pCarModelBoxVertices);
>
> //Back plane of the car
>
> m_pCarModelBoxVertices->push_back(osg::Vec3(-f64HalfCarLength,-f64HalfCarWidth,0.0));
>
> m_pCarModelBoxVertices->push_back(osg::Vec3(-f64HalfCarLength,-f64HalfCarWidth,f64CarHeight));
>
> m_pCarModelBoxVertices->push_back(osg::Vec3(-f64HalfCarLength,f64HalfCarWidth,0.0));
>
> m_pCarModelBoxVertices->push_back(osg::Vec3(-f64HalfCarLength,f64HalfCarWidth,f64CarHeight));
>
>
>
> //Top plane of the car
>
> m_pCarModelBoxVertices->push_back(osg::Vec3(-f64HalfCarLength,-f64HalfCarWidth,f64CarHeight));
>
> m_pCarModelBoxVertices->push_back(osg::Vec3(f64HalfCarLength,-f64HalfCarWidth,f64CarHeight));
>
> m_pCarModelBoxVertices->push_back(osg::Vec3(-f64HalfCarLength,f64HalfCarWidth,f64CarHeight));
>
> m_pCarModelBoxVertices->push_back(osg::Vec3(f64HalfCarLength,f64HalfCarWidth,f64CarHeight));
>
>
>
> //Front plane of the car
>
> m_pCarModelBoxVertices->push_back(osg::Vec3(f64HalfCarLength,f64HalfCarWidth,f64CarHeight));
>
> m_pCarModelBoxVertices->push_back(osg::Vec3(f64HalfCarLength,-f64HalfCarWidth,f64CarHeight));
>
> m_pCarModelBoxVertices->push_back(osg::Vec3(f64HalfCarLength,f64HalfCarWidth,0.0));
>
> m_pCarModelBoxVertices->push_back(osg::Vec3(f64HalfCarLength,-f64HalfCarWidth,0.0));
>
>
> //Right plane of the car
>
> m_pCarModelBoxVertices->push_back(osg::Vec3(f64HalfCarLength,-f64HalfCarWidth,f64CarHeight));
>
> m_pCarModelBoxVertices->push_back(osg::Vec3(-f64HalfCarLength,-f64HalfCarWidth,f64CarHeight));
>
> m_pCarModelBoxVertices->push_back(osg::Vec3(-f64HalfCarLength,-f64HalfCarWidth,0.0));
>
> m_pCarModelBoxVertices->push_back(osg::Vec3(f64HalfCarLength,-f64HalfCarWidth,0.0));
>
>
> //Bottom plane of the car
>
> m_pCarModelBoxVertices->push_back(osg::Vec3(f64HalfCarLength,+f64HalfCarWidth,0.0));
>
> m_pCarModelBoxVertices->push_back(osg::Vec3(f64HalfCarLength,-f64HalfCarWidth,0.0));
>
> m_pCarModelBoxVertices->push_back(osg::Vec3(-f64HalfCarLength,-f64HalfCarWidth,0.0));
>
> m_pCarModelBoxVertices->push_back(osg::Vec3(-f64HalfCarLength,+f64HalfCarWidth,0.0));
>
>
> //Left plane of the car
>
> m_pCarModelBoxVertices->push_back(osg::Vec3(f64HalfCarLength,f64HalfCarWidth,f64CarHeight));
>
> m_pCarModelBoxVertices->push_back(osg::Vec3(f64HalfCarLength,f64HalfCarWidth,0.0));
>
> m_pCarModelBoxVertices->push_back(osg::Vec3(-f64HalfCarLength,f64HalfCarWidth,0.0));
>
> m_pCarModelBoxVertices->push_back(osg::Vec3(-f64HalfCarLength,f64HalfCarWidth,f64CarHeight));
>
> m_pCarModelBoxDrawable->addPrimitiveSet(new
> osg::DrawArrays(osg::PrimitiveSet::TRIANGLE_STRIP,0,4));
> m_pCarModelBoxDrawable->addPrimitiveSet(new
> osg::DrawArrays(osg::PrimitiveSet::TRIANGLE_STRIP,4,4));
> m_pCarModelBoxDrawable->addPrimitiveSet(new
> osg::DrawArrays(osg::PrimitiveSet::TRIANGLE_STRIP,8,4));
> m_pCarModelBoxDrawable->addPrimitiveSet(new
> osg::DrawArrays(osg::PrimitiveSet::TRIANGLE_STRIP,12,4));
> m_pCarModelBoxDrawable->addPrimitiveSet(new
> osg::DrawArrays(osg::PrimitiveSet::TRIANGLE_STRIP,16,4));
> m_pCarModelBoxDrawable->addPrimitiveSet(new
> osg::DrawArrays(osg::PrimitiveSet::TRIANGLE_STRIP,20,4));
>
>
> //Set plane normals
> m_pCarModelBoxNormals = new osg::Vec3Array();
> m_pCarModelBoxNormals->reserve(6);
> m_pCarModelBoxDrawable->setNormalArray(m_pCarModelBoxNormals);
>
> m_pCarModelBoxDrawable->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE_SET);
>
> m_pCarModelBoxNormals->push_back(osg::Vec3(-1.0,0.0,0.0)); //back
> m_pCarModelBoxNormals->push_back(osg::Vec3(0.0,0.0,1.0)); //top
> m_pCarModelBoxNormals->push_back(osg::Vec3(1.0,0.0,0.0)); //front
> m_pCarModelBoxNormals->push_back(osg::Vec3(0.0,-1.0,0.0)); //right
> m_pCarModelBoxNormals->push_back(osg::Vec3(0.0,0.0,-1.0)); //bottom
> m_pCarModelBoxNormals->push_back(osg::Vec3(0.0,1.0,0.0)); //left
>
>
> //Set box color
> m_pCarModelBoxColor = new osg::Vec4Array();
> m_pCarModelBoxDrawable->setColorArray(m_pCarModelBoxColor);
> m_pCarModelBoxDrawable->setColorBinding(osg::Geometry::BIND_OVERALL);
>
> m_pCarModelBoxColor->push_back(osg::Vec4(0.5,0.5,0.5,1.0));
>
>
>
>
>
> Thank you!
>
> Cheers,
> Nicolas
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=46292#46292
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>

Attachment: nicolas_delarge.7z
Description: application/7z-compressed

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to