Assuming your "cube" is an osg shape primitive, I guess you would create
the grid as a texture (with transparency), and add it to the cube. eg,
osg::Texture2D* cubeTexture = new osg::Texture2D();
cubeTexture->setImage(osgDB::readImageFile(somePath));
osg::StateSet *ss = cubeGeode->getOrCreateStateSet();
ss->setMode( GL_BLEND, osg::StateAttribute::ON );
ss->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
ss->setTextureAttributeAndModes(0,cubeTexture,osg::StateAttribute::ON);
But better would be to make a grid from a vertex array. eg, this makes
one side of the cube:
size = 10; // number of grid squares
int numVertices = 8 + (size*8);
osg::Geode gridGeode = new osg::Geode();
osg::Geometry* gridLines = new osg::Geometry();
osg::Vec3 myCoords[numVertices];
for (int i = 0; i <= _size; i++)
{
myCoords[i+0+(i*7)] = osg::Vec3(-size, i, 0.0);
myCoords[i+1+(i*7)] = osg::Vec3( size, i, 0.0);
myCoords[i+2+(i*7)] = osg::Vec3(-size, -i, 0.0);
myCoords[i+3+(i*7)] = osg::Vec3( size, -i, 0.0);
myCoords[i+4+(i*7)] = osg::Vec3( i, -size, 0.0);
myCoords[i+5+(i*7)] = osg::Vec3( i, size, 0.0);
myCoords[i+6+(i*7)] = osg::Vec3(-i, -size, 0.0);
myCoords[i+7+(i*7)] = osg::Vec3(-i, size, 0.0);
}
osg::Vec3Array* vertices = new osg::Vec3Array(numVertices,myCoords);
gridLines->setVertexArray(vertices);
gridLines->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES,
0, numVertices));
Hope that helps.
On Fri, 2010-03-26 at 18:53 +0000, Richard Redding wrote:
> Hey All,
>
> Right now I am using OSG to code a cube for viewing an IR LED in 3DOF
> using 2 wiimotes. The problem I am running into right now is how to turn the
> walls of the cube transparent and interlace a grid in the cube to see three
> dimensional movement based on the vectors I have calculated to equate one
> point in three dimensional space for which it will run around inside of the
> cube.
>
> I am calculating the position of the 1 IR LED by triangulating the shortest
> vector between the lines of sight and taking its median.
>
> I am very new to OSG and only have a basic C++/C education.
> I am sorry if this is too trivial of a question.
>
> ...
>
> Thanks all!
>
> Cheers Mates,
> Richard
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=26208#26208
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org