Esempio n. 1
0
inline void gl_project_poly(int ptsz,int *x,int *y,int *z)
{
	int			i;

	for (i=0;i<ptsz;i++) {
		gl_project_point(&x[i],&y[i],&z[i]);
	}
}
Esempio n. 2
0
void halo_draw_setup(void)
{
	int						n;
	halo_draw_type			*halo_draw;
	
	view.render->halo_draw.in_view_count=0;
	
		// clear all halo spots
	
	for (n=0;n!=view.render->halo_draw.count;n++) {

		halo_draw=&view.render->halo_draw.halos[n];
		halo_draw->in_view=FALSE;

			// is it behind the z?

		if (!gl_project_in_view_z(&halo_draw->pnt)) continue;
				
			// cull halo

		if (!halo_draw_setup_cull(&iface.halo_list.halos[halo_draw->idx],halo_draw->obj_idx,&halo_draw->pnt,&halo_draw->pixel_sz,&halo_draw->alpha)) continue;

			// project the halo
			// and check if on screen

		halo_draw->proj_pnt.x=halo_draw->pnt.x;
		halo_draw->proj_pnt.y=halo_draw->pnt.y;
		halo_draw->proj_pnt.z=halo_draw->pnt.z;
			
		gl_project_point(&halo_draw->proj_pnt);
		halo_draw->proj_pnt.y=view.screen.y_sz-halo_draw->proj_pnt.y;
		
		if (((halo_draw->proj_pnt.x+halo_draw->pixel_sz)<0) || ((halo_draw->proj_pnt.y+halo_draw->pixel_sz)<0) || ((halo_draw->proj_pnt.x-halo_draw->pixel_sz)>=view.screen.x_sz) || ((halo_draw->proj_pnt.y-halo_draw->pixel_sz)>=view.screen.y_sz)) continue;

		halo_draw->in_view=TRUE;
		view.render->halo_draw.in_view_count++;
	}
}
Esempio n. 3
0
void remote_draw_names_setup(void)
{
	int						n,x,y,z,dist;
	bool					hit,has_tag;
	d3pnt					spt,ept,hpt;
	obj_type				*obj;
	model_type				*mdl;
	ray_trace_contact_type	contact;
	
	if (!net_setup.client.joined) return;
	if (!setup.network.show_names) return;
	
		// clear all name draws
	
	obj=server.objs;
	
	for (n=0;n!=server.count.obj;n++) {
		obj->draw.remote_name.on=FALSE;
		obj++;
	}

		// remove names behind z or off-screen
		// ignore console as it won't matter for projection
		
	gl_3D_view();
	gl_3D_rotate(&view.render->camera.pnt,&view.render->camera.ang);
	gl_setup_project();
	
	for (n=0;n!=view.render->draw_list.count;n++) {
		if (view.render->draw_list.items[n].type!=view_render_type_object) continue;
		obj=&server.objs[view.render->draw_list.items[n].idx];
		
		if (!obj->player) continue;
		if (obj->hidden) continue;
		
			// get name point
		
		has_tag=FALSE;

		mdl=NULL;
		if ((obj->draw.uid!=-1) && (obj->draw.on)) mdl=model_find_uid(obj->draw.uid);

		if (mdl!=NULL) {
			x=obj->pnt.x;
			y=obj->pnt.y;
			z=obj->pnt.z;
			has_tag=model_get_name_position(mdl,&obj->draw.setup,&x,&y,&z);
		}

		if (!has_tag) {
			x=obj->pnt.x;
			y=(obj->pnt.y-obj->size.y)-map_enlarge;
			z=obj->pnt.z;
		}
		
			// translate and rotate point
			
		dist=distance_get(x,y,z,view.render->camera.pnt.x,view.render->camera.pnt.y,view.render->camera.pnt.z);
		if (dist>=remote_name_max_distance) continue;

		obj->draw.remote_name.pnt.x=x;
		obj->draw.remote_name.pnt.y=y;
		obj->draw.remote_name.pnt.z=z;
		
			// is it behind the z?

		if (!gl_project_in_view_z(x,y,z)) continue;
				
			// project names

		gl_project_point(&x,&y,&z);

		obj->draw.remote_name.proj_pnt.x=x;
		obj->draw.remote_name.proj_pnt.y=y;
		obj->draw.remote_name.proj_pnt.z=z;
		
			// calculate the fade
			
		if (dist<remote_name_min_distance) {
			obj->draw.remote_name.fade=1.0f;
		}
		else {
			obj->draw.remote_name.fade=1.0f-((float)(dist-remote_name_min_distance)/(float)(remote_name_max_distance-remote_name_min_distance));
		}
		
		obj->draw.remote_name.size=hud.font.text_size_medium-(int)((float)(hud.font.text_size_medium*dist)/(float)(remote_name_max_distance-remote_name_min_distance));
		if (obj->draw.remote_name.size<10) obj->draw.remote_name.size=10;
		
		obj->draw.remote_name.on=TRUE;
	}

		// ray trace remote name to camera's eye level
		// to check for visibility

	ept.x=view.render->camera.pnt.x;
	ept.y=view.render->camera.pnt.y;
	ept.z=view.render->camera.pnt.z;

	contact.obj.on=TRUE;
	contact.proj.on=FALSE;

	contact.hit_mode=poly_ray_trace_hit_mode_all;
	contact.origin=poly_ray_trace_origin_object;

	for (n=0;n!=server.count.obj;n++) {
		obj=&server.objs[n];
		if (!obj->draw.remote_name.on) continue;

		spt.x=obj->draw.remote_name.pnt.x;
		spt.y=obj->draw.remote_name.pnt.y;
		spt.z=obj->draw.remote_name.pnt.z;

		contact.obj.ignore_uid=obj->uid;
		
		hit=ray_trace_map_by_point(&spt,&ept,&hpt,&contact);
		
		if (camera.mode==cv_fpp) {
			if (hit) {
				if (contact.obj.uid!=server.player_obj_uid) {
					obj->draw.remote_name.on=FALSE;
					continue;
				}
			}
			else {
				obj->draw.remote_name.on=FALSE;
				continue;
			}
		}
		else {
			if (hit) {
				obj->draw.remote_name.on=FALSE;
				continue;
			}
		}
	}
}
Esempio n. 4
0
void view_draw_debug_info(d3pnt *pnt,d3pnt *size,int count,char *strs)
{
	int						n,x,y,dist;
	d3col					col;
	d3pnt					spt,ept,win_pnt;
	ray_trace_contact_type	contact;

		// only show closer objects

	dist=distance_get(pnt->x,pnt->y,pnt->z,view.render->camera.pnt.x,view.render->camera.pnt.y,view.render->camera.pnt.z);
	if (dist>25000) return;

		// ray trace check

	spt.x=pnt->x;
	spt.y=pnt->y-size->y;
	spt.z=pnt->z;

	ept.x=view.render->camera.pnt.x;
	ept.y=view.render->camera.pnt.y;
	ept.z=view.render->camera.pnt.z;

	contact.obj.on=FALSE;
	contact.proj.on=FALSE;

	contact.origin=poly_ray_trace_origin_object;

	if (ray_trace_map_by_point(&spt,&ept,&contact)) return;

		// project the mid point

	win_pnt.x=pnt->x;
	win_pnt.y=pnt->y-size->y;
	win_pnt.z=pnt->z;

	gl_project_point(&win_pnt);

		// draw the info

	gl_2D_view_interface();
	
	glDisable(GL_DEPTH_TEST);
	
		// covert to interface resolution

	x=(win_pnt.x*iface.scale_x)/view.screen.x_sz;
	y=((view.screen.y_sz-win_pnt.y)*iface.scale_y)/view.screen.y_sz;

	y-=(iface.font.text_size_small*count);

		// draw text

	col.r=col.b=1.0f;
	col.g=0.0f;
	
	gl_text_start(font_hud_index,iface.font.text_size_small,FALSE);

	for (n=0;n!=count;n++) {
		y+=iface.font.text_size_small;
		gl_text_draw(x,y,(char*)&strs[n*128],tx_center,FALSE,&col,1.0f);
	}

	gl_text_end();

	glEnable(GL_DEPTH_TEST);

		// restore original projection

	gl_3D_view();
	gl_3D_rotate(&view.render->camera.pnt,&view.render->camera.ang);
}