X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=scene.c;h=4ab75ead5e5faea49efca188babd95d18a8ab22c;hb=7d67d4870c708779b65675a4b6422972af08ee4a;hp=df115d154dc6fd443dd34df01347dc7dd2419937;hpb=3d89d50018205ce3262ee69d780ed0d5e07ecd78;p=atyndall%2Fcits2231.git diff --git a/scene.c b/scene.c index df115d1..4ab75ea 100644 --- a/scene.c +++ b/scene.c @@ -216,10 +216,7 @@ 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) { switch (id) { @@ -252,13 +249,60 @@ void processLightEvents(int id) { void makeMenu() { - glutCreateMenu(processMainEvents); + // 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 ( !objectMenuEntries[j] ) break; // Detect if we've reached the end of the array + glutAddMenuEntry( objectMenuEntries[j], j ); + } + } + + // Construct add object menu + int addObjectMenu = glutCreateMenu(processObjectEvents); + for ( int i = 0; addObjectSubmenu[i]; i++ ) { + char name[10]; // buffer to hold name + sprintf(name, "%d-%d", i*11 - (i-1), i*11 + 9); + glutAddSubMenu( name, addObjectSubmenu[i] ); + } + + + int mainMenu = glutCreateMenu(processMainEvents); glutAddMenuEntry("Rotate/Move Camera", ROTATE_MOVE_CAMERA); - //Add object + 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 @@ -269,22 +313,6 @@ void makeMenu() { glutAttachMenu(GLUT_RIGHT_BUTTON); } - -/*void createGLUTMenus() { - - int menu,submenu; - - submenu = glutCreateMenu(processMenuEvents); - glutAddMenuEntry("Red",RED); - glutAddMenuEntry("Blue",BLUE); - glutAddMenuEntry("Green",GREEN); - - menu = glutCreateMenu(processMenuEvents); - glutAddMenuEntry("White",WHITE); - glutAddSubMenu("RGB Menu",submenu); - glutAttachMenu(GLUT_RIGHT_BUTTON); -*/ - void display() { // You probably want to change both of the following. glClear(GL_COLOR_BUFFER_BIT);