X-Git-Url: https://git.ucc.asn.au/?p=atyndall%2Fcits2231.git;a=blobdiff_plain;f=scene.c;h=3f211b4028f12f612d8d09e63c89ba00c24aa67c;hp=ad7e4bfb08c056ffff6c870f08be40f337f2905b;hb=3d2cc99d5a436f3f1febf9e4b8508388398b6879;hpb=5a9dfd8e5f68b2f6062987a5b67bbd7934828bf1;ds=sidebyside diff --git a/scene.c b/scene.c index ad7e4bf..3f211b4 100644 --- a/scene.c +++ b/scene.c @@ -305,11 +305,14 @@ void motion(int x, int y) { //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 scaling = ( diff + (float)height/bigsmallFactor ) / ( (float)height/bigsmallFactor ); + + sceneObjs[curObject].scale[0] *= scaling; + sceneObjs[curObject].scale[1] *= scaling; + sceneObjs[curObject].scale[2] *= scaling; } startx = x;