Text archives Help
- From: abe@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r695 - branches/itanium2/fox
- Date: Fri, 4 Nov 2005 00:08:23 -0700 (MST)
Author: abe
Date: Fri Nov 4 00:08:22 2005
New Revision: 695
Modified:
branches/itanium2/fox/FMantaTrackballNav.cc
Log:
Changed trackball dolly from middle mouse button to shift + left button.
Formatted tabs.
M FMantaTrackballNav.cc
Modified: branches/itanium2/fox/FMantaTrackballNav.cc
==============================================================================
--- branches/itanium2/fox/FMantaTrackballNav.cc (original)
+++ branches/itanium2/fox/FMantaTrackballNav.cc Fri Nov 4 00:08:22 2005
@@ -8,7 +8,7 @@
void FMantaTrackballNav::projectToSphere( Vector &result, Real x, Real y,
Real radius ) {
- x /= radius;
+ x /= radius;
y /= radius;
Real rad2 = x*x+y*y;
if(rad2 > 1) {
@@ -25,151 +25,151 @@
// Mouse events.
long FMantaTrackballNav::onKeyPress ( FXObject *sender, FXSelector sel,
void *data ) {
- FXEvent *event = (FXEvent *)data;
- return 1;
+ FXEvent *event = (FXEvent *)data;
+ return 1;
}
long FMantaTrackballNav::onMouseChange( FXObject *sender, FXSelector sel,
void *data ) {
- FXEvent *event = (FXEvent *)data;
- FXushort sel_type = FXSELTYPE( sel );
+ FXEvent *event = (FXEvent *)data;
+ FXushort sel_type = FXSELTYPE( sel );
// Determine the image resolution.
int xres, yres;
bool stereo;
manta_interface->getResolution( manta_channel, stereo, xres, yres );
- Real width = (Real)xres * 0.5;
- Real height = (Real)yres * 0.5;
+ Real width = (Real)xres * 0.5;
+ Real height = (Real)yres * 0.5;
- // Record mouse up and mouse down.
- switch (sel_type) {
- case SEL_LEFTBUTTONPRESS:
- mouse_down[0] = true;
- break;
- case SEL_LEFTBUTTONRELEASE:
- mouse_down[0] = false;
- break;
- case SEL_MIDDLEBUTTONPRESS:
- mouse_down[1] = true;
- break;
- case SEL_MIDDLEBUTTONRELEASE:
- mouse_down[1] = false;
- break;
- case SEL_RIGHTBUTTONPRESS:
- mouse_down[2] = true;
+ // Record mouse up and mouse down.
+ switch (sel_type) {
+ case SEL_LEFTBUTTONPRESS:
+ mouse_down[0] = true;
+ break;
+ case SEL_LEFTBUTTONRELEASE:
+ mouse_down[0] = false;
+ break;
+ case SEL_MIDDLEBUTTONPRESS:
+ mouse_down[1] = true;
+ break;
+ case SEL_MIDDLEBUTTONRELEASE:
+ mouse_down[1] = false;
+ break;
+ case SEL_RIGHTBUTTONPRESS:
+ mouse_down[2] = true;
// printf("Right button. state: 0x%x SHIFTMASK 0x%x\n", event->state,
SHIFTMASK );
- // Two clicks of the right button changes the lookat point.
- if ((event->state & SHIFTMASK) == SHIFTMASK) {
- // New center of rotation.
- Point lookat;
- Vector normal;
+ // Two clicks of the right button changes the lookat point.
+ if ((event->state & SHIFTMASK) == SHIFTMASK) {
+ // New center of rotation.
+ Point lookat;
+ Vector normal;
// std::cerr << "Setting center of rotation. " << event->win_x << " "
<< event->win_y << std::endl;
- if (manta_frame->shootOneRay( event->win_x,
event->win_y, lookat, normal )) {
- manta_interface->addTransaction("camera
lookat",
+ if (manta_frame->shootOneRay( event->win_x, event->win_y, lookat,
normal )) {
+ manta_interface->addTransaction("camera lookat",
Callback::create( this,
&FMantaTrackballNav::mantaLookat, lookat ) );
- }
+ }
- return 1;
- }
+ return 1;
+ }
- // Update rotate from.
- projectToSphere( rotate_from,
-
((Real)event->win_x-width)/width,
-
-((Real)event->win_y-height)/height,
-
trackball_radius );
- break;
- case SEL_RIGHTBUTTONRELEASE:
- mouse_down[2] = false;
- break;
- };
+ // Update rotate from.
+ projectToSphere( rotate_from,
+ ((Real)event->win_x-width)/width,
+ -((Real)event->win_y-height)/height,
+ trackball_radius );
+ break;
+ case SEL_RIGHTBUTTONRELEASE:
+ mouse_down[2] = false;
+ break;
+ };
- // Look for mouse movements.
- if (sel_type == SEL_MOTION && mouse_down[2]) {
+ // Look for mouse movements.
+ if (sel_type == SEL_MOTION && mouse_down[2]) {
- // Update rotate to.
- projectToSphere( rotate_to,
- ((Real)event->win_x-width)/width,
-
-((Real)event->win_y-height)/height,
-
trackball_radius );
+ // Update rotate to.
+ projectToSphere( rotate_to,
+ ((Real)event->win_x-width)/width,
+ -((Real)event->win_y-height)/height,
+ trackball_radius );
- // Check to make sure the vectors are far enough apart.
- Real distance = (rotate_from - rotate_to).length();
- if (distance > 0.001) {
-
- // Create a rotation event.
- AffineTransform rotation;
-
- rotation.initWithRotation( rotate_to, rotate_from );
-
- // Send the rotation to manta.
- manta_interface->addTransaction("trackball rotate",
- Callback::create( this,
&FMantaTrackballNav::mantaTrackball, rotation ) );
-
- // Move the from point of the rotation.
- rotate_from = rotate_to;
- }
- }
- else if (sel_type == SEL_MOTION && mouse_down[1]) {
+ // Check to make sure the vectors are far enough apart.
+ Real distance = (rotate_from - rotate_to).length();
+ if (distance > 0.001) {
+
+ // Create a rotation event.
+ AffineTransform rotation;
+
+ rotation.initWithRotation( rotate_to, rotate_from );
+
+ // Send the rotation to manta.
+ manta_interface->addTransaction("trackball rotate",
+ Callback::create( this,
&FMantaTrackballNav::mantaTrackball, rotation ) );
+
+ // Move the from point of the rotation.
+ rotate_from = rotate_to;
+ }
+ }
+ else if (sel_type == SEL_MOTION && mouse_down[0] && ((event->state &
SHIFTMASK) == SHIFTMASK)) {
- // Create a dolly event.
- Real dolly;
+ // Create a dolly event.
+ Real dolly;
- dolly = ((Real) (event->win_x -
event->last_x))/(width+control_speed);
- dolly *= control_speed;
+ dolly = ((Real) (event->win_x - event->last_x))/(width+control_speed);
+ dolly *= control_speed;
- manta_interface->addTransaction("trackball dolly",
- Callback::create( this,
&FMantaTrackballNav::mantaDolly, dolly ) );
- }
+ manta_interface->addTransaction("trackball dolly",
+ Callback::create( this,
&FMantaTrackballNav::mantaDolly, dolly ) );
+ }
- else if (sel_type == SEL_MOTION && mouse_down[0]) {
+ else if (sel_type == SEL_MOTION && mouse_down[0]) {
- // Create a pan (translation) event.
- Vector translation;
+ // Create a pan (translation) event.
+ Vector translation;
- translation[0] = ((Real)-(event->win_x -
event->last_x))/width;
- translation[1] = ((Real) (event->win_y -
event->last_y))/height;
- translation *= control_speed;
+ translation[0] = ((Real)-(event->win_x - event->last_x))/width;
+ translation[1] = ((Real) (event->win_y - event->last_y))/height;
+ translation *= control_speed;
- manta_interface->addTransaction("trackball pan",
- Callback::create( this,
&FMantaTrackballNav::mantaPan, translation ) );
- }
+ manta_interface->addTransaction("trackball pan",
+ Callback::create( this,
&FMantaTrackballNav::mantaPan, translation ) );
+ }
- return 1;
+ return 1;
}
// These functions are called by the manta thread.
void FMantaTrackballNav::mantaLookat( Point lookat ) {
- Camera *camera = manta_interface->getCamera( manta_channel );
+ Camera *camera = manta_interface->getCamera( manta_channel );
- // Move the camera.
- camera->reset( camera->getPosition(), camera->getUp(), lookat );
+ // Move the camera.
+ camera->reset( camera->getPosition(), camera->getUp(), lookat );
}
void FMantaTrackballNav::mantaTrackball( AffineTransform rotation ) {
- Camera *camera = manta_interface->getCamera( manta_channel );
+ Camera *camera = manta_interface->getCamera( manta_channel );
- // Apply the rotation.
- camera->transform( rotation, Camera::LookAt );
+ // Apply the rotation.
+ camera->transform( rotation, Camera::LookAt );
}
void FMantaTrackballNav::mantaDolly( Real distance ) {
- Camera *camera = manta_interface->getCamera( manta_channel );
+ Camera *camera = manta_interface->getCamera( manta_channel );
- // Dolly the camera.
- camera->dolly( distance );
+ // Dolly the camera.
+ camera->dolly( distance );
}
void FMantaTrackballNav::mantaPan( Vector pan ) {
- Camera *camera = manta_interface->getCamera( manta_channel );
+ Camera *camera = manta_interface->getCamera( manta_channel );
- // Move around the image plane.
- camera->translate( pan );
+ // Move around the image plane.
+ camera->translate( pan );
}
- [MANTA] r695 - branches/itanium2/fox, abe, 11/04/2005
Archive powered by MHonArc 2.6.16.