From faf8b6a77994ac32ffff814c08fe59e70431f5d7 Mon Sep 17 00:00:00 2001 From: Ash Tyndall Date: Sat, 22 Oct 2011 11:30:09 +0800 Subject: [PATCH 1/1] --- globals.c | 2 +- scene.c | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/globals.c b/globals.c index c79395a..7b1a4a1 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, camRotateFactor = 0.5, camAngleFactor = 0.5; -GLfloat leftrightFactor = 0.5, nearfarFactor = 0.5, bigsmallFactor = 0.6, updownFactor = 0.03, rotateFactor = 0.8, texscaleFactor = 0.5; +GLfloat leftrightFactor = 0.5, nearfarFactor = 0.5, bigsmallFactor = 0.6, updownFactor = 0.03, rotateFactor = 0.8, texscaleFactor = 0.05; /* Beginning width, height */ int width = 500, height = 500; diff --git a/scene.c b/scene.c index a0fbff1..b02b4f1 100644 --- a/scene.c +++ b/scene.c @@ -306,7 +306,7 @@ void motion(int x, int y) { if ( buttonSelected == GLUT_LEFT_BUTTON ) { // w: left/right, h: near/far - // **NOTE: Currently a work in progress + // **NOTE: Currently a work in progress, does not work correctly printf("cam angle: %f\n", rotate*camRotateFactor); sceneObjs[curObject].x += diffx * sin(rotate*camRotateFactor); sceneObjs[curObject].z += diffx * cos(rotate*camRotateFactor); @@ -327,19 +327,25 @@ void motion(int x, int y) { break; case STATE_OBJECT_ROTATION_TEXTURE_SCALE: + if ( buttonSelected == GLUT_LEFT_BUTTON ) { // w: rotate on y sceneObjs[curObject].rotation.y += diffx * rotateFactor; + // h: rotate on x sceneObjs[curObject].rotation.x += diffy * rotateFactor; + } else if ( buttonSelected == GLUT_MIDDLE_BUTTON ) { // w: rotate on x sceneObjs[curObject].rotation.x += diffx * rotateFactor; + // h: texture scale float max = (float)height/texscaleFactor; float scaling = (diffy + max) / max; sceneObjs[curObject].texture.scale *= scaling; + } + break; } -- 2.20.1