Пример #1
0
void map_mesh_flip(map_type *map,int mesh_idx,bool flip_x,bool flip_y,bool flip_z)
{
    int						n,nvertex;
    d3pnt					mpt;
    d3pnt					*pt;
    map_mesh_type			*mesh;

    // get center

    map_mesh_calculate_center(map,mesh_idx,&mpt);

    // flip vertexes

    mesh=&map->mesh.meshes[mesh_idx];

    nvertex=mesh->nvertex;
    pt=mesh->vertexes;

    for (n=0; n!=nvertex; n++) {
        if (flip_x) pt->x=mpt.x-(pt->x-mpt.x);
        if (flip_y) pt->y=mpt.y-(pt->y-mpt.y);
        if (flip_z) pt->z=mpt.z-(pt->z-mpt.z);
        pt++;
    }
}
Пример #2
0
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,&center_pnt);
		map_mesh_rotate(&map,mesh_idx,&center_pnt,ang);
		view_vbo_mesh_rebuild(mesh_idx);
	}
	
	main_wind_draw();
}
Пример #3
0
void view_center_all(bool reset_ang)
{
	int					n,old_sel_idx;
	d3pnt				pnt;
	d3ang				ang;
	
		// find center
		
	pnt.x=-1;
	
		// look for player spot first
		
	for (n=0;n!=map.nspot;n++) {
		if (map.spots[n].type==spot_type_player) {
			memmove(&pnt,&map.spots[n].pnt,sizeof(d3pnt));
			pnt.y-=3000;
			break;
		}
	}

		// otherwise do first mesh with vertexes
		
	if (pnt.x==-1) {
	
		for (n=0;n!=map.mesh.nmesh;n++) {
			if (map.mesh.meshes[n].nvertex!=0) {
				map_mesh_calculate_center(&map,n,&pnt);
				break;
			}
		}
	
	}
	
		// just center in total map size
		
	if (pnt.x==-1) {
		pnt.x=map_max_size>>1;
		pnt.y=map_max_size>>1;
		pnt.z=map_max_size>>1;
	}
Пример #4
0
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();
}