X-Git-Url: https://git.ucc.asn.au/?p=atyndall%2Fcits2231.git;a=blobdiff_plain;f=scene.c;h=fcbda4ab692c7657f8dd1cc88d2922f96707d038;hp=c650c057dc9db23128a1c7de063239157a8f406b;hb=5bf3130b1623b0f243454f7be5a970e6772b18f5;hpb=55bfed85b24a4fe5471d3fca580e3b86cd74e21d diff --git a/scene.c b/scene.c index c650c05..fcbda4a 100644 --- a/scene.c +++ b/scene.c @@ -1,6 +1,6 @@ /** * CITS2231 Graphics Scene Editor - * @author Ashley Tyndall (20915779) + * @author Ashley Tyndall (20915779), Jenna de la Harpe (20367932) */ #include @@ -111,6 +111,7 @@ void processLightEvents(int id) { */ void processObjectEvents(int id) { addSceneObject(id); + manipulateState = STATE_OBJECT_POSITION_SCALE; glutPostRedisplay(); } @@ -298,21 +299,47 @@ void motion(int x, int y) { break; case STATE_OBJECT_POSITION_SCALE: - //SceneObject co = sceneObjs[curObject]; - + //so.x, so.y, so.z if ( buttonSelected == GLUT_LEFT_BUTTON ) { // w: left/right, h: near/far - + //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 + float diff = (y - starty); + float map = (diff - -((float)height/2))/(0 - -((float)height/2)); + float scaling; + + if ( diff < 0 ) { + scaling = map; + } else { + scaling = pow(1.0/map, diff); + } + + if ( scaling != 0 ) { + + + sceneObjs[curObject].scale[0] *= scaling; + sceneObjs[curObject].scale[1] *= scaling; + sceneObjs[curObject].scale[2] *= scaling; + printf("Diff is %f, Scaling by %f on all axii\n", diff, sceneObjs[curObject].scale[0]); + + } + + starty = y; } + + startx = x; break; case STATE_OBJECT_ROTATION_TEXTURE_SCALE: if ( buttonSelected == GLUT_LEFT_BUTTON ) { // w: rotate on width, h: rotate on h + } else if ( buttonSelected == GLUT_MIDDLE_BUTTON ) { - // w & h, rotate on h + // w: rotate on height, h: texture scale + } break;