Ejemplo n.º 1
0
OSStatus tool_wind_event_callback(EventHandlerCallRef eventhandler,EventRef event,void *userdata)
{
	int				i,k;
	ControlRef		ctrl;

	GetEventParameter(event,kEventParamDirectObject,typeControlRef,NULL,sizeof(ControlRef),NULL,&ctrl);
	
		// group combo
		
	if (ctrl==group_combo) {
		k=GetControl32BitValue(ctrl);
		
			// no group
			
		if (k==1) {
			group_set(-1);
			return(noErr);
		}
		
			// set a group
			
		group_set(k-3);
		return(noErr);
	}
		
		// buttons
		
	k=-1;
	for ((i=0);(i!=maxtool);i++) {
		if (ctrl==tool_ctrl[i]) {
			k=i;
			break;
		}
	}
	
	if (k!=-1) undo_clear();
	
	switch (k) {
		case 0:
			vertex_mode=vm_none;
            SetControlValue(tool_ctrl[0],1);
            SetControlValue(tool_ctrl[1],0);
            SetControlValue(tool_ctrl[2],0);
			break;
		case 1:
			vertex_mode=vm_lock;
            SetControlValue(tool_ctrl[0],0);
            SetControlValue(tool_ctrl[1],1);
            SetControlValue(tool_ctrl[2],0);
			break;
		case 2:
			vertex_mode=vm_snap;
            SetControlValue(tool_ctrl[0],0);
            SetControlValue(tool_ctrl[1],0);
            SetControlValue(tool_ctrl[2],1);
			break;
		case 3:
			dp_primitive=!dp_primitive;
			break;
		case 4:
			dp_auto_texture=!dp_auto_texture;
			break;
		case 5:
			SetControlValue(tool_ctrl[k],0);			// pop back up
			main_wind_rotate_view();
			main_wind_draw();
			break;
		case 6:
            select_clear();
			dp_wall=!dp_wall;
			break;
		case 7:
            select_clear();
			dp_floor=!dp_floor;
			break;
		case 8:
            select_clear();
			dp_ceiling=!dp_ceiling;
			break;
		case 9:
            select_clear();
			dp_liquid=!dp_liquid;
			break;
		case 10:
            select_clear();
			dp_ambient=!dp_ambient;
			break;
		case 11:
            select_clear();
			dp_object=!dp_object;
			break;
		case 12:
            select_clear();
			dp_lightsoundparticle=!dp_lightsoundparticle;
			break;
		case 13:
            select_clear();
            dp_node=!dp_node;
			break;
		case 14:
			dp_textured=!dp_textured;
			break;
		case 15:
            dp_y_hide=!dp_y_hide;
			break;
		case 16:
			SetControlValue(tool_ctrl[k],0);			// pop back up
			segment_sub_point();
			break;
		case 17:
			SetControlValue(tool_ctrl[k],0);			// pop back up
			segment_add_point();
			break;
		case 18:
			SetControlValue(tool_ctrl[k],0);			// pop back up
			segment_tesselate();
			break;
		case 19:
			SetControlValue(tool_ctrl[k],0);			// pop back up
			launch_map_script_editor();
			break;
		case 20:
			SetControlValue(tool_ctrl[k],0);			// pop back up
			launch_engine();
			break;
			
	}
    
    menu_fix_enable();
    
    main_wind_draw();
			
	return(noErr);
}
Ejemplo n.º 2
0
Archivo: map_menu.c Proyecto: rzel/dim3
bool map_menu_event_run(int cmd)
{
	d3ang			rot_ang;

	switch (cmd) {
            
			// file menu
			
		case map_menu_item_FileSave:
			file_save_map();
			return(TRUE);

		case map_menu_item_FileQuit:
			if (file_close_map()) {
				os_application_quit();
			}
			return(TRUE);
			
			// edit menu
			
		case map_menu_item_EditUndo:
			map_undo_pull();
			return(TRUE);
			
		case map_menu_item_EditDelete:
			piece_delete();
			return(TRUE);
			
		case map_menu_item_EditDuplicate:
			piece_duplicate();
			return(TRUE);
			
		case map_menu_item_EditSelectMore:
			piece_select_more();
			return(TRUE);
			
			// view menu
			
		case map_menu_item_ViewFront:
			view_face_front();
			main_wind_draw();
			break;
			
		case map_menu_item_ViewLeft:
			view_face_left();
			main_wind_draw();
			break;
			
		case map_menu_item_ViewRight:
			view_face_right();
			main_wind_draw();
			break;
			
		case map_menu_item_ViewBack:
			view_face_back();
			main_wind_draw();
			break;
			
		case map_menu_item_ViewTop:
			view_face_top();
			main_wind_draw();
			break;
			
		case map_menu_item_ViewBottom:
			view_face_bottom();
			main_wind_draw();
			break;

		case map_menu_item_ViewPerspective:
			view_perspective_ortho(FALSE);
			main_wind_menu_update();
			main_wind_draw();
			return(TRUE);
			
		case map_menu_item_ViewOrtho:
			view_perspective_ortho(TRUE);
			main_wind_menu_update();
			main_wind_draw();
			return(TRUE);
			
		case map_menu_item_ViewUVLayer1:
			view_set_uv_layer(uv_layer_normal);
			main_wind_menu_update();
			main_wind_draw();
			return(TRUE);
			
		case map_menu_item_ViewUVLayer2:
			view_set_uv_layer(uv_layer_light_map);
			main_wind_menu_update();
			main_wind_draw();
			return(TRUE);
			
		case map_menu_item_ViewGotoSelect:
			map_view_goto_select();
			main_wind_draw();
			return(TRUE);
			
		case map_menu_item_ViewGotoMapCenter:
			map_view_goto_map_center(view_get_current_view());
			main_wind_draw();
			return(TRUE);
			
		case map_menu_item_ViewClip:
			view_flip_clip();
			main_wind_menu_update();
			main_wind_draw();
			return(TRUE);
			
		case map_menu_item_ViewShowHideLiquids:
			select_remove_type(item_map_liquid);
			state.map.show_liquid=!state.map.show_liquid;
			main_wind_menu_update();
			main_wind_draw();
			break;

		case map_menu_item_ViewShowHideSpots:
			select_remove_type(item_map_spot);
			select_remove_type(item_map_scenery);
			state.map.show_object=!state.map.show_object;
			main_wind_menu_update();
			main_wind_draw();
			break;
			
		case map_menu_item_ViewShowHideLights:
			select_remove_type(item_map_light);
			select_remove_type(item_map_sound);
			select_remove_type(item_map_particle);
			state.map.show_lightsoundparticle=!state.map.show_lightsoundparticle;
			main_wind_menu_update();
			main_wind_draw();
			break;
			
		case map_menu_item_ViewShowHideNodes:
			select_remove_type(item_map_node);
			state.map.show_node=!state.map.show_node;
			main_wind_menu_update();
			main_wind_draw();
			break;
			
		case map_menu_item_ViewShowHideMovements:
			state.map.show_movements=!state.map.show_movements;
			main_wind_menu_update();
			main_wind_draw();
			break;

		case map_menu_item_ViewSplitHorizontal:
			view_split_horizontal();
			main_wind_menu_update();
			main_wind_draw();
			break;
			
		case map_menu_item_ViewSplitVertical:
			view_split_vertical();
			main_wind_menu_update();
			main_wind_draw();
			break;
			
		case map_menu_item_ViewRemoveSplit:
			view_split_remove();
			main_wind_menu_update();
			main_wind_draw();
			break;
			
			// map menu

		case map_menu_item_MapRaiseY:
			map_mesh_move_all(0,-2000,0);
			main_wind_draw();
			return(TRUE);
			
		case map_menu_item_MapLowerY:
			map_mesh_move_all(0,2000,0);
			main_wind_draw();
			return(TRUE);
			
		case map_menu_item_MapCenter:
			map_mesh_center_all();
			main_wind_draw();
			return(TRUE);
			
		case map_menu_item_MapResetUV:
			map_mesh_reset_uv_all();
			main_wind_draw();
			return(TRUE);

		case map_menu_item_MapResetNormals:
			os_set_wait_cursor();
			map_recalc_normals(&map,FALSE);
			os_set_arrow_cursor();
			main_wind_draw();
			return(TRUE);

		case map_menu_item_MapSortMeshPolys:
			os_set_wait_cursor();
			map_mesh_sort_polys(&map);
			os_set_arrow_cursor();
			main_wind_draw();
			return(TRUE);
			
		case map_menu_item_ClearLightMaps:
			light_maps_clear();
			view_set_uv_layer(uv_layer_normal);
			main_wind_menu_update();
			main_wind_draw();
			return(TRUE);
			
		case map_menu_item_BuildLightMaps:
			if (light_maps_create()) {
				view_set_uv_layer(uv_layer_light_map);
				main_wind_menu_update();
				main_wind_draw();
			}
			return(TRUE);

		case map_menu_item_BuildLiquidReflectionMaps:
			liquid_reflection_maps_create();
			return(TRUE);

		case map_menu_item_AutoGenerateTextures:
			view_map_auto_generate_textures();
			return(TRUE);

		case map_menu_item_AutoGenerateMap:
			view_map_auto_generate_start();
			return(TRUE);

		case map_menu_item_Run:
			launch_engine();
			return(TRUE);
			            
			// mesh menu

		case map_menu_item_MeshCombine:
			piece_combine_mesh();
			main_wind_draw();
			return(TRUE);
			
		case map_menu_item_MeshSplit:
			piece_split_mesh();
			main_wind_draw();
			return(TRUE);
			
		case map_menu_item_MeshTesselate:
			piece_tesselate(TRUE);
			return(TRUE);

		case map_menu_item_MeshDistort:
			piece_distort();
			return(TRUE);
			
		case map_menu_item_MeshResize:
			piece_resize();
			return(TRUE);

		case map_menu_item_MeshForceGrid:
			piece_force_grid();
			return(TRUE);

		case map_menu_item_MeshFlipX:
			piece_flip(TRUE,FALSE,TRUE);
			return(TRUE);
			
		case map_menu_item_MeshFlipY:
			piece_flip(FALSE,TRUE,FALSE);
			return(TRUE);
			
		case map_menu_item_MeshFlipZ:
			piece_flip(FALSE,FALSE,TRUE);
			return(TRUE);
			
		case map_menu_item_MeshRotateX:
			rot_ang.x=90.0f;
			rot_ang.y=rot_ang.z=0.0f;
			piece_rotate(&rot_ang);
			return(TRUE);
			
		case map_menu_item_MeshRotateY:
			rot_ang.y=90.0f;
			rot_ang.x=rot_ang.z=0.0f;
			piece_rotate(&rot_ang);
			return(TRUE);
			
		case map_menu_item_MeshRotateZ:
			rot_ang.z=90.0f;
			rot_ang.x=rot_ang.y=0.0f;
			piece_rotate(&rot_ang);
			return(TRUE);

		case map_menu_item_MeshFreeRotate:
			piece_free_rotate();
			return(TRUE);

		case map_menu_item_MeshRaiseY:
			piece_move(0,-100,0);
			main_wind_draw();
			return(TRUE);
            
		case map_menu_item_MeshLowerY:
			piece_move(0,100,0);
            main_wind_draw();
 			return(TRUE);

		case map_menu_item_MeshSelectAllPoly:
			piece_mesh_select_all_poly();
			main_wind_draw();
			return(TRUE);
			
		case map_menu_item_MeshResetUV:
			piece_reset_uvs(FALSE);
			main_wind_draw();
			return(TRUE);
			
		case map_menu_item_MeshWholeUV:
			piece_whole_uvs(FALSE);
			main_wind_draw();
			return(TRUE);
			
		case map_menu_item_MeshSingleUV:
			piece_single_uvs(FALSE);
			main_wind_draw();
			return(TRUE);
			
		case map_menu_item_MeshCreateNormals:
			piece_mesh_recalc_normals(FALSE);
			main_wind_draw();
			return(TRUE);
			
		case map_menu_item_MeshInvertNormals:
			piece_mesh_invert_normals(FALSE);
			main_wind_draw();
			return(TRUE);

		case map_menu_item_MeshSetNormalsOut:
			piece_mesh_set_normals_in_out(TRUE);
			main_wind_draw();
			return(TRUE);

		case map_menu_item_MeshSetNormalsIn:
			piece_mesh_set_normals_in_out(FALSE);
			main_wind_draw();
			return(TRUE);
			
			// polygon menu
			
		case map_menu_item_PolygonHole:
			piece_poly_hole();
			return(TRUE);
			
		case map_menu_item_PolyTesselate:
			piece_tesselate(FALSE);
			return(TRUE);
			
		case map_menu_item_PolygonRotateUV:
			piece_rotate_uvs();
			main_wind_draw();
			return(TRUE);
			
		case map_menu_item_PolygonFlipU:
			piece_flip_uvs(TRUE,FALSE);
			main_wind_draw();
			return(TRUE);
			
		case map_menu_item_PolygonFlipV:
			piece_flip_uvs(FALSE,TRUE);
			main_wind_draw();
			return(TRUE);
			
		case map_menu_item_PolygonRecalcNormal:
			piece_mesh_recalc_normals(TRUE);
			main_wind_draw();
			return(TRUE);
			
		case map_menu_item_PolygonInvertNormal:
			piece_mesh_invert_normals(TRUE);
			main_wind_draw();
			return(TRUE);

		case map_menu_item_PolygonResetUV:
			piece_reset_uvs(TRUE);
			main_wind_draw();
			return(TRUE);
			
		case map_menu_item_PolygonWholeUV:
			piece_whole_uvs(TRUE);
			main_wind_draw();
			return(TRUE);
			
		case map_menu_item_PolygonSingleUV:
			piece_single_uvs(TRUE);
			main_wind_draw();
			return(TRUE);

	}
	
	return(FALSE);
}