示例#1
0
文件: model_dos.c 项目: rzel/dim3
bool model_file_open(char *file_name)
{
		// close model

	if (!model_file_close()) return(FALSE);
	
		// open model
		
	os_set_wait_cursor();
	
	os_select_window();
 
	if (!model_open(&model,file_name,TRUE)) {
		os_set_arrow_cursor();
		os_dialog_alert("Animator","There was a problem loading the model file.");
		model_file_reset_state();
		return(FALSE);
	}
    	
	os_set_arrow_cursor();

		// finish
		
	state.model.model_open=TRUE;
	strcpy(state.model.model_file_name,file_name);
	
	model_file_reset_state();

	return(TRUE);
}
示例#2
0
文件: walk_view.c 项目: prophile/dim3
void walk_view_cursor(bool rot_ok)
{
    // special check for nodes link changes

    if ((select_count()==1) && (select_has_type(node_piece))) {

        if (main_wind_option_down()) {
            os_set_cut_cursor();
            return;
        }

        if (main_wind_control_down()) {
            os_set_add_cursor();
            return;
        }
    }

    // normal cursors

    if (main_wind_space_down()) {
        os_set_hand_cursor();
        return;
    }
    if ((main_wind_option_down()) && ((!main_wind_control_down()) && (!main_wind_shift_down()))) {
        os_set_forward_cursor();
        return;
    }
    if ((main_wind_command_down()) && (rot_ok)) {
        os_set_rotate_cursor();
        return;
    }

    os_set_arrow_cursor();
}
示例#3
0
文件: model_dos.c 项目: rzel/dim3
void model_file_import_mesh_obj(bool replace)
{
	char			path[1024],err_str[256];
	bool			found_normals;
    
	os_set_arrow_cursor();
	if (!os_load_file("Select an OBJ to Import",path,"obj")) return;
	
	if (state.model.cur_mesh_idx==-1) state.model.cur_mesh_idx=0;
	
	if (!model_import_obj(path,replace,&found_normals,err_str)) {
		os_dialog_alert("OBJ Import",err_str);
		return;
	}

		// finish setup
		
	model_vertex_mask_clear_sel(state.model.cur_mesh_idx);
	model_vertex_mask_clear_hide(state.model.cur_mesh_idx);

	model_poly_mask_clear_sel(state.model.cur_mesh_idx);
	model_poly_mask_clear_hide(state.model.cur_mesh_idx);
	
	main_wind_draw();
}
示例#4
0
文件: model_dos.c 项目: rzel/dim3
void model_file_import_animations(void)
{
	char			file_name[256];
	
	os_set_arrow_cursor();

    if (!dialog_file_open_run("Open a Model","Models",NULL,"Mesh.xml;Model.xml",file_name)) return;
	
	os_set_wait_cursor();
	
	model_insert_animations(file_name);
	
    model_calculate_parents(&model);
	
	os_set_arrow_cursor();
	
	main_wind_draw();
}
示例#5
0
文件: model_dos.c 项目: rzel/dim3
void model_file_insert_mesh_dim3_model(void)
{
	char			file_name[256];
	
	os_set_arrow_cursor();

    if (!dialog_file_open_run("Open a Model","Models",NULL,"Mesh.xml;Model.xml",file_name)) return;
	
	if (state.model.cur_mesh_idx==-1) state.model.cur_mesh_idx=0;
	
	os_set_wait_cursor();
	
	model_insert_mesh(file_name);
	
    model_calculate_parents(&model);
    model_center_xz(&model,state.model.cur_mesh_idx);
    model_floor(&model,state.model.cur_mesh_idx);
    model_recalc_boxes(&model);
	
	os_set_arrow_cursor();
	
	main_wind_draw();
}
示例#6
0
文件: model_dos.c 项目: rzel/dim3
bool model_file_save(void)
{
	char			err_str[256];
	bool			ok;
	
	os_set_wait_cursor();
	
	ok=model_save(&model,err_str);
	os_set_arrow_cursor();
	
	if (!ok) os_dialog_alert("dim3 Animator could not save model.",err_str);
	
	return(ok);
}
示例#7
0
文件: model_dos.c 项目: rzel/dim3
void model_auto_generate_textures(void)
{
	char			base_path[1024],dir_path[1024];

	os_set_wait_cursor();

		// texture directory

	file_paths_data_default(&file_path_setup,base_path,"Models",NULL,NULL);
		
	strcat(base_path,"/");
	strcat(base_path,state.model.model_file_name);
	
	sprintf(dir_path,"%s/Textures",base_path);

		// run bitmap generation for model

	auto_generate_model_create_texture_set(&model,dir_path);

	os_set_arrow_cursor();

	main_wind_draw();
}
示例#8
0
bool model_wind_hit_box_click(d3pnt *start_pnt)
{
	int						n,k,box_idx,pt_idx,xsz,zsz,ysz,offx,offz,offy,
							kx,ky,kz;
	bool					model_hit_box_drag_on;
	d3rect					mbox;
	d3pnt					org_pnt,org_cnt,last_pnt,pnt,edge_pnt[8];
	d3fpnt					hand_pnt;
	model_box_type			*box;
	
	model_play(model_play_mode_stop);
	
		// setup the draw pose
		
	model_draw_setup_pose(state.model.cur_pose_idx);
	model_create_draw_bones(&model,&draw_setup);
	
		// setup transforms
		
	model_draw_gl_setup(0);
	model_draw_setup_project_point();

		// find a click

	box_idx=pt_idx=-1;
		
	for (n=0;n!=model.nhit_box;n++) {
		box=&model.hit_boxes[n].box;

		xsz=box->size.x/2;
		offx=box->offset.x;
		zsz=box->size.z/2;
		offz=box->offset.z;
		ysz=box->size.y;
		offy=box->offset.y;
		
		edge_pnt[0].x=edge_pnt[1].x=edge_pnt[4].x=edge_pnt[5].x=offx-xsz;
		edge_pnt[2].x=edge_pnt[3].x=edge_pnt[6].x=edge_pnt[7].x=offx+xsz;
		edge_pnt[0].y=edge_pnt[1].y=edge_pnt[2].y=edge_pnt[3].y=offy-ysz;
		edge_pnt[4].y=edge_pnt[5].y=edge_pnt[6].y=edge_pnt[7].y=offy;
		edge_pnt[0].z=edge_pnt[3].z=edge_pnt[4].z=edge_pnt[7].z=offz-zsz;
		edge_pnt[1].z=edge_pnt[2].z=edge_pnt[5].z=edge_pnt[6].z=offz+zsz;
	
		for (k=0;k!=8;k++) {
			model_get_point_position(&draw_setup,&edge_pnt[k]);
			hand_pnt.x=(float)edge_pnt[k].x;
			hand_pnt.y=(float)edge_pnt[k].y;
			hand_pnt.z=(float)edge_pnt[k].z;
			if (model_wind_draw_bone_click_box(start_pnt,&hand_pnt)) {
				box_idx=n;
				pt_idx=k;
				break;
			}
		}
		
		if (box_idx!=-1) break;
	}
	
	if (box_idx==-1) return(FALSE);
	
		// get original size
		
	box=&model.hit_boxes[box_idx].box;
	memmove(&org_pnt,&box->size,sizeof(d3pnt));
	memmove(&org_cnt,&box->offset,sizeof(d3pnt));
	
		// drag handle
		
	model_hit_box_drag_on=FALSE;

	last_pnt.x=last_pnt.y=-1;
	
	os_set_drag_cursor();
	model_wind_get_box(&mbox);
		
	while (!os_track_mouse_location(&pnt,&mbox)) {
		
		if ((last_pnt.x==pnt.x) && (last_pnt.y==pnt.y)) continue;
		memmove(&last_pnt,&pnt,sizeof(d3pnt));
		
		kx=(pnt.x-start_pnt->x)*5;
		ky=(pnt.y-start_pnt->y)*5;
		kz=0;
		
		rotate_point_center(&kx,&ky,&kz,state.model.ang.x,state.model.ang.y,0.0f);

		if ((pt_idx==0) || (pt_idx==1) || (pt_idx==4) || (pt_idx==5)) {
			box->size.x=org_pnt.x-kx;
		}
		else {
			box->size.x=org_pnt.x+kx;
		}
		if ((pt_idx==0) || (pt_idx==1) || (pt_idx==2) || (pt_idx==3)) {
			box->size.y=org_pnt.y-ky;
		}
		else {
			box->size.y=org_pnt.y+ky;
			box->offset.y=org_cnt.y+ky;
		}
		if ((pt_idx==0) || (pt_idx==3) || (pt_idx==4) || (pt_idx==7)) {
			box->size.z=org_pnt.z-kz;
		}
		else {
			box->size.z=org_pnt.z+kz;
		}
		
			// draw the model
			
		main_wind_draw();
		model_hit_box_drag_on=TRUE;
	}

	os_set_arrow_cursor();

		// redraw model
		
	main_wind_draw();

	return(model_hit_box_drag_on);
}
示例#9
0
bool model_wind_bone_click(d3pnt *start_pnt,bool double_click)
{
	int						n,k,x,drag_handle;
	float					org_ang,org_mov,
							bone_drag_handle_offset;
	float					*ang,*mov;
	d3rect					mbox;
	d3pnt					pnt,last_pnt;
	d3fpnt					bone_pnt,hand_pnt;
	d3vct					vct;
	d3ang					hang,rot;
	model_bone_type			*bone;
	model_draw_bone_type	*draw_bone;
	
	if (model.nbone==0) return(FALSE);
	
	model_play(model_play_mode_stop);
	
		// setup the draw pose
		
	model_draw_setup_pose(state.model.cur_pose_idx);
	model_create_draw_bones(&model,&draw_setup);
	
		// setup transforms
		
	model_draw_gl_setup(0);
	model_draw_setup_project_point();
	
		// click on any drag handles?
		
	drag_handle=drag_handle_none;
	
	if ((state.model.cur_pose_idx!=-1) && (state.model.cur_bone_idx!=-1)) {
	
		bone=&model.bones[state.model.cur_bone_idx];
		draw_bone=&draw_setup.bones[state.model.cur_bone_idx];
		
		bone_pnt.x=draw_bone->fpnt.x+draw_setup.move.x;
		bone_pnt.y=draw_bone->fpnt.y+draw_setup.move.y;
		bone_pnt.z=draw_bone->fpnt.z+draw_setup.move.z;
		
		bone_drag_handle_offset=model_draw_bones_drag_handle_offset();

		model_draw_bones_get_handle_rot(state.model.cur_bone_idx,&rot);
		
			// x drag bone

		vct.x=bone_drag_handle_offset;
		vct.y=0;
		vct.z=0;
		hang.x=bone->natural_rot.x;
		hang.y=rot.y+bone->natural_rot.y;
		hang.z=rot.z+bone->natural_rot.z;
		model_draw_bones_drag_handle_calc(&bone_pnt,&vct,&hang,&hand_pnt);
		if (model_wind_draw_bone_click_box(start_pnt,&hand_pnt)) drag_handle=drag_handle_x;
		
			// y drag bone
			
		vct.x=0;
		vct.y=bone_drag_handle_offset;
		vct.z=0;
		hang.x=rot.x+bone->natural_rot.x;
		hang.y=bone->natural_rot.y;
		hang.z=rot.z+bone->natural_rot.z;
		model_draw_bones_drag_handle_calc(&bone_pnt,&vct,&hang,&hand_pnt);
		if (model_wind_draw_bone_click_box(start_pnt,&hand_pnt)) drag_handle=drag_handle_y;
		
			// z drag bone
			
		vct.x=0;
		vct.y=0;
		vct.z=bone_drag_handle_offset;
		hang.x=rot.x+bone->natural_rot.x;
		hang.y=rot.y+bone->natural_rot.y;
		hang.z=+bone->natural_rot.z;
		model_draw_bones_drag_handle_calc(&bone_pnt,&vct,&hang,&hand_pnt);
		if (model_wind_draw_bone_click_box(start_pnt,&hand_pnt)) drag_handle=drag_handle_z;
	}
	
		// click on any bones?
		
	if (drag_handle==drag_handle_none) {
	
		k=-1;
		draw_bone=draw_setup.bones;
			
		for (n=0;n!=model.nbone;n++) {
			bone_pnt.x=draw_bone->fpnt.x+draw_setup.move.x;
			bone_pnt.y=draw_bone->fpnt.y+draw_setup.move.y;
			bone_pnt.z=draw_bone->fpnt.z+draw_setup.move.z;
			
			if (model_wind_draw_bone_click_box(start_pnt,&bone_pnt)) {
				k=n;
				break;
			}

			draw_bone++;
		}
		
		if (k==-1) return(FALSE);
	
			// select as current bone
			
		state.model.cur_item=item_model_bone;
		state.model.cur_bone_idx=k;
		model_palette_scroll_into_view(item_model_bone,state.model.cur_bone_idx);

		if ((state.model.sel_vertex_with_bone) || (double_click)) model_vertex_mask_set_sel_bone(state.model.cur_mesh_idx,state.model.cur_bone_idx);

		list_palette_set_level(&model_palette,1);

		main_wind_draw();

		return(TRUE);
	}

		// no drag if no pose

	if (state.model.cur_pose_idx==-1) return(TRUE);
	
		// get drag angle
		
	switch (drag_handle) {
	
		case drag_handle_x:
			ang=&model.poses[state.model.cur_pose_idx].bone_moves[state.model.cur_bone_idx].rot.x;
			mov=&model.poses[state.model.cur_pose_idx].bone_moves[state.model.cur_bone_idx].mov.x;
			break;
		
		case drag_handle_y:
			ang=&model.poses[state.model.cur_pose_idx].bone_moves[state.model.cur_bone_idx].rot.y;
			mov=&model.poses[state.model.cur_pose_idx].bone_moves[state.model.cur_bone_idx].mov.y;
			break;
			
		case drag_handle_z:
			ang=&model.poses[state.model.cur_pose_idx].bone_moves[state.model.cur_bone_idx].rot.z;
			mov=&model.poses[state.model.cur_pose_idx].bone_moves[state.model.cur_bone_idx].mov.z;
			break;
		
		default:
			return(TRUE);
			
	}
	
		// drag bone

	org_ang=*ang;
	org_mov=*mov;
	last_pnt.x=last_pnt.y=-1;
	
	model_undo_set_bone_move(state.model.cur_pose_idx,state.model.cur_bone_idx);
	
	os_set_drag_cursor();
	model_wind_get_box(&mbox);
		
	while (!os_track_mouse_location(&pnt,&mbox)) {
		
		if ((last_pnt.x==pnt.x) && (last_pnt.y==pnt.y)) continue;
		memmove(&last_pnt,&pnt,sizeof(d3pnt));
		
		x=pnt.x-start_pnt->x;
		if (x<-180) x=-180;
		if (x>180) x=180;
		
		if (state.model.drag_bone_mode==handle_mode_rotate) {
			*ang=org_ang+(((float)x)/2.0f);
		}
		else {
			*mov=org_mov+(((float)x)/20.0f);
		}
		
			// draw the model
			
		main_wind_draw();
	}

	os_set_arrow_cursor();

		// redraw model
		
	main_wind_draw();

	return(TRUE);
}
示例#10
0
void select_model_wind(d3pnt *start_pnt)
{
	int				sz;
	float			*pv;
	
		// no playing while selecting
		
	model_play(model_play_mode_stop);
	
		// get the draw vertexes
		// need to save off array as drawing will reuse
		// array and free it
		
	model_draw_setup_initialize(&model,&draw_setup,TRUE);
		
	model_draw_setup_pose(state.model.cur_pose_idx);
	
	model_create_draw_bones(&model,&draw_setup);
	model_create_draw_vertexes(&model,state.model.cur_mesh_idx,&draw_setup);
	
	sz=(model.meshes[state.model.cur_mesh_idx].nvertex*3)*sizeof(float);
	pv=(float*)malloc(sz);
	if (pv==NULL) return;
	
	memmove(pv,draw_setup.mesh_arrays[state.model.cur_mesh_idx].gl_vertex_array,sz);
		
	model_draw_setup_shutdown(&model,&draw_setup);
	
		// setup transforms
		
	model_draw_gl_setup(0);
	model_draw_setup_project_point();

		// run the correct click
		
	switch (state.model.select_mode) {

		case select_mode_mesh:
			select_model_wind_mesh(start_pnt);
			break;

		case select_mode_polygon:
			if (!select_model_wind_vertex_sel_poly(start_pnt,pv)) {
				if (!select_model_wind_polygon(start_pnt,FALSE)) {
					select_model_wind_vertex_drag_sel(start_pnt,pv);
				}
			}
			break;

		case select_mode_vertex:
			if (!select_model_wind_vertex(start_pnt,pv)) {
				select_model_wind_vertex_drag_sel(start_pnt,pv);
			}
			break;
	}
	
		// free the saved vertexes

	free(pv);

		// redraw the model
		
	main_wind_draw();

	os_set_arrow_cursor();	
}
示例#11
0
void select_model_wind_vertex_drag_sel(d3pnt *start_pnt,float *pv)
{
	char					*org_vertex_sel;
	bool					chg_sel;
	d3rect					mbox;
	d3pnt					pnt,last_pnt;
	
		// turn on or off?
		
	org_vertex_sel=(char*)malloc(model.meshes[state.model.cur_mesh_idx].nvertex);
		
	if (os_key_shift_down()) {
		select_model_wind_save_drag_sel_state(org_vertex_sel);
		os_set_add_cursor();
		chg_sel=TRUE;
	}
	else {
		if (os_key_control_down()) {
			select_model_wind_save_drag_sel_state(org_vertex_sel);
			os_set_subtract_cursor();
			chg_sel=FALSE;
		}
		else {
			memset(org_vertex_sel,0x0,model.meshes[state.model.cur_mesh_idx].nvertex);
			os_set_arrow_cursor();
			chg_sel=TRUE;
		}
	}
	
		// drag the selection

	last_pnt.x=last_pnt.y=-1;
	
	state.model.drag_sel_on=TRUE;
	model_wind_get_box(&mbox);
	
	while (!os_track_mouse_location(&pnt,&mbox)) {
		
		if ((last_pnt.x==pnt.x) && (last_pnt.y==pnt.y)) continue;
		memmove(&last_pnt,&pnt,sizeof(d3pnt));
		
		if (start_pnt->x<last_pnt.x) {
			state.model.drag_sel_box.lx=start_pnt->x;
			state.model.drag_sel_box.rx=last_pnt.x;
		}
		else {
			state.model.drag_sel_box.rx=start_pnt->x;
			state.model.drag_sel_box.lx=last_pnt.x;
		}
		if (start_pnt->y<last_pnt.y) {
			state.model.drag_sel_box.ty=start_pnt->y;
			state.model.drag_sel_box.by=last_pnt.y;
		}
		else {
			state.model.drag_sel_box.by=start_pnt->y;
			state.model.drag_sel_box.ty=last_pnt.y;
		}
		
		select_model_wind_restore_drag_sel_state(org_vertex_sel);
		model_drag_sel_vertex(pv,&state.model.drag_sel_box,chg_sel);

		if (state.model.select_mode==select_mode_polygon) select_model_wind_select_poly_for_vertex_drag_sel();
		
		main_wind_draw();
	}
	
	state.model.drag_sel_on=FALSE;
	
	free(org_vertex_sel);
}
示例#12
0
文件: map_menu.c 项目: 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);
}
示例#13
0
文件: texture_edit.c 项目: rzel/dim3
bool texture_edit_click(d3pnt *pnt,bool double_click)
{
	int				wid,high,frame_idx,frame_count;
    char			bitmap_name[file_str_len];
	d3pnt			pt;
	d3rect			box,tbox;
	texture_type	*texture;

		// check for scrolling

	if (os_key_space_down()) {
		texture_edit_click_scroll();
		return(TRUE);
	}
	
		// regular clicks

	if (state.mode==app_mode_map) {
		texture=&map.textures[state.map.texture_edit_idx];
		frame_count=map_count_texture_frames(&map,state.map.texture_edit_idx);
	}
	else {
		texture=&model.textures[state.model.texture_edit_idx];
		frame_count=model_count_texture_frames(&model,state.model.texture_edit_idx);
	}

	texture_edit_get_box(&box);

	wid=box.rx-box.lx;
	high=box.by-box.ty;

		// move within view
		
	pnt->x-=box.lx;
	pnt->y-=box.ty;

		// clicking in return?
		
	frame_idx=-1;

	tbox.lx=wid-120;
	tbox.rx=tbox.lx+120;
	tbox.ty=high-40;
	tbox.by=tbox.ty+40;

	if ((pnt->x>=tbox.lx) && (pnt->x<=tbox.rx) && (pnt->y>=tbox.ty) && (pnt->y<=tbox.by)) {
		frame_idx=texture_edit_frame_click_return_idx;
	}

		// clicking in delete
		
	if ((frame_idx==-1) && (frame_count>0)) {
		tbox.lx=470;
		tbox.rx=600;
		tbox.ty=((texture_edit_item_high*(frame_count-1))+100)-texture_edit_scroll_pos;
		tbox.by=tbox.ty+25;

		if ((pnt->x>=tbox.lx) && (pnt->x<=tbox.rx) && (pnt->y>=tbox.ty) && (pnt->y<=tbox.by)) {
			frame_idx=texture_edit_frame_click_delete_idx;
		}
	}
	
		// clicking in item?
		
	if (frame_idx==-1) {
		frame_idx=(pnt->y+texture_edit_scroll_pos)/texture_edit_item_high;
		
		tbox.lx=0;
		tbox.rx=wid;
		tbox.ty=(frame_idx*texture_edit_item_high)-texture_edit_scroll_pos;
		tbox.by=tbox.ty+texture_edit_item_high;
		
		if ((frame_idx<0) || (frame_idx>=max_texture_frame)) return(FALSE);
	}
	
	texture_edit_frame_click_idx=frame_idx;
		
		// run the click
		
	main_wind_draw();

	while (!os_track_mouse_location(&pt,&box)) {
		if ((pt.x<tbox.lx) || (pt.x>=tbox.rx) || (pt.y<tbox.ty) || (pt.y>=tbox.by)) {
			texture_edit_frame_click_idx=-1;
		}
		else {
			texture_edit_frame_click_idx=frame_idx;
		}

		main_wind_draw();
		
		usleep(10000);
	}

	if (texture_edit_frame_click_idx==-1) return(FALSE);

	texture_edit_frame_click_idx=-1;
	main_wind_draw();
		
		// return was clicked
		
	if (frame_idx==texture_edit_frame_click_return_idx) {
		texture_edit_switch(-1);
		return(TRUE);
	}
	
		// delete
		
	if (frame_idx==texture_edit_frame_click_delete_idx) {

		os_set_wait_cursor();
		
		if (state.mode==app_mode_map) {
			map_delete_texture_frame(&map,state.map.texture_edit_idx);
		}
		else {
			model_delete_texture_frame(&model,state.model.texture_edit_idx);
		}

		os_set_arrow_cursor();
		
		main_wind_draw();
		return(TRUE);
	}
	
		// can we edit this item?
		
	if (frame_idx>frame_count) {
		os_dialog_alert("Texture Frames","This texture frame can not be edited.\nYou can only add adjancent texture frames.");
		return(FALSE);
	}
	
		// item was clicked
		
	if (texture_edit_click_bitmap_open(bitmap_name)) {
		strcpy(texture->frames[frame_idx].name,bitmap_name);

		os_set_wait_cursor();
		
		if (state.mode==app_mode_map) {
			map_refresh_textures(&map);
		}
		else {
			model_refresh_textures(&model);
		}

		os_set_arrow_cursor();
	}

	main_wind_draw();

	return(TRUE);
}
示例#14
0
文件: model_dos.c 项目: rzel/dim3
bool model_file_new(void)
{
	char		file_name[256],err_str[256],
				base_path[1024],path[1024];

		// close model

	state.model.texture_edit_idx=-1;

	if (!model_file_close()) return(FALSE);
	
		// get name
	
	strcpy(file_name,"NewModel");
	if (!dialog_new_model_run(file_name)) {
		model_file_reset_state();
		return(FALSE);
	}

		// create model

	os_set_wait_cursor();
		
	model_new(&model,file_name);
	
	model.nmesh=1;
	strcpy(model.meshes[0].name,"Default");
	
	model.view_box.size.x=model.view_box.size.y=model.view_box.size.z=100;

	os_select_window();
	
	os_set_wait_cursor();
	
		// create new folders
		
	file_paths_data_default(&file_path_setup,base_path,"Models",NULL,NULL);
		
	strcat(base_path,"/");
	strcat(base_path,file_name);
	os_create_directory(base_path);
	
	sprintf(path,"%s/Textures",base_path);
	os_create_directory(path);

        // write the XML
	
	if (!model_save(&model,err_str)) {
		os_set_arrow_cursor();
		os_dialog_alert("dim3 Animator could not save model.",err_str);
		model_file_reset_state();
		return(FALSE);
	}
	
	os_set_arrow_cursor();
	
		// finish
		
	state.model.model_open=TRUE;
	strcpy(state.model.model_file_name,file_name);
	
	model_file_reset_state();
	
	return(TRUE);
}