Пример #1
0
bool melee_strike_position_object_model(int tick,obj_type *obj,weapon_type *weap,d3pnt *fire_pnt,char *err_str)
{
	int						pose_idx,bone_idx;
	melee_type				*melee;
	model_type				*mdl;
	model_draw_setup		*setup;

		// get correct melee settings

	if (weap==NULL) {
		melee=&obj->melee;
	}
	else {
		melee=&weap->melee;
	}

		// get model

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

		// get current pose

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

	bone_idx=model_find_bone(mdl,melee->object_strike_bone_tag);
	if (bone_idx==-1) {
		if (err_str!=NULL) strcpy(err_str,"Object has missing or no strike bone");
		return(FALSE);
	}
	
	model_draw_setup_object(tick,obj);

	setup=&obj->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 obj

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

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

	return(TRUE);
}
Пример #2
0
bool weapon_get_projectile_position_angle_object_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_setup		*setup;
	
		// get model

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

		// get current pose

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

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

	model_draw_setup_object(tick,obj);

	setup=&obj->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 in front of obj

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

	if (weap->draw.no_rot.on) gl_project_fix_rotation(&fire_pnt->x,&fire_pnt->y,&fire_pnt->z);
	
		// angle from object
		
	fire_ang->x=angle_add(setup->ang.x,obj->view_ang.x);
	fire_ang->y=setup->ang.y;
	fire_ang->z=setup->ang.z;

	return(TRUE);
}
Пример #3
0
bool melee_strike_position_projectile_model(int tick,obj_type *obj,weapon_type *weap,proj_setup_type *proj_setup,proj_type *proj,d3pnt *fire_pnt,char *err_str)
{
	int						pose_idx,bone_idx;
	model_type				*mdl;
	model_draw_setup		*setup;

		// get model

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

		// get current pose

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

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

	model_draw_setup_projectile(tick,proj);

	setup=&proj->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 projectile

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

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

	return(TRUE);
}
Пример #4
0
void model_animation_effect_launch_bone_position(model_draw *draw,int animate_idx,int pose_idx,int bone_idx,d3pnt *pnt)
{
	model_type				*mdl;

		// default to center of model

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

		// bone position

	if ((bone_idx!=-1) && (draw->model_idx!=-1)) {
		mdl=server.model_list.models[draw->model_idx];

		model_calc_draw_bone_position(mdl,&draw->setup,pose_idx,bone_idx,pnt);
		pnt->x+=draw->pnt.x;
		pnt->y+=draw->pnt.y;
		pnt->z+=draw->pnt.z;
	}
}
Пример #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);
}
Пример #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);
}