X-Git-Url: https://git.ucc.asn.au/?p=atyndall%2Fcits2231.git;a=blobdiff_plain;f=scene.c;h=3f211b4028f12f612d8d09e63c89ba00c24aa67c;hp=d351afaf6e46642280b1830f3b0e92eee9e3b025;hb=3d2cc99d5a436f3f1febf9e4b8508388398b6879;hpb=3252ebe3045e51d4cf9ee40f24e7204e230492d6 diff --git a/scene.c b/scene.c index d351afa..3f211b4 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 @@ -110,8 +110,8 @@ void processLightEvents(int id) { * @param id ID of object selected */ void processObjectEvents(int id) { - // **NOTE: For the testing phase, only have the teapot addSceneObject(id); + manipulateState = STATE_OBJECT_POSITION_SCALE; glutPostRedisplay(); } @@ -120,7 +120,10 @@ void processObjectEvents(int id) { * @param id ID of texutre selected */ void processTextureEvents(int id) { - + if ( curObject >= 0 ) { + sceneObjs[curObject].texture = id; + glutPostRedisplay(); + } } /** @@ -168,7 +171,7 @@ void makeMenu() { glutAddMenuEntry("Position/Scale", M_POSITION_SCALE); glutAddMenuEntry("Rotation/Texture Scale", M_ROTATION_TEXTURE_SCALE); //glutAddSubMenu("Material", materialMenu); - //glutAddSubMenu("Texture", textureMenu); + glutAddSubMenu("Texture", textureMenu); glutAddSubMenu("Ground texture", gTextureMenu); //glutAddSubMenu("Lights", lightMenu); glutAddMenuEntry("Exit", M_EXIT); @@ -296,21 +299,32 @@ 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 = (x - startx); + float scaling = ( diff + (float)height/bigsmallFactor ) / ( (float)height/bigsmallFactor ); + + sceneObjs[curObject].scale[0] *= scaling; + sceneObjs[curObject].scale[1] *= scaling; + sceneObjs[curObject].scale[2] *= scaling; } + + 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; @@ -390,12 +404,9 @@ void display() { SceneObject so = sceneObjs[i]; // Apply rotation vector - //GLfloat* rv = &so.rotation.vector; - printf("%f, %f, %f\n", so.rotation.vector[0], so.rotation.vector[1], so.rotation.vector[2]); glRotatef(so.rotation.amount, so.rotation.vector[0], so.rotation.vector[1], so.rotation.vector[2]); // Apply scaling vector - //GLfloat* sv = &so.scale; glScalef(so.scale[0], so.scale[1], so.scale[2]); // Apply translation vector