2

I have two, more or less related, questions:

Currently I'm working on the creation of a simple wire-frame model of a more complicated object in OpenSceneGraph. After creating a very primitive object (a line) at a certain coordinate in space, translating and rotating them around, I want to know the resulting position of the two coordinates of the line. How can this be accomplished in a basic way? I need the coordinate to be able to translate following Groups of Geodes to this point (to "attach" them automatically). What I did to create and translate my line (following this this):

vertices->push_back(osg::Vec3(0,0,0));
vertices->push_back(osg::Vec3(1,0,0));
geom->setVertexArray(vertices);
geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES,0,2));
geode->addDrawable(geom);
pat->addChild(geode);
pat->setPosition(osg::Vec3(0,0,0));

Trying to extract the first point:

osg::Vec3* vertice = (osg::Vec3*)pat->getChild(0)->asGeode()->getDrawable(0)->asGeometry()->getVertexArray();

But this one is still (0,0,0), even after translation to (1,1,1). What did I wrong?

As I want to get into 3D, doing more low-level stuff than necessary helps me to get the concepts right. But what would be the high-level approach to build more complicated objects? An object that isn't static, which has chains of "joints" that can be rotated -- so each rotation of a joint influences the following, attached joints.

edit: got it, easy as pie...: Just a

osg::Vec3* vec = new osg::Vec3(1,0,0);
osg::Matrixd* mat = new osg::Matrixd();
mat->makeRotate(pat->getAttitude());
osg::Vec3 endpoint = mat->preMult((*vec)*length);
Bart
  • 19,692
  • 7
  • 68
  • 77
marvin2k
  • 1,573
  • 2
  • 14
  • 18

0 Answers0