X-Git-Url: https://git.ucc.asn.au/?p=atyndall%2Fcits2231.git;a=blobdiff_plain;f=scene.c;h=61c95af05498d0a22d68dc6bd989fe670e25fd6b;hp=7d5456fab079adcea1db91de6b8b74542e6b621d;hb=fcbdf0e38fcd0fed685405ff967feb8eb196c790;hpb=84a44257a71818d30cf2bbdea195a0b7d246aa83 diff --git a/scene.c b/scene.c index 7d5456f..61c95af 100644 --- a/scene.c +++ b/scene.c @@ -199,6 +199,9 @@ 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; // Holding shift is the same as the middle button + } switch(button) { case GLUT_LEFT_BUTTON: case GLUT_MIDDLE_BUTTON: @@ -299,17 +302,22 @@ void motion(int x, int y) { break; case STATE_OBJECT_POSITION_SCALE: - //so.x, so.y, so.z + if ( buttonSelected == GLUT_LEFT_BUTTON ) { // w: left/right, h: near/far + //so.x, so.y, so.z //sceneObjs[curObject].x += (x - startx)*leftrightFactor; } else if ( buttonSelected == GLUT_MIDDLE_BUTTON ) { // w: big/small, h: up/down - float scaling = (y - starty);//*bigsmallFactor; - printf("Scaling by %f on all axii\n", scaling); - sceneObjs[curObject].scale[0] += scaling; - sceneObjs[curObject].scale[1] += scaling; - sceneObjs[curObject].scale[2] += scaling; + + // For big/small scaling, we map negative numbers to 0->1 and positive numbers to 1->inf + float diff = (x - startx); + float max = (float)height/bigsmallFactor; + float scaling = ( diff + max) / max; + + sceneObjs[curObject].scale[0] *= scaling; + sceneObjs[curObject].scale[1] *= scaling; + sceneObjs[curObject].scale[2] *= scaling; } startx = x;