X-Git-Url: https://git.ucc.asn.au/?p=atyndall%2Fcits2231.git;a=blobdiff_plain;f=scene.c;h=72d08d078b34516f605522968d5c9646ca84e02c;hp=6d47393250a084c9a7075613fa8c04882d1cd8a1;hb=7947c53d4ab7cbb0525796413d38415f86375c27;hpb=5e6a932345dfe95c3d2b289053b93abfb5c5d4fb diff --git a/scene.c b/scene.c index 6d47393..72d08d0 100644 --- a/scene.c +++ b/scene.c @@ -305,10 +305,23 @@ 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; - 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 = (y - starty); + float scaling; + + if ( diff < 0 ) { + scaling = (diff - -((float)height/2))/(0 - -((float)height/2)); + } else { + scaling = diff; + } + + printf("Diff is %f, Scaling by %f on all axii\n", diff, scaling); + sceneObjs[curObject].scale[0] = scaling; + sceneObjs[curObject].scale[1] = scaling; + sceneObjs[curObject].scale[2] = scaling; + + starty = y; } startx = x;