Ejemplo n.º 1
0
bool select_model_wind_polygon(d3pnt *start_pnt,bool check_only)
{
	int					n,k,idx,npoly;
	float				*pv;
	d3pnt				v_pnts[8];
 	model_mesh_type		*mesh;
	model_poly_type		*poly;
	
		// clicking mesh
	
	mesh=&model.meshes[state.model.cur_mesh_idx];
	
		// draw and pick the polygons
		
	npoly=mesh->npoly;
	if (!model_pick_list_start(npoly)) return(FALSE);
	
		// draw the mesh
		
	model_draw_setup_initialize(&model,&draw_setup,TRUE);
	model_draw_setup_bones_vertexes(state.model.cur_mesh_idx);

	poly=mesh->polys;
    
    for (n=0;n!=npoly;n++) {
	
		if (!model_vertex_mask_check_hide_poly(state.model.cur_mesh_idx,poly)) {
			
			for (k=0;k!=poly->ptsz;k++) {
				pv=draw_setup.mesh_arrays[state.model.cur_mesh_idx].gl_vertex_array+(poly->v[k]*3);
				v_pnts[k].x=(int)*pv++;
				v_pnts[k].y=(int)*pv++;
				v_pnts[k].z=(int)*pv;
			}
			
			model_pick_list_add_poly(n,poly->ptsz,v_pnts);
		}
		
		poly++;
    }
	
	model_draw_setup_shutdown(&model,&draw_setup);
	
	model_pick_list_end(start_pnt,&idx);

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

		// are we checking only?

	if (check_only) return(TRUE);
	
	// supergumba
	// this is some temp code that can be used
	// to quickly make quads by selecting triangles
	// one after another
/*	
	model_poly_mask_set_sel(state.cur_mesh_idx,idx,TRUE);
	if (model_poly_mask_count_sel(state.cur_mesh_idx)==2) {
		model_polygon_make_quad(state.cur_mesh_idx);
		model_poly_mask_clear_sel(state.cur_mesh_idx);
		main_wind_draw();
	}
	
	return(TRUE);
*/

		// run the selection

	if (!os_key_shift_down()) model_poly_mask_clear_sel(state.model.cur_mesh_idx);
	model_poly_mask_set_sel(state.model.cur_mesh_idx,idx,TRUE);
	
		// select all the vertexes attached to polygon

	model_vertex_mask_set_sel_poly_mask(state.model.cur_mesh_idx);

	return(TRUE);
}
Ejemplo n.º 2
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();	
}
Ejemplo n.º 3
0
void select_model_wind(Point start_pt,unsigned long modifiers)
{
	int						lx,rx,ty,by,sz;
	double					mod_matrix[16],proj_matrix[16],vport[4];
	char					org_vertex_sel[max_model_vertex];
	bool					chg_sel;
	float					*pv;
	Point					pt,last_pt;
	MouseTrackingResult		track;
	
	model_wind_play(FALSE,FALSE);
	
		// 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);
		
	draw_model_setup_pose(&model,&draw_setup,cur_pose);
	
	model_create_draw_bones(&model,&draw_setup);
	model_create_draw_vertexes(&model,cur_mesh,&draw_setup);
	
	sz=(model.meshes[cur_mesh].nvertex*3)*sizeof(float);
	pv=(float*)malloc(sz);
	if (pv==NULL) return;
	
	memmove(pv,draw_setup.mesh_arrays[cur_mesh].gl_vertex_array,sz);
		
	model_draw_setup_shutdown(&model,&draw_setup);
	
		// setup transforms
		
	draw_model_gl_setup(&model);
	glGetDoublev(GL_MODELVIEW_MATRIX,mod_matrix);
	glGetDoublev(GL_PROJECTION_MATRIX,proj_matrix);
	glGetIntegerv(GL_VIEWPORT,(GLint*)vport);
	
		// turn on or off?
		
	if ((modifiers&shiftKey)!=0) {
		select_model_wind_save_sel_state(org_vertex_sel);
		SetCCursor(add_cursor);
		chg_sel=TRUE;
	}
	else {
		if ((modifiers&controlKey)!=0) {
			select_model_wind_save_sel_state(org_vertex_sel);
			SetCCursor(sub_cursor);
			chg_sel=FALSE;
		}
		else {
			memset(org_vertex_sel,0x0,max_model_vertex);
			InitCursor();
			chg_sel=TRUE;
		}
	}
	
		// drag the selection

	last_pt.h=last_pt.v=-1;
	
	drag_sel_on=TRUE;
	
	do {
		TrackMouseLocation(NULL,&pt,&track);
		model_wind_offset_click(&pt);
		
		if (memcmp(&last_pt,&pt,sizeof(Point))==0) continue;
		
		memmove(&last_pt,&pt,sizeof(Point));
		
		if (start_pt.h<last_pt.h) {
			lx=start_pt.h;
			rx=last_pt.h;
		}
		else {
			rx=start_pt.h;
			lx=last_pt.h;
		}
		if (start_pt.v<last_pt.v) {
			ty=start_pt.v;
			by=last_pt.v;
		}
		else {
			by=start_pt.v;
			ty=last_pt.v;
		}
		
		select_model_wind_restore_sel_state(org_vertex_sel);
		model_sel_vertex(pv,lx,ty,rx,by,chg_sel,mod_matrix,proj_matrix,vport);
		
		SetRect(&drag_sel_box,lx,ty,rx,by);
		draw_model_wind_pose(&model,cur_mesh,cur_pose);
	
	} while (track!=kMouseTrackingMouseReleased);
	
	drag_sel_on=FALSE;
	
	free(pv);

		// redraw the model
		
	draw_model_wind_pose(&model,cur_mesh,cur_pose);
		
		// reset the data browser
		
	hilite_vertex_rows();

	InitCursor();
}