Dear OpenSG-users,
I already have posted some questions concerning OpenSG and headtracking
several month ago. The headtracking is working now, but there are
several problems. I solved some more by trial-and-error rather than
really understanding OpenSG.
So here are my questions, short version:
1. What type of coordinatesystem (lefthand/righthand) does OSG use for
the trackingdata?
2. What are the trackingdata's units expected by OSG? We get millimeter
from the trackingsystem.
3. What is the best practice to manipulate the trackingdata to fit OSG?
What is the best way to get the correct matrix for the manipulation?
Questions, long version:
We are using an ART-trackingsystem. It provides its data in mm in a
right-hand coordinate system. First thing I did was setting up the
ProjectionCameraDecorators and the Tracking, feeding the data without
any manipulation.
First problem: Nothing on the screen. First trial-and-error solution:
All trackingdata has to be scaled by /100 (screencorners and tracking,
see code snippet). It works, but I would still like to know what units
are really expected by OSG.
Next problem: The scene scaled the wrong way. While getting closer to
the screen, the scene got smaller, directly at the screen it became a dot.
For every corner of the screen, I provided the coordinates in
coordinates of the tracking system (via the decorators'
push_back()-memberfunction). For the value of the z-coordinate right at
the screen, it seemed like the scene would be scaled to absolute minimum.
After some trial-and-error again, I came to the following solution:
For the screen's corners z-coordinates I set a value that is located 2
meters behind the actual screen (-3000mm instead of actual -835mm) plus
I had to invert the tracked z-data (see code snippet).
What is the idea behind the data set in the decorators'
push_back()-memberfunction? And how is OSG's coordinatesystem for
trackingdata oriented?
Code snippets (pretty ugly, but cleaning up is done at the end ;) ):
Setting up the Decorators:
(...)
//
// Headtracking:
// UserTrackingNode
//
userTrackingNode = OSG::Node::create();
userTrackingTransform = OSG::Transform::create();
osg::Matrix matrix;
matrix.setIdentity();
EDIT_CP(userTrackingTransform, {
userTrackingTransform->setMatrix(matrix);
});
EDIT_CP(userTrackingNode, {
userTrackingNode->setCore(userTrackingTransform);
});
EDIT_CP(cameraBeacon, {
cameraBeacon->addChild(userTrackingNode);
});
//
// Headtracking:
// Screencoordinates
//
QString screenConfig[12];
screenConfig[0] = ps->getGlobalConfigValue("SLowerleftX",
screenConfig[0]);
screenConfig[1] = ps->getGlobalConfigValue("SLowerleftY",
screenConfig[1]);
screenConfig[2] = ps->getGlobalConfigValue("SLowerleftZ",
screenConfig[2]);
screenConfig[3] = ps->getGlobalConfigValue("SLowerrightX",
screenConfig[3]);
screenConfig[4] = ps->getGlobalConfigValue("SLowerrightY",
screenConfig[4]);
screenConfig[5] = ps->getGlobalConfigValue("SLowerrightZ",
screenConfig[5]);
screenConfig[6] = ps->getGlobalConfigValue("SUpperrightX",
screenConfig[6]);
screenConfig[7] = ps->getGlobalConfigValue("SUpperrightY",
screenConfig[7]);
screenConfig[8] = ps->getGlobalConfigValue("SUpperrightZ",
screenConfig[8]);
screenConfig[9] = ps->getGlobalConfigValue("SUpperleftX",
screenConfig[9]);
screenConfig[10] = ps->getGlobalConfigValue("SUpperleftY",
screenConfig[10]);
screenConfig[11] = ps->getGlobalConfigValue("SUpperleftZ",
screenConfig[11]);
osg::Pnt3f screenLL;
osg::Pnt3f screenLR;
osg::Pnt3f screenUR;
osg::Pnt3f screenUL;
screenLL.setValues(screenConfig[0].toFloat()/100,
screenConfig[1].toFloat()/100,
screenConfig[2].toFloat()/100);
screenLR.setValues(screenConfig[3].toFloat()/100,
screenConfig[4].toFloat()/100,
screenConfig[5].toFloat()/100);
screenUR.setValues(screenConfig[6].toFloat()/100,
screenConfig[7].toFloat()/100,
screenConfig[8].toFloat()/100);
screenUL.setValues(screenConfig[9].toFloat()/100,
screenConfig[10].toFloat()/100,
screenConfig[11].toFloat()/100);
//
// Headtracking:
// Left camera
//
camLeftProj = OSG::ProjectionCameraDecorator::create();
EDIT_CP( camLeftProj, {
camLeftProj->setDecoratee(cam);
camLeftProj->setEyeSeparation(stereoInfo.eyeSep /
stereoInfo.unit);
camLeftProj->setLeftEye(true);
camLeftProj->setUser(userTrackingNode);
camLeftProj->editMFSurface()->push_back(screenLL); // lower left
camLeftProj->editMFSurface()->push_back(screenLR); // lower right
camLeftProj->editMFSurface()->push_back(screenUR); // upper right
camLeftProj->editMFSurface()->push_back(screenUL); // upper left
});
//
// Headtracking:
// Right camera
//
camRightProj = OSG::ProjectionCameraDecorator::create();
EDIT_CP( camRightProj, {
camRightProj->setDecoratee(cam);
camRightProj->setEyeSeparation(stereoInfo.eyeSep /
stereoInfo.unit);
camRightProj->setLeftEye(false);
camRightProj->setUser(userTrackingNode);
camRightProj->editMFSurface()->push_back(screenLL); //
lower left
camRightProj->editMFSurface()->push_back(screenLR); //
lower right
camRightProj->editMFSurface()->push_back(screenUR); //
upper right
camRightProj->editMFSurface()->push_back(screenUL); //
upper left
});
}
(...)
Tracking:
(...)
BodyType trackedBody = dt->getBody(i);
Matrix userTrackingMatrix;
// Process Location
float x, y, z;
x = trackedBody.getLocX()/100;
y = trackedBody.getLocY()/100;
z = -trackedBody.getLocZ()/100;
// Process Transformation
Vec3d rotationX;
Vec3d rotationY;
Vec3d rotationZ;
Quaternion userRotation;
trackedBody = dt->getBody(i);
rotationX.setValues(trackedBody.getRotColRow_1_1(),
trackedBody.getRotColRow_1_2(),
trackedBody.getRotColRow_1_3());
rotationY.setValues(trackedBody.getRotColRow_2_1(),
trackedBody.getRotColRow_2_2(),
trackedBody.getRotColRow_2_3());
rotationZ.setValues(trackedBody.getRotColRow_3_1(),
trackedBody.getRotColRow_3_2(),
trackedBody.getRotColRow_3_3());
userRotation.setValue(Matrix(rotationX,rotationY,rotationZ));
userTrackingMatrix.setIdentity();
userTrackingMatrix.setRotate(userRotation);
userTrackingMatrix.setTranslate(x, y, z);
//userTrackingMatrix.setScale(sceneTransform);
beginEditCP(userTrackingTransform,
osg::Transform::MatrixFieldMask);
userTrackingTransform->setMatrix(userTrackingMatrix);
endEditCP(userTrackingTransform,
osg::Transform::MatrixFieldMask);
(...)
Greetings,
Simon Hohl
------------------------------------------------------------------------------
Centralized Desktop Delivery: Dell and VMware Reference Architecture
Simplifying enterprise desktop deployment and management using
Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
client virtualization framework. Read more!
http://p.sf.net/sfu/dell-eql-dev2dev
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users