David Goering wrote:
Hey,
Well my problem is this, I have a webcam and it looks on a table from a slant, 
and gives me coordinates of an object it finds (a marker). These coordinates 
are then sent to the TransformationMatrix arTransform in order for 
OpenSceneGraph zu render a Model on there.
The problem is, if I move the marker back on the table it should move the model 
as well, but because the camera is slanted it moves the object back and down 
(or up).
So what I wanted to do is adjust the Camera Coordinate System by the angle the 
camera has to the table. So roughly 45°.

So I thought updating arTransform by the rotation, would solve my problem of my 
model not adjusting correctly.

And then I wanted to add scale factors, as the model "slides" off of the 
model....

OK, the MatrixTransform is a node in the scene graph, so it will only transform Drawables that are attached to it as children. You won't see any translations happening in the matrix itself because you haven't given it any points to transform yet.

What you're immediately looking for sounds more like this:

osg::Matrix rot = rot.rotate(osg::DegreesToRadians(45.0),1.0,0.0,0.0);
osg::Matrix sca = sca.scale (1.0,1.0,1.0);
osg::Matrix m = rot * sca;

osg::Vec3 marker_pos = <however you get your marker coordinates>

vec = osg::Vec4(marker_pos, 1.0)
vec = m * vec;

double x = vec.x();
double y = vec.y();
double z = vec.z();


Of course, if that's all you need then there's no reason to be using a scene graph library at all. Instead, once you get the matrix correct, you just need to attach the model as a child of the MatrixTransform, and it should show up in the right place. You might also consider writing a MatrixManipulator to handle updating the transform automatically.

In regard to your camera alignment issue, that's not likely to be something you can eyeball. It would be better to place some additional markers on the table (three markers, not in a straight line, and all visible to the camera would be minimum) and derive a real transform matrix from this. Basically, you know the real-world coordinates of each marker, so you can relate them to the virtual world coordinates as perceived by the camera.

There are lots of papers on the right way to do this out there, try Googling for "augmented reality registration".

This isn't an easy thing to get right, so good luck!  :-)

--"J"

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

Reply via email to