From: Ash Tyndall Date: Sat, 22 Oct 2011 01:33:17 +0000 (+0800) Subject: (no commit message) X-Git-Url: https://git.ucc.asn.au/?p=atyndall%2Fcits2231.git;a=commitdiff_plain;h=521d3ab9808ad5d15a32a9470508b4c687304ae1;ds=sidebyside --- diff --git a/globals.c b/globals.c index a08eee1..719d6ae 100644 --- a/globals.c +++ b/globals.c @@ -92,7 +92,7 @@ GLfloat emission[] = {0.0, 0.3, 0.3, 1.0}; /* Zoom and rotate tracking */ GLfloat zoom = 0.0, rotate = 0.0, camAngle = 40.0; GLfloat zoomFactor = 0.2, rotateFactor = 0.5, camAngleFactor = 0.5; -GLfloat leftrightFactor = 0.5, nearfarFactor = 0.5, bigsmallFactor = 0.2, updownFactor = 0.5; +GLfloat leftrightFactor = 0.5, nearfarFactor = 0.5, bigsmallFactor = 0.05, updownFactor = 0.5; /* Beginning width, height */ int width = 500, height = 500; diff --git a/scene.c b/scene.c index 7d5456f..d73df53 100644 --- a/scene.c +++ b/scene.c @@ -305,7 +305,17 @@ 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; + + // For big/small scaling, we map negative numbers to 0->1 and positive numbers to 1->inf + float diff = (y - starty); + float scaling; + + if ( scaling < 0 ) { + scaling = (x - -height)/(0 - -height); + } else { + scaling = diff; + } + printf("Scaling by %f on all axii\n", scaling); sceneObjs[curObject].scale[0] += scaling; sceneObjs[curObject].scale[1] += scaling;