X-Git-Url: https://git.ucc.asn.au/?p=atyndall%2Fcits2231.git;a=blobdiff_plain;f=scene.c;h=27fc5474f8b9d08e2769ff05526103c236d8aece;hp=ffa63dd14f3f7cf7b7772685e66766999cb985c0;hb=2090fa97207b7008eaddbab184478b1720e5fad1;hpb=876a9341282f91027829f3e544ad4e4a7215c682 diff --git a/scene.c b/scene.c index ffa63dd..27fc547 100644 --- a/scene.c +++ b/scene.c @@ -168,8 +168,8 @@ void makeMenu() { glutCreateMenu(processMainEvents); glutAddMenuEntry("Rotate/Move Camera", M_ROTATE_MOVE_CAMERA); glutAddSubMenu("Add object", objectMenu); - //glutAddMenuEntry("Position/Scale", M_POSITION_SCALE); - //glutAddMenuEntry("Rotation/Texture Scale", M_ROTATION_TEXTURE_SCALE); + glutAddMenuEntry("Position/Scale", M_POSITION_SCALE); + glutAddMenuEntry("Rotation/Texture Scale", M_ROTATION_TEXTURE_SCALE); //glutAddSubMenu("Material", materialMenu); glutAddSubMenu("Texture", textureMenu); glutAddSubMenu("Ground texture", gTextureMenu); @@ -302,9 +302,31 @@ void motion(int x, int y) { //so.x, so.y, so.z if ( buttonSelected == GLUT_LEFT_BUTTON ) { // w: left/right, h: near/far - sceneObjs[curObject].x += (x - startx); + //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 scaling; + + if ( diff < 0 ) { + scaling = (diff - -((float)height/2))/(0 - -((float)height/2)); + } else { + scaling = pow(1.1, 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;