X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=scene.c;h=2ea33671e8a3996f6777cb6436fe6ef3fc571f29;hb=efaba07bb307174e2dc0e57b8fb60fecb14d40d5;hp=b12ed159445d2f47b0401f5cd8a16ff773b828ae;hpb=c012f7cd9295d346519ed24e16e78ce5d553f329;p=atyndall%2Fcits2231.git diff --git a/scene.c b/scene.c index b12ed15..2ea3367 100644 --- a/scene.c +++ b/scene.c @@ -167,6 +167,31 @@ void getTexture(int i) { // getTexture(i) loads texture i if it isn't already lo glBindTexture(GL_TEXTURE_2D, 0); // Back to default texture } +// Menu enum +enum menu { + // Main menu + ROTATE_MOVE_CAMERA, + POSITION_SCALE, + ROTATION_TEXTURE_SCALE, + EXIT, + + // Material submenu + MATERIAL_ALL_RGB, + MATERIAL_AMBIENT_RGB, + MATERIAL_DIFFUSE_RGB, + MATERIAL_SPECULAR_RGB, + MATERIAL_ALL_ADSS, + MATERIAL_RED_ADSS, + MATERIAL_GREEN_ADSS, + MATERIAL_BLUE_ADSS, + + // Light submenu + LIGHT_MOVE_LIGHT_1, + LIGHT_RGBALL_LIGHT_1, + LIGHT_MOVE_LIGHT_2, + LIGHT_RGBALL_LIGHT_2 +}; + // Menu arrays const char *textureMenuEntries[NTEXTURE] = { "1 Plain", "2 Rust", "3 Concrete", "4 Carpet", "5 Beach Sand", @@ -191,13 +216,14 @@ const char *objectMenuEntries[NMESH] = { "51 Chef", "52 Parasaurolophus", "53 Rooster", "54 T-rex" }; -const char *materialMenuEntries[8] = { - "All R/G/B", "Ambient R/G/B", "Diffuse R/G/B", "Specular R/G/B", - "All Amb/Diff/Spec/Shine", "Red Amb/Diff/Spec/Shine", "Green Amb/Diff/Spec/Shine", "Blue Amb/Diff/Spec/Shine" -}; + void processMainEvents(int id) { - if(id == 99) exit(0); + switch (id) { + case EXIT: + exit(0); + + } } void processObjectEvents(int id) { @@ -220,18 +246,71 @@ void processLightEvents(int id) { } + + void makeMenu() { - int main, object, material, texture, gtexture, light; + // Construct material menu + int materialMenu = glutCreateMenu(processMaterialEvents); + glutAddMenuEntry("All R/G/B", MATERIAL_ALL_RGB); + glutAddMenuEntry("Ambient R/G/B", MATERIAL_AMBIENT_RGB); + glutAddMenuEntry("Diffuse R/G/B", MATERIAL_DIFFUSE_RGB); + glutAddMenuEntry("Specular R/G/B", MATERIAL_SPECULAR_RGB); + glutAddMenuEntry("All Amb/Diff/Spec/Shine", MATERIAL_ALL_ADSS); + glutAddMenuEntry("Red Amb/Diff/Spec/Shine", MATERIAL_RED_ADSS); + glutAddMenuEntry("Green Amb/Diff/Spec/Shine", MATERIAL_GREEN_ADSS); + glutAddMenuEntry("Blue Amb/Diff/Spec/Shine", MATERIAL_BLUE_ADSS); + + // Construct light menu + int lightMenu = glutCreateMenu(processLightEvents); + glutAddMenuEntry("Move Light 1", LIGHT_MOVE_LIGHT_1); + glutAddMenuEntry("R/G/B/All Light 1", LIGHT_RGBALL_LIGHT_1); + glutAddMenuEntry("Move Light 2", LIGHT_MOVE_LIGHT_2); + glutAddMenuEntry("R/G/B/All Light 2", LIGHT_RGBALL_LIGHT_2); + + // Construct add object submenus + int objectMenuEntriesSize = sizeof(objectMenuEntries) / sizeof(objectMenuEntries[0]); + int menuNumber = objectMenuEntriesSize / 10 + 1; + int addObjectSubmenu[menuNumber-1]; + + for( int i = 0; i < menuNumber; i++ ) { + addObjectSubmenu[i] = glutCreateMenu(processObjectEvents); + int startNum = i*11 - (i-1); + for ( int j = startNum - 1; j < (startNum+9); j++ ) { + if ( j == objectMenuEntriesSize ) break; // Detect if we've reached the end of the array + glutAddMenuEntry( objectMenuEntries[j], j ); + } + } - object = glutCreateMenu(processObjectEvents); - for ( int i = 0; objectMenuEntries[i]; i++ ) { - glutAddMenuEntry( objectMenuEntries[i], i ); + // Construct add object menu + int addObjectMenu = glutCreateMenu(processObjectEvents); + for ( int i = 0; addObjectSubmenu[i]; i++ ) { + char name[10]; // buffer to hold name + int startNum; i*11 - (i-1); + sprintf(name, "%d-%d", startNum, startNum + 9); + glutAddSubMenu( name, addObjectSubmenu[i] ); } + + + int mainMenu = glutCreateMenu(processMainEvents); + + glutAddMenuEntry("Rotate/Move Camera", ROTATE_MOVE_CAMERA); + glutAddSubMenu("Add object", addObjectMenu); + glutAddMenuEntry("Position/Scale", POSITION_SCALE); + glutAddMenuEntry("Rotation/Texture Scale", ROTATION_TEXTURE_SCALE); + //material + + + glutSetMenu(mainMenu); + glutAddSubMenu("Material", materialMenu); + + //texture + //ground texture + //lights + + glutAddMenuEntry("Exit", EXIT); - glutCreateMenu(processMainEvents); - glutAddMenuEntry("Exit", 99); glutAttachMenu(GLUT_RIGHT_BUTTON); }