I posted a question a while ago about osgManipulator, but didn't get any
replies. My problem is that I want to be able to set the transformation
matrix directly on a selected object, in addition to using the various
osgManipulator widgets. That is, setting the matrix in code should
update the widgets, and interacting with the widgets should update the
matrix. From what I can tell, it's currently only possible to generate
the transformation matrix with osgManipulator - you can't modify the
transformation matrix and see that change reflected back in the widgets.
I would be surprised if nobody has run into this problem before. It
seems like required functionality for many applications where the
widgets in osgManipulator would be most helpful. In my case, I'm trying
to recreate a rudimentary 3D editor and the ability to type specific
translation and rotation values into the GUI is just as important as
being able to directly drag the handles on the manipulator widgets.
I've reached the conclusion that I can't do this with osgManipulator so
I'm considering reimplementing something to suit my needs. I'd really
appreciate it if someone could tell me:
a) that I'm wrong and osgManipulator *can* do this (would be great!)
b) is anybody working on osgManipulator who I could collaborate with on
adding what I need?
c) would it be easier/cleaner/faster to simply start from scratch?
I only propose (c) because it looks to me like osgManipulator is
designed as a sort of message-passing system that incrementally modifies
a transformation matrix. Trying to make that process work backwards
sounds tricky, and making it so you can seamlessly jump between manual
(typing) and direct (click and drag) editing modes sounds even harder.
As always, thanks for listening. :-)
Cheers,
Julian.
_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
You can also use billboards so their position will change with the
manipulator transformation, but they will always direct towards the
observer.
And of course, you might want to check osgWidget that supply GUI tools
for osg scenes, (And if I'm wrong with the description I apologies).
Good luck,
Guy.
Thanks for your response. I think we are thinking of different
manipulators. I'm talking about the classes in the osgManipulator
namespace. Were you referring to camera manipulators like the trackball?
osgManipulator already provides GUI objects for doing the
transformations (just run the osgManipulator example).
That part works OK - I can click and drag the little widgets to
manipulate the model. However, I also want to be able to specify the
manipulation directly. For example, I could drag the widgets around to
scale the model to 0.5, but I also want to be able to type in 0.5 in my
interface and get the same result. Problem is that seems to put the
widgets out of sync with the model. :-(
I haven't looked at osgWidget. Perhaps it does what I need...
Julian.
> However, I also want to be able to specify the
> manipulation directly. For example, I could drag the widgets around to
> scale the model to 0.5, but I also want to be able to type in 0.5 in my
> interface and get the same result. Problem is that seems to put the
> widgets out of sync with the model. :-(
I would have thought that you just need to give the
osgManipulator::Dragger's matrix the same transform as your object's
matrix (assuming your object has an osg::MatrixTransform as a parent,
for example). I don't quite remember the structure, but doesn't the
Dragger decorate the object anyways? So just apply your transform to the
Dragger itself (which is a subclass of osg::MatrixTransform) and both
the object and the manipulator should be transformed in the same way.
If you're talking about changing the object's vertices directly, then
you need to do something a bit different. I did it this way in my
Masters project whenever an object's vertices changed:
void updateDragger(osgManipulator::Dragger* d, osg::Geode* g)
{
osg::BoundingBox bb;
for (unsigned int i = 0; i < g->getNumDrawables(); ++i)
{
bb.expandBy(g->getDrawable(i)->getBound());
}
float x = bb.xMax() - bb.xMin();
float y = bb.yMax() - bb.yMin();
float z = bb.zMax() - bb.zMin();
osg::Vec3d t, s;
osg::Quat q, q2;
d->getMatrix().decompose(t, q, s, q2);
osg::Matrix m = osg::Matrix::rotate(q) * osg::Matrix::scale(x+.1,
y+.1, z+.1);
m.setTrans(d->getMatrix().getTrans() + bb.center());
d->setMatrix(m);
}
(Note that I add 0.1 to the scale so that in the case of a cube for
example, the planes of my TabBoxDragger don't coincide with the cube's
faces. You may want something different, this is just an example)
Hope this helps,
J-S
--
______________________________________________________
Jean-Sebastien Guay jean-seba...@cm-labs.com
http://www.cm-labs.com/
http://whitestar02.webhop.org/