X-Git-Url: https://git.ucc.asn.au/?p=atyndall%2Fcits2231.git;a=blobdiff_plain;f=scene.c;h=49661b14a2ce786b87cce1c044ac7d3c299a4f0b;hp=a8d9596c57cba66c849a537877481abee49d1cc2;hb=fe589a3051db988450daaf58dd76b2fb321abdba;hpb=fe551bcf4f464576a9e1e76acc83ba24d0bfe63c diff --git a/scene.c b/scene.c index a8d9596..49661b1 100644 --- a/scene.c +++ b/scene.c @@ -199,8 +199,8 @@ void windowReshape(int w, int h) { * @param y Mouse y position */ void mouse(int button, int state, int x, int y) { - if ( glutGetModifiers() == GLUT_ACTIVE_SHIFT ) { - button = GLUT_MIDDLE_BUTTON; + if ( button == GLUT_LEFT_BUTTON && glutGetModifiers() == GLUT_ACTIVE_SHIFT ) { + button = GLUT_MIDDLE_BUTTON; // Holding shift with left button is the same as the middle button } switch(button) { case GLUT_LEFT_BUTTON: @@ -286,13 +286,14 @@ void motion(int x, int y) { switch ( manipulateState ) { case STATE_CAMERA_ROTATE_MOVE: + // w: rotate rotate += (x - startx); if ( buttonSelected == GLUT_LEFT_BUTTON ) { - // w: rotate, h: zoom + // h: zoom zoom += (y - starty); } else if ( buttonSelected == GLUT_MIDDLE_BUTTON ) { - // w: rotate, h: tilt + // h: tilt camAngle += (y - starty); } @@ -308,9 +309,7 @@ void motion(int x, int y) { //so.x, so.y, so.z //sceneObjs[curObject].x += (x - startx)*leftrightFactor; } else if ( buttonSelected == GLUT_MIDDLE_BUTTON ) { - // w: big/small, h: up/down - - // For big/small scaling, we map negative numbers to 0->1 and positive numbers to 1->inf + // w: big/small float diff = (x - startx); float max = (float)height/bigsmallFactor; float scaling = ( diff + max) / max; @@ -318,9 +317,14 @@ void motion(int x, int y) { sceneObjs[curObject].scale[0] *= scaling; sceneObjs[curObject].scale[1] *= scaling; sceneObjs[curObject].scale[2] *= scaling; + + // h: up/down + sceneObjs[curObject].y -= (y - starty) * updownFactor; } + starty = y; startx = x; + break; case STATE_OBJECT_ROTATION_TEXTURE_SCALE: