Esempio n. 1
0
File: hand.c Progetto: rzel/dim3
void draw_weapon_hand_setup(obj_type *obj,weapon_type *weap)
{
	int				tick;
    model_draw		*draw;
	model_type		*mdl;
	
		// weapons hidden or zoom on?
		
	if (obj->hide_all_weapons) return;
	if ((weap->zoom.on) && (weap->zoom.mode!=zoom_mode_off) && (obj->zoom_draw.on) && (!weap->zoom.show_weapon)) return;

		// weapon model draw
		
	draw=&weap->draw;
	if ((draw->model_idx==-1) || (!draw->on)) return;
	
	mdl=server.model_list.models[draw->model_idx];

		// regular weapon model

	tick=game_time_get();
	
	model_draw_setup_clear(mdl,&draw->setup);
	model_draw_setup_weapon(obj,weap,FALSE,FALSE);

	model_calc_animation(draw,tick);
	model_calc_draw_bones(draw);
	
	render_model_setup(draw,tick);
	render_model_build_vertex_lists(draw,TRUE);

		// dual wielded weapons

	if ((weap->dual.on) && (weap->dual.active)) {
	
		draw=&weap->draw_dual;
		if ((draw->model_idx!=-1) && (draw->on)) {
			mdl=server.model_list.models[draw->model_idx];

			model_draw_setup_clear(mdl,&draw->setup);
			model_draw_setup_weapon(obj,weap,FALSE,TRUE);

			model_calc_animation(draw,tick);
			model_calc_draw_bones(draw);
			
			render_model_setup(draw,tick);
			render_model_build_vertex_lists(draw,TRUE);
		}
	}
}
Esempio n. 2
0
model_draw* script_bone_function_setup(void)
{
	obj_type			*obj;
	weapon_type			*weap;
	proj_type			*proj;
	
	switch (js.attach.thing_type) {
	
		case thing_type_object:
			obj=object_find_uid(js.attach.thing_uid);
			model_draw_setup_object(js.time.current_tick,obj);
			return(&obj->draw);
			
		case thing_type_weapon:
			weap=weapon_find_uid(js.attach.thing_uid);
			obj=object_find_uid(weap->obj_uid);
			model_draw_setup_weapon(js.time.current_tick,obj,weap,FALSE,FALSE);
			return(&weap->draw);
			
		case thing_type_projectile:
			proj=projectile_find_uid(js.attach.thing_uid);
			model_draw_setup_projectile(js.time.current_tick,proj);
			return(&proj->draw);
			
		case thing_type_projectile_setup:
			JS_ReportError(js.cx,"There is no model to get bone positions from");
			return(NULL);
			
	}
	
	return(NULL);
}
Esempio n. 3
0
bool melee_strike_position_weapon_model(int tick,obj_type *obj,weapon_type *weap,d3pnt *fire_pnt,char *err_str)
{
	int						pose_idx,bone_idx;
	model_type				*mdl;
	model_draw_setup		*setup;

		// get model

	mdl=model_find_uid(weap->draw.uid);
	if (mdl==NULL) {
		if (err_str!=NULL) strcpy(err_str,"Weapon has no model");
		return(FALSE);
	}

		// get current pose

	pose_idx=model_find_pose(mdl,weap->melee.strike_pose_name);
	if (pose_idx==-1) {
		if (err_str!=NULL) strcpy(err_str,"Weapon has missing or no strike pose");
		return(FALSE);
	}
	
		// get 'fire' bone offset

	bone_idx=model_find_bone(mdl,weap->melee.strike_bone_tag);
	if (bone_idx==-1) {
		if (err_str!=NULL) strcpy(err_str,"Weapon has missing or no strike bone");
		return(FALSE);
	}

	model_draw_setup_weapon(tick,obj,weap,TRUE,FALSE);

	setup=&weap->draw.setup;

	setup->move.x=setup->move.y=setup->move.z=0;
	setup->sway.x=setup->sway.y=setup->sway.z=0.0f;

	model_calc_draw_bone_position(mdl,setup,pose_idx,bone_idx,&fire_pnt->x,&fire_pnt->y,&fire_pnt->z);
	
		// move fire point to weapon

	fire_pnt->x+=weap->draw.pnt.x;
	fire_pnt->y+=weap->draw.pnt.y+obj->duck.y_move;
	fire_pnt->z+=weap->draw.pnt.z;

	if (weap->draw.no_rot.on) gl_project_fix_rotation(&fire_pnt->x,&fire_pnt->y,&fire_pnt->z);

	return(TRUE);
}
Esempio n. 4
0
void run_objects_no_slice(int tick)
{
	int				n;
	obj_type		*obj;
	weapon_type		*weap;

	obj=server.objs;

	for (n=0;n!=server.count.obj;n++) {

		if (!obj->hidden) {
			
			model_draw_setup_object(tick,obj);
			model_run_animation(&obj->draw);

			if (!obj->scenery.on) {

					// fades

				model_fade_run(tick,&obj->draw);
				model_mesh_fade_run(tick,&obj->draw);

					// held weapons

				if (obj->player) {
					weap=weapon_find_current(obj);
					if (weap!=NULL) {
						model_draw_setup_weapon(tick,obj,weap,FALSE,FALSE);
						weapon_run_hand(obj,tick);
					}
				}

			}
		}
		
		obj++;
	}
}
Esempio n. 5
0
bool weapon_get_projectile_position_angle_weapon_barrel(int tick,obj_type *obj,weapon_type *weap,d3pnt *fire_pnt,d3ang *fire_ang,char *err_str)
{
	int						pose_idx,bone_idx,dist;
	d3pnt					barrel_pnt;
	model_type				*mdl;
	model_draw				*draw;
	model_draw_setup		*setup;

		// get weapon model

	mdl=model_find_uid(weap->draw.uid);
	if (mdl==NULL) {
		if (err_str!=NULL) strcpy(err_str,"Weapon has no model");
		return(FALSE);
	}

		// get current pose

	pose_idx=model_find_pose(mdl,weap->proj.fire_pose_name);
	if (pose_idx==-1) {
		if (err_str!=NULL) strcpy(err_str,"Weapon has missing or no fire pose");
		return(FALSE);
	}
	
		// get 'fire' bone offset and calc

	bone_idx=model_find_bone(mdl,weap->proj.fire_bone_tag);
	if (bone_idx==-1) {
		if (err_str!=NULL) strcpy(err_str,"Weapon has missing or no fire bone");
		return(FALSE);
	}

	model_draw_setup_weapon(tick,obj,weap,TRUE,weap->dual.in_dual);

	if (weap->dual.in_dual) {
		draw=&weap->draw_dual;
	}
	else {
		draw=&weap->draw;
	}

	setup=&draw->setup;

	setup->move.x=setup->move.y=setup->move.z=0;
	setup->sway.x=setup->sway.y=setup->sway.z=0.0f;

	model_calc_draw_bone_position(mdl,setup,pose_idx,bone_idx,&fire_pnt->x,&fire_pnt->y,&fire_pnt->z);

	if (draw->flip_x) fire_pnt->x=-fire_pnt->x;

	fire_pnt->x+=draw->pnt.x;
	fire_pnt->y+=draw->pnt.y;
	fire_pnt->z+=draw->pnt.z;

	if (draw->no_rot.on) gl_project_fix_rotation(&fire_pnt->x,&fire_pnt->y,&fire_pnt->z);

		// get 'barrel' bone offset (draw bones already calced above)

	bone_idx=model_find_bone(mdl,weap->proj.barrel_bone_tag);
	if (bone_idx==-1) {
		if (err_str!=NULL) strcpy(err_str,"Weapon has missing or no barrel bone");
		return(FALSE);
	}

	model_get_draw_bone_position(setup,bone_idx,&barrel_pnt.x,&barrel_pnt.y,&barrel_pnt.z);

	if (draw->flip_x) barrel_pnt.x=-barrel_pnt.x;

	barrel_pnt.x+=draw->pnt.x;
	barrel_pnt.y+=draw->pnt.y;
	barrel_pnt.z+=draw->pnt.z;

	if (draw->no_rot.on) gl_project_fix_rotation(&barrel_pnt.x,&barrel_pnt.y,&barrel_pnt.z);

		// angles between them

	dist=distance_2D_get(0,0,(fire_pnt->x-barrel_pnt.x),(fire_pnt->z-barrel_pnt.z));
	fire_ang->x=-(180.0f-angle_find(0,0,(fire_pnt->y-barrel_pnt.y),dist));
	fire_ang->y=angle_find(barrel_pnt.x,barrel_pnt.z,fire_pnt->x,fire_pnt->z);
	fire_ang->z=0.0f;

	return(TRUE);
}
Esempio n. 6
0
bool weapon_get_projectile_position_angle_weapon_model(int tick,obj_type *obj,weapon_type *weap,d3pnt *fire_pnt,d3ang *fire_ang,char *err_str)
{
	int						pose_idx,bone_idx;
	model_type				*mdl;
	model_draw				*draw;
	model_draw_setup		*setup;

		// get model

	mdl=model_find_uid(weap->draw.uid);
	if (mdl==NULL) {
		if (err_str!=NULL) strcpy(err_str,"Weapon has no model");
		return(FALSE);
	}

		// get current pose

	pose_idx=model_find_pose(mdl,weap->proj.fire_pose_name);
	if (pose_idx==-1) {
		if (err_str!=NULL) strcpy(err_str,"Weapon has missing or no fire pose");
		return(FALSE);
	}
	
		// get 'fire' bone offset and calc

	bone_idx=model_find_bone(mdl,weap->proj.fire_bone_tag);
	if (bone_idx==-1) {
		if (err_str!=NULL) strcpy(err_str,"Weapon has missing or no fire bone");
		return(FALSE);
	}

	model_draw_setup_weapon(tick,obj,weap,TRUE,weap->dual.in_dual);

	if (weap->dual.in_dual) {
		draw=&weap->draw_dual;
	}
	else {
		draw=&weap->draw;
	}

	setup=&draw->setup;

	setup->move.x=setup->move.y=setup->move.z=0;
	setup->sway.x=setup->sway.y=setup->sway.z=0.0f;

	model_calc_draw_bone_position(mdl,setup,pose_idx,bone_idx,&fire_pnt->x,&fire_pnt->y,&fire_pnt->z);

	if (draw->flip_x) fire_pnt->x=-fire_pnt->x;
	
	fire_pnt->x+=draw->pnt.x;
	fire_pnt->y+=draw->pnt.y;
	fire_pnt->z+=draw->pnt.z;

	if (draw->no_rot.on) gl_project_fix_rotation(&fire_pnt->x,&fire_pnt->y,&fire_pnt->z);
	
		// fire angle

	fire_ang->x=angle_add(setup->ang.x,obj->draw.setup.ang.x);
	fire_ang->y=angle_add(setup->ang.y,angle_add(obj->draw.setup.ang.y,180.0f));
	fire_ang->z=angle_add(setup->ang.z,obj->draw.setup.ang.z);
	
	if (draw->flip_x) fire_ang->y=angle_add(fire_ang->y,180.0f);

	return(TRUE);
}