void redraw_windows(void) { // center select_clear(); main_wind_center_position_in_map(); // some defaults magnify_factor=magnify_factor_default; main_wind_set_view(vw_3_panel); main_wind_set_perspective(ps_perspective); // redraw main_wind_tool_default(); menu_fix_enable(); main_wind_tool_fix_enable(); SelectWindow(mainwind); main_wind_draw(); texture_palette_reset(); }
void piece_mesh_invert_normals(bool poly_only) { int n,k,sel_count,type,mesh_idx,poly_idx; map_mesh_type *mesh; sel_count=select_count(); for (n=0;n!=sel_count;n++) { select_get(n,&type,&mesh_idx,&poly_idx); if (type!=item_map_mesh) continue; // invert the poly mesh=&map.mesh.meshes[mesh_idx]; if (poly_only) { piece_mesh_poly_invert_normals(&mesh->polys[poly_idx]); } else { for (k=0;k!=mesh->npoly;k++) { piece_mesh_poly_invert_normals(&mesh->polys[k]); } } } main_wind_draw(); }
void piece_tesselate(bool mesh) { int n,sel_count,type,mesh_idx,poly_idx; map_undo_push(); sel_count=select_count(); for (n=0;n!=sel_count;n++) { select_get(n,&type,&mesh_idx,&poly_idx); if (type==item_map_mesh) { if (mesh) { map_mesh_tesselate(&map,mesh_idx); } else { map_mesh_poly_tesselate(&map,mesh_idx,poly_idx); } view_vbo_mesh_rebuild(mesh_idx); } } select_clear(); main_wind_draw(); }
void palette_node_save(void) { int type,main_idx,poly_idx; node_type *node; // get node select_get(0,&type,&main_idx,&poly_idx); node=&map.nodes[main_idx]; // set controls dialog_get_text(palette_node_wind,kNodeName,0,node->name,name_str_len); node->event_id=dialog_get_int(palette_node_wind,kNodeEventID,0); node->ang.x=dialog_get_float(palette_node_wind,kNodeAngleX,0); node->ang.y=dialog_get_float(palette_node_wind,kNodeAngleY,0); node->ang.z=dialog_get_float(palette_node_wind,kNodeAngleZ,0); node->follow_camera=dialog_get_boolean(palette_node_wind,kNodeFollowCamera,0); // need to reset node combo main_wind_tool_fill_node_combo(); main_wind_draw(); }
void piece_select_more(void) { int n,t,t2,sel_count,type,mesh_idx,poly_idx; d3pnt *pt1,*pt2; map_mesh_type *mesh; map_mesh_poly_type *poly; // select more polygons sel_count=select_count(); for (n=0;n!=sel_count;n++) { select_get(n,&type,&mesh_idx,&poly_idx); if (type!=item_map_mesh) continue; mesh=&map.mesh.meshes[mesh_idx]; poly=&mesh->polys[poly_idx]; for (t=0;t!=poly->ptsz;t++) { t2=t+1; if (t2==poly->ptsz) t2=0; pt1=&mesh->vertexes[poly->v[t]]; pt2=&mesh->vertexes[poly->v[t2]]; piece_select_more_check_edge(pt1,pt2); } } main_wind_draw(); }
void texture_edit_switch(int texture_idx) { // clicking again leaves if (state.mode==app_mode_map) { if ((state.map.texture_edit_idx!=-1) && (state.map.texture_edit_idx==texture_idx)) { state.map.texture_edit_idx=-1; } else { state.map.texture_edit_idx=texture_idx; } map_palette_reset(); list_palette_set_level(&map_palette,0); } else { if ((state.model.texture_edit_idx!=-1) && (state.model.texture_edit_idx==texture_idx)) { state.model.texture_edit_idx=-1; } else { state.model.texture_edit_idx=texture_idx; } list_palette_set_level(&model_palette,0); } texture_edit_frame_click_idx=-1; main_wind_draw(); }
void piece_move(int move_x,int move_y,int move_z) { int n,sel_count,type,mesh_idx,poly_idx; d3pnt mov_pnt; map_undo_push(); sel_count=select_count(); mov_pnt.x=move_x; mov_pnt.y=move_y; mov_pnt.z=move_z; for (n=0;n!=sel_count;n++) { select_get(n,&type,&mesh_idx,&poly_idx); if (type==item_map_mesh) { if (!map.mesh.meshes[mesh_idx].flag.lock_move) { map_mesh_move(&map,mesh_idx,&mov_pnt); view_force_grid(mesh_idx,TRUE); view_vbo_mesh_rebuild(mesh_idx); } } } main_wind_draw(); }
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(); }
void model_palette_click_mesh(int mesh_idx,bool double_click) { int n; d3pnt move_pnt; model_vertex_type *vtx; model_bone_type *bone; model_mesh_type *mesh; mesh=&model.meshes[mesh_idx]; if (!double_click) return; // regular clicks switch (model_palette.item_pane.click.id) { case kMeshPropertyMovement: // get change move_pnt.x=mesh->import_move.x-mesh->org_import_move.x; move_pnt.y=mesh->import_move.y-mesh->org_import_move.y; move_pnt.z=mesh->import_move.z-mesh->org_import_move.z; memmove(&mesh->org_import_move,&mesh->import_move,sizeof(d3pnt)); // now set the vertexes vtx=mesh->vertexes; for (n=0;n!=mesh->nvertex;n++) { vtx->pnt.x+=move_pnt.x; vtx->pnt.y+=move_pnt.y; vtx->pnt.z+=move_pnt.z; vtx++; } // if this is mesh 0, then move the // bones if (mesh_idx==0) { bone=model.bones; for (n=0;n!=model.nbone;n++) { bone->pnt.x+=move_pnt.x; bone->pnt.y+=move_pnt.y; bone->pnt.z+=move_pnt.z; bone++; } } main_wind_draw(); break; } }
bool liquid_reflection_maps_create_process(int nliq,char *err_str) { int n,txt_idx; char base_path[1024],dir_path[1024], map_name[256],str[256]; // base path file_paths_data_default(&file_path_setup,base_path,"Bitmaps/Textures",NULL,NULL); // create folders if they don't exist sprintf(dir_path,"%s/ReflectionMaps",base_path); os_create_directory(dir_path); light_map_texture_map_folder_name(map_name); sprintf(dir_path,"%s/ReflectionMaps/%s",base_path,map_name); os_create_directory(dir_path); // clear the textures and // start mesh-poly and/or liquid setup progress_next_title("Liquid Reflection Map: Setup"); map_delete_texture(&map,liquid_reflection_texture_start_idx,(liquid_reflection_texture_start_idx+max_liquid_reflection_map_textures)); liquid_reflection_map_setup(); liquid_reflection_map_bitmap_pixel_start(); // create a ray traced light map // for all the polys txt_idx=liquid_reflection_texture_start_idx; for (n=0;n!=map.liquid.nliquid;n++) { sprintf(str,"Liquid Reflection Map: Rendering Liquid %d/%d",(n+1),nliq); progress_next_title(str); if (!liquid_reflection_map_run_for_liquid(txt_idx,n,base_path,map_name,err_str)) { liquid_reflection_map_bitmap_pixel_free(); return(FALSE); } txt_idx++; } // free textures and polys progress_next_title("Liquid Reflection Map: Finishing"); liquid_reflection_map_bitmap_pixel_free(); main_wind_draw(); return(TRUE); }
void change_model_wind(d3pnt *start_pnt,bool shift_on,bool rotate_on,bool size_on) { int old_magnify_z; d3rect mbox; d3pnt pnt,last_pnt,old_shift; d3ang old_ang; // rotate, shift, or size the model last_pnt.x=last_pnt.y=-1; old_shift.x=state.model.shift.x; old_shift.y=state.model.shift.y; old_ang.x=state.model.ang.x; old_ang.y=state.model.ang.y; old_magnify_z=state.model.magnify_z; 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 (shift_on) { state.model.shift.x=old_shift.x+((last_pnt.x-start_pnt->x)*4); state.model.shift.y=old_shift.y-((last_pnt.y-start_pnt->y)*4); } if (rotate_on) { state.model.ang.x=old_ang.x-(float)((last_pnt.y-start_pnt->y)/5); state.model.ang.y=old_ang.y+(float)((last_pnt.x-start_pnt->x)/5); } if (size_on) { state.model.magnify_z=old_magnify_z+((last_pnt.y-start_pnt->y)*2); } if (state.model.play_mode==model_play_mode_stop) main_wind_draw(); } if (state.model.play_mode==model_play_mode_stop) main_wind_draw(); }
void map_palette_click(d3pnt *pnt,bool double_click) { bool old_open; // check if open changes old_open=list_palette_is_open(&map_palette); // click if (!list_palette_click(&map_palette,pnt,double_click)) { if (old_open!=list_palette_is_open(&map_palette)) main_wind_draw(); return; } // can't do anything if no map if (!state.map.map_open) return; // if texture window is up, texture properties if (state.map.texture_edit_idx!=-1) { map_palette_click_texture(state.map.texture_edit_idx,map_palette.item_pane.click.id,double_click); main_wind_draw(); return; } // click by level switch (list_palette_get_level(&map_palette)) { case 0: map_palette_click_level_0(double_click); break; case 1: map_palette_click_level_1(double_click); break; case 2: map_palette_click_level_2(double_click); break; } main_wind_draw(); }
void texture_palette_click(d3pnt *pnt,bool dblclick) { int nsel,page,page_cnt,yadd; // move within palette pnt->y-=txt_palette_y; // texture page change if (pnt->x<16) { page_cnt=max_map_texture/txt_wind_per_page; yadd=(txt_wind_row_count*txt_pixel_sz)/page_cnt; page=pnt->y/yadd; if (txt_page!=page) { txt_page=page; main_wind_draw(); } return; } // find clicked texture nsel=((pnt->y/txt_pixel_sz)*txt_wind_column_count)+((pnt->x-16)/txt_pixel_sz); nsel+=(txt_page*txt_wind_per_page); // double clicks if (dblclick) { dialog_texture_setting_run(nsel); main_wind_draw(); return; } // single clicks if (map.textures[nsel].frames[0].bitmap.gl_id==-1) return; texture_palette_put_selected_texture(nsel); texture_palette_reset(); main_wind_draw(); }
void tool_wind_magnify_scroll(int delta) { magnify_factor-=delta; if (magnify_factor<5) magnify_factor=5; if (magnify_factor>210) magnify_factor=210; SetControlValue(magnify_slider,magnify_factor); top_view_reset(); main_wind_draw(); }
void map_palette_scroll_into_view(int item_id,int item_idx) { // can only scroll into view // on map items page if (!list_palette_get_level(&map_palette)!=0) return; map_palette_fill_level_0(); list_palette_scroll_item_into_view(&map_palette,item_id,item_idx); main_wind_draw(); }
void model_view_draw_play(void) { int n,cur_tick, old_pose_move_idx; // if no current animation, just do no pose for animated textures if ((state.model.cur_animate_idx==-1) && (state.model.play_mode!=model_play_mode_blend)) { main_wind_draw(); return; } // clear the draw setup model_draw_setup_clear(&model,&draw_setup); // get the current animation tick // and divide by 4 if we are in slow play cur_tick=time_get(); if (state.model.play_mode==model_play_mode_slow) cur_tick=cur_tick>>2; // calculate the animation old_pose_move_idx=state.model.blend[0].pose_move_idx; if (state.model.play_mode!=model_play_mode_blend) { model_play_draw_calc_animation(cur_tick,state.model.cur_animate_idx,0,TRUE); } else { for (n=0;n!=max_model_blend_animation;n++) { if (state.model.blend[n].animate_idx!=-1) { model_play_draw_calc_animation(cur_tick,state.model.blend[n].animate_idx,n,(n==0)); } } } // if prev/next animation type // stop if pose has changed if ((state.model.play_mode==model_play_mode_prev) || (state.model.play_mode==model_play_mode_next)) { if (old_pose_move_idx!=state.model.blend[0].pose_move_idx) { model_play(model_play_mode_stop); } } // global draw setup model_draw_wind(state.model.cur_mesh_idx); }
void model_play(int play_mode) { int n,tick,pose_move_idx; // good animation? if (play_mode!=model_play_mode_stop) { if (state.model.cur_animate_idx==-1) return; if (model.animates[state.model.cur_animate_idx].npose_move==0) return; } // always turn off animation until setup is complete // as animation is on a timer state.model.play_mode=model_play_mode_stop; // if it's next or previous, we // need to start on current selection pose_move_idx=0; switch (play_mode) { case model_play_mode_prev: pose_move_idx=state.model.cur_animate_pose_move_idx-1; if (pose_move_idx<0) pose_move_idx=model.animates[state.model.cur_animate_idx].npose_move-1; break; case model_play_mode_next: pose_move_idx=state.model.cur_animate_pose_move_idx; break; } // setup animation time_start(); tick=time_get(); for (n=0;n!=max_model_blend_animation;n++) { state.model.blend[n].pose_move_idx=pose_move_idx; state.model.blend[n].tick=tick; } // turn on/off animation state.model.play_mode=play_mode; if (state.model.model_open) main_wind_draw(); }
void tool_wind_magnify_action(ControlRef ctrl,ControlPartCode code) { int s; s=GetControlValue(ctrl); if (s==magnify_factor) return; magnify_factor=s; top_view_reset(); portal_view_reset(); site_path_view_reset(); main_wind_draw(); }
void texture_edit_click_scroll(void) { int org_y; d3pnt pt; d3rect box; org_y=-1; texture_edit_get_box(&box); main_wind_draw(); while (!os_track_mouse_location(&pt,&box)) { if (org_y==-1) org_y=pt.y; if (pt.y!=org_y) { texture_edit_scroll(pt.y-org_y); main_wind_draw(); org_y=pt.y; } usleep(10000); } }
void texture_edit_scroll(int y_move) { int high; d3rect box; texture_edit_scroll_pos-=y_move; if (texture_edit_scroll_pos<0) texture_edit_scroll_pos=0; texture_edit_get_box(&box); high=(texture_edit_item_high*max_texture_frame)-(box.by-box.ty); if (texture_edit_scroll_pos>high) texture_edit_scroll_pos=high; main_wind_draw(); }
void palette_polygon_save(void) { int type,main_idx,poly_idx; float x_txtoff,y_txtoff,x_txtfact,y_txtfact; map_mesh_poly_type *poly; map_liquid_type *liq; // get polygon select_get(0,&type,&main_idx,&poly_idx); // save data if (type==mesh_piece) { poly=&map.mesh.meshes[main_idx].polys[poly_idx]; x_txtoff=dialog_get_float(palette_poly_wind,kMeshPolySettingOffX,0); y_txtoff=dialog_get_float(palette_poly_wind,kMeshPolySettingOffY,0); x_txtfact=dialog_get_float(palette_poly_wind,kMeshPolySettingSizeX,0); y_txtfact=dialog_get_float(palette_poly_wind,kMeshPolySettingSizeY,0); if ((x_txtfact>0.0f) && (y_txtfact>0.0f)) map_mesh_set_poly_uv_as_box(&map,main_idx,poly_idx,x_txtoff,y_txtoff,x_txtfact,y_txtfact); poly->dark_factor=dialog_get_float(palette_poly_wind,kMeshPolySettingDark,0); poly->alpha=dialog_get_float(palette_poly_wind,kMeshPolySettingAlpha,0); poly->x_shift=dialog_get_float(palette_poly_wind,kMeshPolySettingShiftX,0); poly->y_shift=dialog_get_float(palette_poly_wind,kMeshPolySettingShiftY,0); dialog_special_combo_get_node(palette_poly_wind,kMeshPolySettingCamera,0,poly->camera,name_str_len); } // liquid data else { liq=&map.liquid.liquids[main_idx]; liq->x_txtoff=dialog_get_float(palette_poly_wind,kMeshPolySettingOffX,0); liq->y_txtoff=dialog_get_float(palette_poly_wind,kMeshPolySettingOffY,0); liq->x_txtfact=dialog_get_float(palette_poly_wind,kMeshPolySettingSizeX,0); liq->y_txtfact=dialog_get_float(palette_poly_wind,kMeshPolySettingSizeY,0); liq->alpha=dialog_get_float(palette_poly_wind,kMeshPolySettingAlpha,0); liq->x_shift=dialog_get_float(palette_poly_wind,kMeshPolySettingShiftX,0); liq->y_shift=dialog_get_float(palette_poly_wind,kMeshPolySettingShiftY,0); } main_wind_draw(); }
void piece_force_grid(void) { int n,sel_count,type,mesh_idx,poly_idx; map_undo_push(); sel_count=select_count(); for (n=0;n!=sel_count;n++) { select_get(n,&type,&mesh_idx,&poly_idx); if (type==item_map_mesh) { view_force_grid(mesh_idx,FALSE); view_vbo_mesh_rebuild(mesh_idx); } } main_wind_draw(); }
void palette_sound_save(void) { int type,main_idx,poly_idx; map_sound_type *sound; // get sound select_get(0,&type,&main_idx,&poly_idx); sound=&map.sounds[main_idx]; // set controls dialog_special_combo_get_sound(palette_sound_wind,kSoundName,0,sound->name,name_str_len); sound->pitch=dialog_get_float(palette_sound_wind,kSoundPitch,0); sound->on=dialog_get_boolean(palette_sound_wind,kSoundOn,0); main_wind_draw(); }
void piece_flip(bool flip_x,bool flip_y,bool flip_z) { int n,sel_count,type,mesh_idx,poly_idx; map_undo_push(); sel_count=select_count(); for (n=0;n!=sel_count;n++) { select_get(n,&type,&mesh_idx,&poly_idx); if (type==item_map_mesh) { map_mesh_flip(&map,mesh_idx,flip_x,flip_y,flip_z); view_vbo_mesh_rebuild(mesh_idx); } } main_wind_draw(); }
void piece_poly_hole(void) { int n,sel_count,type,mesh_idx,poly_idx; sel_count=select_count(); for (n=0;n!=sel_count;n++) { select_get(n,&type,&mesh_idx,&poly_idx); if (type==item_map_mesh) { map_mesh_poly_punch_hole(&map,mesh_idx,poly_idx,NULL,FALSE,normal_mode_in); view_vbo_mesh_rebuild(mesh_idx); } } select_clear(); main_wind_draw(); }
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(); }
void piece_mesh_recalc_normals(bool poly_only) { int n,sel_count,type,mesh_idx,poly_idx; sel_count=select_count(); for (n=0;n!=sel_count;n++) { select_get(n,&type,&mesh_idx,&poly_idx); if (type!=item_map_mesh) continue; if (poly_only) { map_recalc_normals_mesh_poly(&map,&map.mesh.meshes[mesh_idx],poly_idx,normal_mode_none,FALSE); } else { map_recalc_normals_mesh(&map,&map.mesh.meshes[mesh_idx],normal_mode_none,FALSE); } } main_wind_draw(); }
void piece_rotate(d3ang *ang) { int n,sel_count,type,mesh_idx,poly_idx; d3pnt center_pnt; map_undo_push(); sel_count=select_count(); for (n=0;n!=sel_count;n++) { select_get(n,&type,&mesh_idx,&poly_idx); if (type!=item_map_mesh) continue; map_mesh_calculate_center(&map,mesh_idx,¢er_pnt); map_mesh_rotate(&map,mesh_idx,¢er_pnt,ang); view_vbo_mesh_rebuild(mesh_idx); } main_wind_draw(); }
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(); }
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(); }