X-Git-Url: https://git.ucc.asn.au/?p=atyndall%2Fcits2231.git;a=blobdiff_plain;f=scene.c;h=a8d9596c57cba66c849a537877481abee49d1cc2;hp=ffa63dd14f3f7cf7b7772685e66766999cb985c0;hb=fe551bcf4f464576a9e1e76acc83ba24d0bfe63c;hpb=876a9341282f91027829f3e544ad4e4a7215c682 diff --git a/scene.c b/scene.c index ffa63dd..a8d9596 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); @@ -199,6 +199,9 @@ void windowReshape(int w, int h) { * @param y Mouse y position */ void mouse(int button, int state, int x, int y) { + if ( glutGetModifiers() == GLUT_ACTIVE_SHIFT ) { + button = GLUT_MIDDLE_BUTTON; + } switch(button) { case GLUT_LEFT_BUTTON: case GLUT_MIDDLE_BUTTON: @@ -299,12 +302,22 @@ void motion(int x, int y) { break; case STATE_OBJECT_POSITION_SCALE: - //so.x, so.y, so.z + if ( buttonSelected == GLUT_LEFT_BUTTON ) { // w: left/right, h: near/far - sceneObjs[curObject].x += (x - startx); + //so.x, so.y, so.z + //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 = (x - startx); + float max = (float)height/bigsmallFactor; + float scaling = ( diff + max) / max; + + sceneObjs[curObject].scale[0] *= scaling; + sceneObjs[curObject].scale[1] *= scaling; + sceneObjs[curObject].scale[2] *= scaling; } startx = x;