void walk_view_draw_select_mesh_get_grow_handles(int mesh_idx,int *px,int *py,int *pz) { d3pnt min,max; map_mesh_calculate_extent(&map,mesh_idx,&min,&max); px[0]=px[3]=px[4]=px[7]=min.x; pz[0]=pz[1]=pz[4]=pz[5]=min.z; px[1]=px[2]=px[5]=px[6]=max.x; pz[2]=pz[3]=pz[6]=pz[7]=max.z; py[0]=py[1]=py[2]=py[3]=min.y; py[4]=py[5]=py[6]=py[7]=max.y; }
void map_mesh_resize(map_type *map,int mesh_idx,d3pnt *min,d3pnt *max) { int n,nvertex; d3pnt *pt,org_min,org_max,dif,org_dif; d3vct fct; map_mesh_type *mesh; // get original size and uv center map_mesh_calculate_extent(map,mesh_idx,&org_min,&org_max); // get resize factor dif.x=max->x-min->x; dif.y=max->y-min->y; dif.z=max->z-min->z; org_dif.x=org_max.x-org_min.x; org_dif.y=org_max.y-org_min.y; org_dif.z=org_max.z-org_min.z; fct.x=fct.y=fct.z=0.0f; if (org_dif.x!=0) fct.x=(float)dif.x/(float)org_dif.x; if (org_dif.y!=0) fct.y=(float)dif.y/(float)org_dif.y; if (org_dif.z!=0) fct.z=(float)dif.z/(float)org_dif.z; // resize vertexes mesh=&map->mesh.meshes[mesh_idx]; // resize vertexes nvertex=mesh->nvertex; pt=mesh->vertexes; for (n=0; n!=nvertex; n++) { pt->x=(int)((float)(pt->x-org_min.x)*fct.x)+min->x; pt->y=(int)((float)(pt->y-org_min.y)*fct.y)+min->y; pt->z=(int)((float)(pt->z-org_min.z)*fct.z)+min->z; pt++; } }
void piece_resize(void) { int n,sel_count,type,mesh_idx,poly_idx; d3pnt min,max,mpt; d3fpnt scale; // setup scale mesh_idx=-1; sel_count=select_count(); for (n=0;n!=sel_count;n++) { select_get(n,&type,&mesh_idx,&poly_idx); if (type==item_map_mesh) break; } if (mesh_idx==-1) return; map_mesh_calculate_extent(&map,mesh_idx,&min,&max); scale.x=(float)abs(max.x-min.x); scale.y=(float)abs(max.y-min.y); scale.z=(float)abs(max.z-min.z); // run dialog if (!dialog_scale_run(&scale)) return; if ((scale.x<=0.0f) || (scale.y<=0.0f) || (scale.z<=0.0f)) return; // resize meshes map_undo_push(); for (n=0;n!=sel_count;n++) { select_get(n,&type,&mesh_idx,&poly_idx); if (type==item_map_mesh) { // resize piece map_mesh_calculate_extent(&map,mesh_idx,&min,&max); map_mesh_calculate_center(&map,mesh_idx,&mpt); min.x=(int)((float)(min.x-mpt.x)*scale.x)+mpt.x; min.y=(int)((float)(min.y-mpt.y)*scale.y)+mpt.y; min.z=(int)((float)(min.z-mpt.z)*scale.z)+mpt.z; max.x=(int)((float)(max.x-mpt.x)*scale.x)+mpt.x; max.y=(int)((float)(max.y-mpt.y)*scale.y)+mpt.y; max.z=(int)((float)(max.z-mpt.z)*scale.z)+mpt.z; map_mesh_resize(&map,mesh_idx,&min,&max); view_vbo_mesh_rebuild(mesh_idx); // handle any cascades view_click_fix_cascade_size(mesh_idx); } } main_wind_draw(); }