new algorithm for spaceball movements

*consolidate motion3 event handeling.
*rotation about focal point.
*translation based on world to screen scale.
*cleanup axes map and constants.
This commit is contained in:
tanderson
2012-02-28 10:42:17 -05:00
parent c3647b3baa
commit 9ffdfbe485
7 changed files with 61 additions and 69 deletions

View File

@@ -320,20 +320,9 @@ SbBool CADNavigationStyle::processSoEvent(const SoEvent * const ev)
// Spaceball & Joystick handling
if (type.isDerivedFrom(SoMotion3Event::getClassTypeId())) {
SoMotion3Event * const event = (SoMotion3Event *) ev;
SoCamera * const camera = viewer->getCamera();
SbVec3f dir = event->getTranslation();
if (camera->getTypeId().isDerivedFrom(SoOrthographicCamera::getClassTypeId())){
static float zoomConstant(-.03f);
dir[2] = 0.0;//don't move the cam for z translation.
SoOrthographicCamera *oCam = static_cast<SoOrthographicCamera *>(camera);
oCam->scaleHeight(1.0-event->getTranslation()[2] * zoomConstant);
}
camera->orientation.getValue().multVec(dir,dir);
camera->position = camera->position.getValue() + dir;
camera->orientation = event->getRotation() * camera->orientation.getValue();
const SoMotion3Event * const event = static_cast<const SoMotion3Event * const>(ev);
if (event)
this->processMotionEvent(event);
processed = TRUE;
}