您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ vm_vec_scale_add函数代码示例

51自学网 2021-06-03 09:45:49
  C++
这篇教程C++ vm_vec_scale_add函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中vm_vec_scale_add函数的典型用法代码示例。如果您正苦于以下问题:C++ vm_vec_scale_add函数的具体用法?C++ vm_vec_scale_add怎么用?C++ vm_vec_scale_add使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了vm_vec_scale_add函数的23个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: create_low_detail_poly

void create_low_detail_poly(int global_index, vec3d *tcp, vec3d *rightv, vec3d *upv){    float		scale;    gshield_tri	*trip;    trip = &Global_tris[global_index];    scale = vm_vec_mag(tcp) * 2.0f;    vm_vec_scale_add(&trip->verts[0].pos, tcp, rightv, -scale/2.0f);    vm_vec_scale_add2(&trip->verts[0].pos, upv, scale/2.0f);    vm_vec_scale_add(&trip->verts[1].pos, &trip->verts[0].pos, rightv, scale);    vm_vec_scale_add(&trip->verts[2].pos, &trip->verts[1].pos, upv, -scale);    vm_vec_scale_add(&trip->verts[3].pos, &trip->verts[2].pos, rightv, -scale);    //	Set u, v coordinates.    //	Note, this need only be done once, as it's common for all explosions.    trip->verts[0].u = 0.0f;    trip->verts[0].v = 0.0f;    trip->verts[1].u = 1.0f;    trip->verts[1].v = 0.0f;    trip->verts[2].u = 1.0f;    trip->verts[2].v = 1.0f;    trip->verts[3].u = 0.0f;    trip->verts[3].v = 1.0f;}
开发者ID:sobczyk,项目名称:fs2open,代码行数:33,


示例2: draw_player

void draw_player( object * obj ){	vms_vector arrow_pos, head_pos;	g3s_point sphere_point, arrow_point, head_point;	// Draw Console player -- shaped like a ellipse with an arrow.	g3_rotate_point(&sphere_point,&obj->pos);	g3_draw_sphere(&sphere_point,obj->size);	// Draw shaft of arrow	vm_vec_scale_add( &arrow_pos, &obj->pos, &obj->orient.fvec, obj->size*3 );	g3_rotate_point(&arrow_point,&arrow_pos);	automap_draw_line(&sphere_point, &arrow_point);	// Draw right head of arrow	vm_vec_scale_add( &head_pos, &obj->pos, &obj->orient.fvec, obj->size*2 );	vm_vec_scale_add2( &head_pos, &obj->orient.rvec, obj->size*1 );	g3_rotate_point(&head_point,&head_pos);	automap_draw_line(&arrow_point, &head_point);	// Draw left head of arrow	vm_vec_scale_add( &head_pos, &obj->pos, &obj->orient.fvec, obj->size*2 );	vm_vec_scale_add2( &head_pos, &obj->orient.rvec, obj->size*(-1) );	g3_rotate_point(&head_point,&head_pos);	automap_draw_line(&arrow_point, &head_point);	// Draw player's up vector	vm_vec_scale_add( &arrow_pos, &obj->pos, &obj->orient.uvec, obj->size*2 );	g3_rotate_point(&arrow_point,&arrow_pos);	automap_draw_line(&sphere_point, &arrow_point);}
开发者ID:CDarrow,项目名称:DXX-Retro,代码行数:31,


示例3: maybe_create_new_grid

//	Project the viewer's position onto the grid plane.  If more than threshold distance//	from grid center, move grid center.void maybe_create_new_grid(grid* gridp, vector *pos, matrix *orient, int force){	int roundoff;	plane	tplane;	vector	gpos, tmp, c;	float	dist_to_plane;	float	square_size, ux, uy, uz;	ux = tplane.A = gridp->gmatrix.v.uvec.xyz.x;	uy = tplane.B = gridp->gmatrix.v.uvec.xyz.y;	uz = tplane.C = gridp->gmatrix.v.uvec.xyz.z;	tplane.D = gridp->planeD;	compute_point_on_plane(&c, &tplane, pos);	dist_to_plane = fl_abs(vm_dist_to_plane(pos, &gridp->gmatrix.v.uvec, &c));	square_size = 1.0f;	while (dist_to_plane >= 25.0f)	{		square_size *= 10.0f;		dist_to_plane /= 10.0f;	}		if (fvi_ray_plane(&gpos, &gridp->center, &gridp->gmatrix.v.uvec, pos, &orient->v.fvec, 0.0f)<0.0f)	{		vector p;		vm_vec_scale_add(&p,pos,&orient->v.fvec, 100.0f );		compute_point_on_plane(&gpos, &tplane, &p );	}	if (vm_vec_dist(&gpos, &c) > 50.0f * square_size)	{		vm_vec_sub(&tmp, &gpos, &c);		vm_vec_normalize(&tmp);		vm_vec_scale_add(&gpos, &c, &tmp, 50.0f * square_size);	}	roundoff = (int) square_size * 10;	if (!ux)		gpos.xyz.x = fl_roundoff(gpos.xyz.x, roundoff);	if (!uy)		gpos.xyz.y = fl_roundoff(gpos.xyz.y, roundoff);	if (!uz)		gpos.xyz.z = fl_roundoff(gpos.xyz.z, roundoff);	if ((square_size != gridp->square_size) ||		(gpos.xyz.x != gridp->center.xyz.x) ||		(gpos.xyz.y != gridp->center.xyz.y) ||		(gpos.xyz.z != gridp->center.xyz.z) || force)	{		gridp->square_size = square_size;		gridp->center = gpos;		modify_grid(gridp);	}}
开发者ID:lubomyr,项目名称:freespace2,代码行数:55,


示例4: trail_calc_facing_pts

// output top and bottom vectors// fvec == forward vector (eye viewpoint basically. in world coords)// pos == world coordinate of the point we're calculating "around"// w == width of the diff between top and bottom around posvoid trail_calc_facing_pts( vec3d *top, vec3d *bot, vec3d *fvec, vec3d *pos, float w ){	vec3d uvec, rvec;	vm_vec_sub( &rvec, &Eye_position, pos );	if (!IS_VEC_NULL(&rvec))		vm_vec_normalize( &rvec );	vm_vec_crossprod(&uvec,fvec,&rvec);	if (!IS_VEC_NULL(&uvec))		vm_vec_normalize(&uvec);	vm_vec_scale_add( top, pos, &uvec, w * 0.5f );	vm_vec_scale_add( bot, pos, &uvec, -w * 0.5f );}
开发者ID:CapeTownMonster,项目名称:fs2open.github.com,代码行数:19,


示例5: cmeasure_set_ship_launch_vel

//Used to set a countermeasure velocity after being launched from a ship as a countermeasure//ie not as a primary or secondary.void cmeasure_set_ship_launch_vel(object *objp, object *parent_objp, int arand){	vec3d vel, rand_vec;	//Get cmeasure rear velocity in world	vm_vec_scale_add(&vel, &parent_objp->phys_info.vel, &parent_objp->orient.vec.fvec, -25.0f);	//Get random velocity vector	static_randvec(arand+1, &rand_vec);	//Add it to the rear velocity	vm_vec_scale_add2(&vel, &rand_vec, 2.0f);	objp->phys_info.vel = vel;	//Zero out this stuff so it isn't moving	vm_vec_zero(&objp->phys_info.rotvel);	vm_vec_zero(&objp->phys_info.max_vel);	vm_vec_zero(&objp->phys_info.max_rotvel);		// blow out his reverse thrusters. Or drag, same thing.	objp->phys_info.rotdamp = 10000.0f;	objp->phys_info.side_slip_time_const = 10000.0f;	objp->phys_info.max_vel.xyz.z = -25.0f;	vm_vec_copy_scale(&objp->phys_info.desired_vel, &objp->orient.vec.fvec, objp->phys_info.max_vel.xyz.z );}
开发者ID:bryansee,项目名称:fs2open.github.com,代码行数:29,


示例6: create_player_appearance_effect

//create flash for player appearancevoid create_player_appearance_effect(object *player_obj){	vms_vector pos;	object *effect_obj;#ifndef NDEBUG	{		int objnum = player_obj-Objects;		if ( (objnum < 0) || (objnum > Highest_object_index) )			Int3(); // See Rob, trying to track down weird network bug	}#endif	if (player_obj == Viewer)		vm_vec_scale_add(&pos, &player_obj->pos, &player_obj->orient.fvec, fixmul(player_obj->size,flash_dist));	else		pos = player_obj->pos;	effect_obj = object_create_explosion(player_obj->segnum, &pos, player_obj->size, VCLIP_PLAYER_APPEARANCE );	if (effect_obj) {		effect_obj->orient = player_obj->orient;		if ( Vclip[VCLIP_PLAYER_APPEARANCE].sound_num > -1 )			digi_link_sound_to_object( Vclip[VCLIP_PLAYER_APPEARANCE].sound_num, effect_obj-Objects, 0, F1_0);	}}
开发者ID:Mako88,项目名称:DXX-Retro,代码行数:28,


示例7: mc_shield_check_common

bool mc_shield_check_common(shield_tri	*tri){	vec3d * points[3];	vec3d hitpoint;	 	float dist;	float sphere_check_closest_shield_dist = FLT_MAX;	// Check to see if Mc_pmly is facing away from ray.  If so, don't bother	// checking it.	if (vm_vec_dot(&Mc_direction,&tri->norm) > 0.0f)	{		return false;	}	// get the vertices in the form the next function wants them	for (int j = 0; j < 3; j++ )		points[j] = &Mc_pm->shield.verts[tri->verts[j]].pos;	if (!(Mc->flags & MC_CHECK_SPHERELINE) ) {	// Don't do this test for sphere colliding against shields		// Find the intersection of this ray with the plane that the Mc_pmly		// lies in		dist = fvi_ray_plane(NULL, points[0],&tri->norm,&Mc_p0,&Mc_direction,0.0f);		if ( dist < 0.0f ) return false; // If the ray is behind the plane there is no collision		if ( !(Mc->flags & MC_CHECK_RAY) && (dist > 1.0f) ) return false; // The ray isn't long enough to intersect the plane		// Find the hit Mc_pmint		vm_vec_scale_add( &hitpoint, &Mc_p0, &Mc_direction, dist );			// Check to see if the Mc_pmint of intersection is on the plane.  If so, this		// also finds the uv's where the ray hit.		if ( fvi_point_face(&hitpoint, 3, points, &tri->norm, NULL,NULL,NULL ) )	{			Mc->hit_dist = dist;			Mc->shield_hit_tri = (int)(tri - Mc_pm->shield.tris);			Mc->hit_point = hitpoint;			Mc->hit_normal = tri->norm;			Mc->hit_submodel = -1;			Mc->num_hits++;			return true;		// We hit, so we're done		}	} else {		// Sphere check against shield					// This needs to look at *all* shield tris and not just return after the first hit		// HACK HACK!! The 10000.0 is the face radius, I didn't know this,		// so I'm assume 10000 would be as big as ever.		mc_check_sphereline_face(3, points, points[0], 10000.0f, &tri->norm, NULL, 0, NULL, NULL);		if (Mc->num_hits && Mc->hit_dist < sphere_check_closest_shield_dist) {			// same behavior whether face or edge			// normal, edge_hit, hit_point all updated thru sphereline_face			sphere_check_closest_shield_dist = Mc->hit_dist;			Mc->shield_hit_tri = (int)(tri - Mc_pm->shield.tris);			Mc->hit_submodel = -1;			Mc->num_hits++;			return true;		// We hit, so we're done		}	} // Mc->flags & MC_CHECK_SPHERELINE else	return false;}
开发者ID:Echelon9,项目名称:fs2open.github.com,代码行数:59,


示例8: mc_check_face

static void mc_check_face(int nv, vec3d **verts, vec3d *plane_pnt, float face_rad, vec3d *plane_norm, uv_pair *uvl_list, int ntmap, ubyte *poly, bsp_collision_leaf* bsp_leaf){	vec3d	hit_point;	float		dist;	float		u, v;	// Check to see if poly is facing away from ray.  If so, don't bother	// checking it.	if (vm_vec_dot(&Mc_direction,plane_norm) > 0.0f)	{		return;	}	// Find the intersection of this ray with the plane that the poly	dist = fvi_ray_plane(NULL, plane_pnt, plane_norm, &Mc_p0, &Mc_direction, 0.0f);	if ( dist < 0.0f ) return; // If the ray is behind the plane there is no collision	if ( !(Mc->flags & MC_CHECK_RAY) && (dist > 1.0f) ) return; // The ray isn't long enough to intersect the plane	// If the ray hits, but a closer intersection has already been found, return	if ( Mc->num_hits && (dist >= Mc->hit_dist ) ) return;		// Find the hit point	vm_vec_scale_add( &hit_point, &Mc_p0, &Mc_direction, dist );		// Check to see if the point of intersection is on the plane.  If so, this	// also finds the uv's where the ray hit.	if ( fvi_point_face(&hit_point, nv, verts, plane_norm, &u,&v, uvl_list ) )	{		Mc->hit_dist = dist;		Mc->hit_point = hit_point;		Mc->hit_submodel = Mc_submodel;		Mc->hit_normal = *plane_norm;		if ( uvl_list )	{			Mc->hit_u = u;			Mc->hit_v = v;			if ( ntmap < 0 ) {				Mc->hit_bitmap = -1;			} else {				Mc->hit_bitmap = Mc_pm->maps[ntmap].textures[TM_BASE_TYPE].GetTexture();						}		}				if(ntmap >= 0){			Mc->t_poly = poly;			Mc->f_poly = NULL;		} else {			Mc->t_poly = NULL;			Mc->f_poly = poly;		}		Mc->bsp_leaf = bsp_leaf;//		mprintf(( "Bing!/n" ));		Mc->num_hits++;	}}
开发者ID:Echelon9,项目名称:fs2open.github.com,代码行数:59,


示例9: vm_vec_sub

vms_vector *vm_vec_interp(vms_vector *result, vms_vector *v0, vms_vector *v1, fix scale) {    vms_vector tvec;	vm_vec_sub(&tvec, v1, v0);    vm_vec_scale_add(result, v0, &tvec, scale);    vm_vec_normalize(result);    return result;}
开发者ID:NonCreature0714,项目名称:descent,代码行数:8,


示例10: move_object_to_vector

void move_object_to_vector(vms_vector *vec_through_screen, fix delta_distance){	vms_vector	result;	vm_vec_scale_add(&result, &Viewer->pos, vec_through_screen, vm_vec_dist(&Viewer->pos,&Objects[Cur_object_index].pos)+delta_distance);	move_object_to_position(Cur_object_index, &result);}
开发者ID:devint1,项目名称:descent-win,代码行数:9,


示例11: ssm_get_random_start_pos

void ssm_get_random_start_pos(vector *out, vector *start, matrix *orient, int ssm_index){	vector temp;	ssm_info *s = &Ssm_info[ssm_index];	// get a random vector in the circle of the firing plane	vm_vec_random_in_circle(&temp, start, orient, s->radius, 1);	// offset it a bit	vm_vec_scale_add(out, &temp, &orient->vec.fvec, s->offset);}
开发者ID:chief1983,项目名称:Imperial-Alliance,代码行数:11,


示例12: draw_exit_model

draw_exit_model(){	vms_vector model_pos;	int f=15,u=0;	//21;	vm_vec_scale_add(&model_pos,&mine_exit_point,&mine_exit_orient.fvec,i2f(f));	vm_vec_scale_add2(&model_pos,&mine_exit_orient.uvec,i2f(u));	draw_polygon_model(&model_pos,&mine_exit_orient,NULL,(mine_destroyed)?destroyed_exit_modelnum:exit_modelnum,0,f1_0,NULL,NULL);}
开发者ID:NonCreature0714,项目名称:descent,代码行数:11,


示例13: obj_in_view_cone

// See if an object is in the view cone.// Returns:// 0 if object isn't in the view cone// 1 if object is in cone // This routine could possibly be optimized.  Right now, for an// offscreen object, it has to rotate 8 points to determine it's// offscreen.  Not the best considering we're looking at a sphere.int obj_in_view_cone( object * objp ){	int i;	vector tmp,pt; 	ubyte codes;// Use this to hack out player for testing.// if ( objp == Player_obj ) return 0;// OLD INCORRECT CODE!!!//	g3_rotate_vector(&tmp,&objp->pos);//	codes=g3_code_vector_radius(&tmp, objp->radius);//	if ( !codes )	{//		return 1;		// center is in, so return 1//	}//	return 0;// This I commented out because it will quickly out for// objects in the center, but cause one more rotation// for objects outside the center.  So I figured it// would be best to slow down objects inside by a bit// and not penalize the offscreen ones, which require// 8 rotatations to throw out.//	g3_rotate_vector(&tmp,&objp->pos);//	codes=g3_code_vector(&tmp);//	if ( !codes )	{//		//mprintf(( "Center is in, so render it/n" ));//		return 1;		// center is in, so return 1//	}	// Center isn't in... are other points?	ubyte and_codes = 0xff;	for (i=0; i<8; i++ )	{		vm_vec_scale_add( &pt, &objp->pos, &check_offsets[i], objp->radius );		g3_rotate_vector(&tmp,&pt);		codes=g3_code_vector(&tmp);		if ( !codes )	{			//mprintf(( "A point is inside, so render it./n" ));			return 1;		// this point is in, so return 1		}		and_codes &= codes;	}	if (and_codes)	{		//mprintf(( "All points offscreen, so don't render it./n" ));		return 0;	//all points off screen	}	//mprintf(( "All points inside, so render it, but doesn't need clipping./n" ));	return 1;	}
开发者ID:NonCreature0714,项目名称:freespace2,代码行数:60,


示例14: particle_emit

// Creates a bunch of particles. You pass a structure// rather than a bunch of parameters.void particle_emit( particle_emitter *pe, int type, int optional_data, float range ){	int i, n;	if ( !Particles_enabled )		return;	int n1, n2;	// Account for detail	int percent = get_percent(Detail.num_particles);	//Particle rendering drops out too soon.  Seems to be around 150 m.  Is it detail level controllable?  I'd like it to be 500-1000 	float min_dist = 125.0f;	float dist = vm_vec_dist_quick( &pe->pos, &Eye_position ) / range;	if ( dist > min_dist )	{		percent = fl2i( i2fl(percent)*min_dist / dist );		if ( percent < 1 ) {			return;		}	}	//mprintf(( "Dist = %.1f, percent = %d%%/n", dist, percent ));	n1 = (pe->num_low*percent)/100;	n2 = (pe->num_high*percent)/100;	// How many to emit?	n = (rand() % (n2-n1+1)) + n1;		if ( n < 1 ) return;	for (i=0; i<n; i++ )	{		// Create a particle		vec3d tmp_vel;		vec3d normal;				// What normal the particle emit arond		float radius = (( pe->max_rad - pe->min_rad ) * frand()) + pe->min_rad;		float speed = (( pe->max_vel - pe->min_vel ) * frand()) + pe->min_vel;		float life = (( pe->max_life - pe->min_life ) * frand()) + pe->min_life;		normal.xyz.x = pe->normal.xyz.x + (frand()*2.0f - 1.0f)*pe->normal_variance;		normal.xyz.y = pe->normal.xyz.y + (frand()*2.0f - 1.0f)*pe->normal_variance;		normal.xyz.z = pe->normal.xyz.z + (frand()*2.0f - 1.0f)*pe->normal_variance;		vm_vec_normalize_safe( &normal );		vm_vec_scale_add( &tmp_vel, &pe->vel, &normal, speed );		particle_create( &pe->pos, &tmp_vel, life, radius, type, optional_data );	}}
开发者ID:DahBlount,项目名称:Freespace-Open-Swifty,代码行数:54,


示例15: supernova_get_eye

void supernova_get_eye(vec3d *eye_pos, matrix *eye_orient){	// supernova camera pos	vec3d Supernova_camera_pos;	static matrix Supernova_camera_orient;	vec3d at;	vec3d sun_temp, sun_vec;	vec3d view;	// set the controls for the heart of the sun	stars_get_sun_pos(0, &sun_temp);	vm_vec_add2(&sun_temp, &Player_obj->pos);	vm_vec_sub(&sun_vec, &sun_temp, &Player_obj->pos);	vm_vec_normalize(&sun_vec);	// always set the camera pos	vec3d move;	matrix whee;	vm_vector_2_matrix(&whee, &move, NULL, NULL);	vm_vec_scale_add(&Supernova_camera_pos, &Player_obj->pos, &whee.vec.rvec, sn_cam_distance);	vm_vec_scale_add2(&Supernova_camera_pos, &whee.vec.uvec, 30.0f);	//cam->set_position(&Supernova_camera_pos);	*eye_pos = Supernova_camera_pos;	// if we're no longer moving the camera	if(Supernova_time < (SUPERNOVA_CUT_TIME - SUPERNOVA_CAMERA_MOVE_TIME)) {		// *eye_pos = Supernova_camera_pos;		//cam->set_rotation(&Supernova_camera_orient);		*eye_orient = Supernova_camera_orient;	}	// otherwise move it	else {		// get a vector somewhere between the supernova shockwave and the player ship		at = Player_obj->pos;		vm_vec_scale_add2(&at, &sun_vec, sn_distance);		vm_vec_sub(&move, &Player_obj->pos, &at);		vm_vec_normalize(&move);		// linearly move towards the player pos		float pct = ((SUPERNOVA_CUT_TIME - Supernova_time) / SUPERNOVA_CAMERA_MOVE_TIME);		vm_vec_scale_add2(&at, &move, sn_distance * pct);		vm_vec_sub(&view, &at, &Supernova_camera_pos);		vm_vec_normalize(&view);		vm_vector_2_matrix(&Supernova_camera_orient, &view, NULL, NULL);		//cam->set_rotation(&Supernova_camera_orient);		*eye_orient = Supernova_camera_orient;	}	//return supernova_camera;}
开发者ID:DahBlount,项目名称:Freespace-Open-Swifty,代码行数:51,


示例16: ssm_get_random_start_pos

void ssm_get_random_start_pos(vec3d *out, vec3d *start, matrix *orient, size_t ssm_index){	vec3d temp;	ssm_info *s = &Ssm_info[ssm_index];	float radius, offset;	if (s->max_radius == -1.0f)		radius = s->radius;	else		radius = frand_range(s->radius, s->max_radius);	if (s->max_offset == -1.0f)		offset = s->offset;	else		offset = frand_range(s->offset, s->max_offset);	switch (s->shape) {	case SSM_SHAPE_SPHERE:		// get a random vector in a sphere around the target		vm_vec_random_in_sphere(&temp, start, orient, radius, 1);		break;	case SSM_SHAPE_CIRCLE:		// get a random vector in the circle of the firing plane		vm_vec_random_in_circle(&temp, start, orient, radius, 1);		break;	case SSM_SHAPE_POINT:		// boooring		vm_vec_scale_add(&temp, start, &orient->vec.fvec, radius);		break;	default:		Assertion(false, "Unknown shape '%d' in SSM type #" SIZE_T_ARG " ('%s'). This should not be possible; get a coder!/n", s->shape, ssm_index, s->name);		break;	}	// offset it a bit	vm_vec_scale_add(out, &temp, &orient->vec.fvec, offset);}
开发者ID:Kobrar,项目名称:fs2open.github.com,代码行数:37,


示例17: collide_predict_large_ship

//	Return true if objp will collide with some large object.//	Don't check for an object this ship is docked to.int collide_predict_large_ship(object *objp, float distance){	object	*objp2;	vec3d	cur_pos, goal_pos;	ship_info	*sip;	sip = &Ship_info[Ships[objp->instance].ship_info_index];	cur_pos = objp->pos;	vm_vec_scale_add(&goal_pos, &cur_pos, &objp->orient.vec.fvec, distance);	for ( objp2 = GET_FIRST(&obj_used_list); objp2 != END_OF_LIST(&obj_used_list); objp2 = GET_NEXT(objp2) ) {		if ((objp != objp2) && (objp2->type == OBJ_SHIP)) {			if (Ship_info[Ships[objp2->instance].ship_info_index].flags & (SIF_BIG_SHIP | SIF_HUGE_SHIP)) {				if (dock_check_find_docked_object(objp, objp2))					continue;				if (cpls_aux(&goal_pos, objp2, objp))					return 1;			}		} else if (!(sip->flags & (SIF_BIG_SHIP | SIF_HUGE_SHIP)) && (objp2->type == OBJ_ASTEROID)) {			if (vm_vec_dist_quick(&objp2->pos, &objp->pos) < (distance + objp2->radius)*2.5f) {				vec3d	pos, delvec;				int		count;				float		d1;				d1 = 2.5f * distance + objp2->radius;				count = (int) (d1/(objp2->radius + objp->radius));	//	Scale up distance, else looks like there would be a collision.				pos = cur_pos;				vm_vec_normalized_dir(&delvec, &goal_pos, &cur_pos);				vm_vec_scale(&delvec, d1/count);				for (; count>0; count--) {					if (vm_vec_dist_quick(&pos, &objp2->pos) < objp->radius + objp2->radius)						return 1;					vm_vec_add2(&pos, &delvec);				}			}		}	}	return 0;}
开发者ID:achilleas-k,项目名称:fs2open.github.com,代码行数:46,


示例18: PNT

void geometry_shader_batcher::draw_bitmap(vertex *position, int orient, float rad, float depth){	rad *= 1.41421356f;//1/0.707, becase these are the points of a square or width and height rad	vec3d PNT(position->world);	vec3d fvec;	// get the direction from the point to the eye	vm_vec_sub(&fvec, &View_position, &PNT);	vm_vec_normalize_safe(&fvec);	// move the center of the sprite based on the depth parameter	if ( depth != 0.0f )		vm_vec_scale_add(&PNT, &PNT, &fvec, depth);	particle_pnt new_particle;	vec3d up = {{{0.0f, 1.0f, 0.0f}}};	new_particle.position = position->world;	new_particle.size = rad;	int direction = orient % 4;	if ( direction == 1 ) {		up.xyz.x = 0.0f;		up.xyz.y = -1.0f;		up.xyz.z = 0.0f;	} else if ( direction == 2 ) {		up.xyz.x = -1.0f;		up.xyz.y = 0.0f;		up.xyz.z = 0.0f;	} else if ( direction == 3 ) {		up.xyz.x = 1.0f;		up.xyz.y = 0.0f;		up.xyz.z = 0.0f;	}	new_particle.up = up;	vertices.push_back(new_particle);}
开发者ID:RandomTiger,项目名称:fs2open.github.com,代码行数:41,


示例19: dump_door_debugging_info

dump_door_debugging_info(){	object *obj;	vms_vector new_pos;	fvi_query fq;	fvi_info hit_info;	int fate;	PHYSFS_file *dfile;	int wall_num;	obj = &Objects[Players[Player_num].objnum];	vm_vec_scale_add(&new_pos,&obj->pos,&obj->orient.fvec,i2f(100));	fq.p0						= &obj->pos;	fq.startseg				= obj->segnum;	fq.p1						= &new_pos;	fq.rad					= 0;	fq.thisobjnum			= Players[Player_num].objnum;	fq.ignore_obj_list	= NULL;	fq.flags					= 0;	fate = find_vector_intersection(&fq,&hit_info);	dfile = PHYSFSX_openWriteBuffered("door.out");	PHYSFSX_printf(dfile,"FVI hit_type = %d/n",fate);	PHYSFSX_printf(dfile,"    hit_seg = %d/n",hit_info.hit_seg);	PHYSFSX_printf(dfile,"    hit_side = %d/n",hit_info.hit_side);	PHYSFSX_printf(dfile,"    hit_side_seg = %d/n",hit_info.hit_side_seg);	PHYSFSX_printf(dfile,"/n");	if (fate == HIT_WALL) {		wall_num = Segments[hit_info.hit_seg].sides[hit_info.hit_side].wall_num;		PHYSFSX_printf(dfile,"wall_num = %d/n",wall_num);		if (wall_num != -1) {			wall *wall = &Walls[wall_num];			active_door *d;			int i;			PHYSFSX_printf(dfile,"    segnum = %d/n",wall->segnum);			PHYSFSX_printf(dfile,"    sidenum = %d/n",wall->sidenum);			PHYSFSX_printf(dfile,"    hps = %x/n",wall->hps);			PHYSFSX_printf(dfile,"    linked_wall = %d/n",wall->linked_wall);			PHYSFSX_printf(dfile,"    type = %d/n",wall->type);			PHYSFSX_printf(dfile,"    flags = %x/n",wall->flags);			PHYSFSX_printf(dfile,"    state = %d/n",wall->state);			PHYSFSX_printf(dfile,"    trigger = %d/n",wall->trigger);			PHYSFSX_printf(dfile,"    clip_num = %d/n",wall->clip_num);			PHYSFSX_printf(dfile,"    keys = %x/n",wall->keys);			PHYSFSX_printf(dfile,"    controlling_trigger = %d/n",wall->controlling_trigger);			PHYSFSX_printf(dfile,"    cloak_value = %d/n",wall->cloak_value);			PHYSFSX_printf(dfile,"/n");			for (i=0;i<Num_open_doors;i++) {		//find door				d = &ActiveDoors[i];				if (d->front_wallnum[0]==wall-Walls || d->back_wallnum[0]==wall-Walls || (d->n_parts==2 && (d->front_wallnum[1]==wall-Walls || d->back_wallnum[1]==wall-Walls)))					break;			}			if (i>=Num_open_doors)				PHYSFSX_printf(dfile,"No active door./n");			else {				PHYSFSX_printf(dfile,"Active door %d:/n",i);				PHYSFSX_printf(dfile,"    n_parts = %d/n",d->n_parts);				PHYSFSX_printf(dfile,"    front_wallnum = %d,%d/n",d->front_wallnum[0],d->front_wallnum[1]);				PHYSFSX_printf(dfile,"    back_wallnum = %d,%d/n",d->back_wallnum[0],d->back_wallnum[1]);				PHYSFSX_printf(dfile,"    time = %x/n",d->time);			}		}	}	PHYSFSX_printf(dfile,"/n");	PHYSFSX_printf(dfile,"/n");	PHYSFS_close(dfile);}
开发者ID:nightwish75,项目名称:d2x-ta,代码行数:81,


示例20: do_endlevel_frame

do_endlevel_frame(){	static fix timer;	vms_vector save_last_pos;	static fix explosion_wait1=0;	static fix explosion_wait2=0;	static fix bank_rate;	static fix ext_expl_halflife;	save_last_pos = ConsoleObject->last_pos;	//don't let move code change this	object_move_all();	ConsoleObject->last_pos = save_last_pos;	if (ext_expl_playing) {		external_explosion.lifeleft -= FrameTime;		do_explosion_sequence(&external_explosion);		if (external_explosion.lifeleft < ext_expl_halflife)			mine_destroyed = 1;		if (external_explosion.flags & OF_SHOULD_BE_DEAD)			ext_expl_playing = 0;	}	if (cur_fly_speed != desired_fly_speed) {		fix delta = desired_fly_speed - cur_fly_speed;		fix frame_accel = fixmul(FrameTime,FLY_ACCEL);		if (abs(delta) < frame_accel)			cur_fly_speed = desired_fly_speed;		else			if (delta > 0)				cur_fly_speed += frame_accel;			else				cur_fly_speed -= frame_accel;	}	//do big explosions	if (!outside_mine) {		if (Endlevel_sequence==EL_OUTSIDE) {			vms_vector tvec;			vm_vec_sub(&tvec,&ConsoleObject->pos,&mine_side_exit_point);			if (vm_vec_dot(&tvec,&mine_exit_orient.fvec) > 0) {				object *tobj;				outside_mine = 1;				tobj = object_create_explosion(exit_segnum,&mine_side_exit_point,i2f(50),VCLIP_BIG_PLAYER_EXPLOSION);				if (tobj) {					external_explosion = *tobj;					tobj->flags |= OF_SHOULD_BE_DEAD;					flash_scale = 0;	//kill lights in mine					ext_expl_halflife = tobj->lifeleft;					ext_expl_playing = 1;				}					digi_link_sound_to_pos( SOUND_BIG_ENDLEVEL_EXPLOSION, exit_segnum, 0, &mine_side_exit_point, 0, i2f(3)/4 );			}		}		//do explosions chasing player		if ((explosion_wait1-=FrameTime) < 0) {			vms_vector tpnt;			int segnum;			object *expl;			static int sound_count;			vm_vec_scale_add(&tpnt,&ConsoleObject->pos,&ConsoleObject->orient.fvec,-ConsoleObject->size*5);			vm_vec_scale_add2(&tpnt,&ConsoleObject->orient.rvec,(rand()-RAND_MAX/2)*15);			vm_vec_scale_add2(&tpnt,&ConsoleObject->orient.uvec,(rand()-RAND_MAX/2)*15);			segnum = find_point_seg(&tpnt,ConsoleObject->segnum);			if (segnum != -1) {				expl = object_create_explosion(segnum,&tpnt,i2f(20),VCLIP_BIG_PLAYER_EXPLOSION);				if (rand()<10000 || ++sound_count==7) {		//pseudo-random					digi_link_sound_to_pos( SOUND_TUNNEL_EXPLOSION, segnum, 0, &tpnt, 0, F1_0 );					sound_count=0;				}			}			explosion_wait1 = 0x2000 + rand()/4;		}	}	//do little explosions on walls	if (Endlevel_sequence >= EL_FLYTHROUGH && Endlevel_sequence < EL_OUTSIDE)		if ((explosion_wait2-=FrameTime) < 0) {			vms_vector tpnt;			fvi_query fq;//.........这里部分代码省略.........
开发者ID:NonCreature0714,项目名称:descent,代码行数:101,


示例21: load_endlevel_data

//.........这里部分代码省略.........				ubyte pal[768];				if (satellite_bm_instance.bm_data)					free(satellite_bm_instance.bm_data);				iff_error = iff_read_bitmap(p,&satellite_bm_instance,BM_LINEAR,pal);				if (iff_error != IFF_NO_ERROR) {					mprintf((1, "File %s - IFF error: %s",p,iff_errormsg(iff_error)));					Error("File %s - IFF error: %s",p,iff_errormsg(iff_error));				}				satellite_bitmap = &satellite_bm_instance;				gr_remap_bitmap_good( satellite_bitmap, pal, iff_transparent_color, -1);				break;			}			case 5:							//earth pos			case 7: {						//station pos				vms_matrix tm;				vms_angvec ta;				int pitch,head;				sscanf(p,"%d,%d",&head,&pitch);				ta.h = i2f(head)/360;				ta.p = -i2f(pitch)/360;				ta.b = 0;				vm_angles_2_matrix(&tm,&ta);				if (var==5)					satellite_pos = tm.fvec;					//vm_vec_copy_scale(&satellite_pos,&tm.fvec,SATELLITE_DIST);				else					station_pos = tm.fvec;				break;			}			case 6:						//planet size				satellite_size = i2f(atoi(p));				break;		}		var++;	}	Assert(var == NUM_VARS);	// OK, now the data is loaded.  Initialize everything	//find the exit sequence by searching all segments for a side with	//children == -2	for (segnum=0,exit_segnum=-1;exit_segnum==-1 && segnum<=Highest_segment_index;segnum++)		for (sidenum=0;sidenum<6;sidenum++)			if (Segments[segnum].children[sidenum] == -2) {				exit_segnum = segnum;				exit_side = sidenum;				break;			}	Assert(exit_segnum!=-1);	compute_segment_center(&mine_exit_point,&Segments[exit_segnum]);	extract_orient_from_segment(&mine_exit_orient,&Segments[exit_segnum]);	compute_center_point_on_side(&mine_side_exit_point,&Segments[exit_segnum],exit_side);	vm_vec_scale_add(&mine_ground_exit_point,&mine_exit_point,&mine_exit_orient.uvec,-i2f(20));	//compute orientation of surface	{		vms_vector tv;		vms_matrix exit_orient,tm;		vm_angles_2_matrix(&exit_orient,&exit_angles);		vm_transpose_matrix(&exit_orient);		vm_matrix_x_matrix(&surface_orient,&mine_exit_orient,&exit_orient);		vm_copy_transpose_matrix(&tm,&surface_orient);		vm_vec_rotate(&tv,&station_pos,&tm);		vm_vec_scale_add(&station_pos,&mine_exit_point,&tv,STATION_DIST);vm_vec_rotate(&tv,&satellite_pos,&tm);vm_vec_scale_add(&satellite_pos,&mine_exit_point,&tv,SATELLITE_DIST);vm_vector_2_matrix(&tm,&tv,&surface_orient.uvec,NULL);vm_vec_copy_scale(&satellite_upvec,&tm.uvec,SATELLITE_HEIGHT);	}	cfclose(ifile);	endlevel_data_loaded = 1;}
开发者ID:NonCreature0714,项目名称:descent,代码行数:101,


示例22: swarm_update_direction

// ------------------------------------------------------------------// swarm_update_direction()////	Check if we want to update the direction of a swarm missile.//void swarm_update_direction(object *objp, float frametime){	weapon_info	*wip;	weapon		*wp;	object		*hobjp;	swarm_info	*swarmp;	vec3d		obj_to_target;	float			vel, target_dist, radius, missile_speed, missile_dist;	physics_info	*pi;	Assert(objp->instance >= 0 && objp->instance < MAX_WEAPONS);	wp = &Weapons[objp->instance];	if (wp->swarm_index == -1) {		return;	}	wip = &Weapon_info[wp->weapon_info_index];	hobjp = wp->homing_object;	pi = &Objects[wp->objnum].phys_info;	swarmp = &Swarm_missiles[wp->swarm_index];	// check if homing is lost.. if it is then get a new path to move swarm missile along	if ( swarmp->homing_objnum != -1 && hobjp == &obj_used_list ) {		swarmp->change_timestamp = 1;		swarmp->path_num = -1;		swarmp->homing_objnum = -1;	}	if ( hobjp != &obj_used_list ) {		swarmp->homing_objnum = OBJ_INDEX(hobjp);	}	if ( timestamp_elapsed(swarmp->change_timestamp) ) {		if ( swarmp->path_num == -1 ) {			if ( Objects[objp->parent].type != OBJ_SHIP ) {				//AL: parent ship died... so just pick some random paths				swarmp->path_num	= myrand()%4;			} else {				ship *parent_shipp;				parent_shipp = &Ships[Objects[objp->parent].instance];				swarmp->path_num = (parent_shipp->next_swarm_path++)%4;				if ( parent_shipp->next_swarm_path%4 == 0 ) {					swarmp->flags ^= SWARM_POSITIVE_PATH;				}			}			vm_vec_scale_add(&swarmp->original_target, &objp->pos, &objp->orient.vec.fvec, SWARM_CONE_LENGTH);			swarmp->circle_rvec = objp->orient.vec.rvec;			swarmp->circle_uvec = objp->orient.vec.uvec;			swarmp->change_count = 1;			swarmp->change_time = fl2i(SWARM_CHANGE_DIR_TIME + SWARM_TIME_VARIANCE*(frand() - 0.5f) * 2);			vm_vec_zero(&swarmp->last_offset);			missile_speed = pi->speed;			missile_dist	= missile_speed * swarmp->change_time/1000.0f;			if ( missile_dist < SWARM_DIST_OFFSET ) {				missile_dist=i2fl(SWARM_DIST_OFFSET);			}			swarmp->angle_offset = (float)(asin(SWARM_DIST_OFFSET / missile_dist));			Assert(!_isnan(swarmp->angle_offset) );		}		swarmp->change_timestamp = timestamp(swarmp->change_time);		// check if swarm missile is homing, if so need to calculate a new target pos to turn towards		if ( hobjp != &obj_used_list && f2fl(Missiontime - wp->creation_time) > 0.5f && ( f2fl(Missiontime - wp->creation_time) > wip->free_flight_time ) ) {			swarmp->original_target = wp->homing_pos;			// Calculate a rvec and uvec that will determine the displacement from the			// intended target.  Use crossprod to generate a right vector, from the missile			// up vector and the vector connecting missile to the homing object.			swarmp->circle_uvec = objp->orient.vec.uvec;			swarmp->circle_rvec = objp->orient.vec.rvec;			missile_speed = pi->speed;			missile_dist = missile_speed * swarmp->change_time/1000.0f;			if ( missile_dist < SWARM_DIST_OFFSET ) {				missile_dist = i2fl(SWARM_DIST_OFFSET);			}			swarmp->angle_offset = (float)(asin(SWARM_DIST_OFFSET / missile_dist));			Assert(!_isnan(swarmp->angle_offset) );		}		vm_vec_sub(&obj_to_target, &swarmp->original_target, &objp->pos);		target_dist = vm_vec_mag_quick(&obj_to_target);		swarmp->last_dist = target_dist;		// If homing swarm missile is close to target, let missile home in on original target		if ( target_dist < SWARM_DIST_STOP_SWARMING ) {//.........这里部分代码省略.........
开发者ID:Admiral-MS,项目名称:fs2open.github.com,代码行数:101,


示例23: do_physics_sim

//.........这里部分代码省略.........	Assert(obj->mtype.phys_info.brakes==0);		//brakes not used anymore?		//if uses thrust, cannot have zero drag	Assert(!(obj->mtype.phys_info.flags&PF_USES_THRUST) || obj->mtype.phys_info.drag!=0);//mprintf((0,"thrust=%x  speed=%x/n",vm_vec_mag(&obj->mtype.phys_info.thrust),vm_vec_mag(&obj->mtype.phys_info.velocity)));	//do thrust & drag		if ((drag = obj->mtype.phys_info.drag) != 0) {		int count;		vms_vector accel;		fix r,k;		count = sim_time / FT;		r = sim_time % FT;		k = fixdiv(r,FT);		if (obj->mtype.phys_info.flags & PF_USES_THRUST) {			vm_vec_copy_scale(&accel,&obj->mtype.phys_info.thrust,fixdiv(f1_0,obj->mtype.phys_info.mass));			while (count--) {				vm_vec_add2(&obj->mtype.phys_info.velocity,&accel);				vm_vec_scale(&obj->mtype.phys_info.velocity,f1_0-drag);			}			//do linear scale on remaining bit of time			vm_vec_scale_add2(&obj->mtype.phys_info.velocity,&accel,k);			vm_vec_scale(&obj->mtype.phys_info.velocity,f1_0-fixmul(k,drag));		}		else {			fix total_drag=f1_0;			while (count--)				total_drag = fixmul(total_drag,f1_0-drag);			//do linear scale on remaining bit of time			total_drag = fixmul(total_drag,f1_0-fixmul(k,drag));			vm_vec_scale(&obj->mtype.phys_info.velocity,total_drag);		}	}	#ifdef EXTRA_DEBUG	if (obj == debug_obj)		printf("  velocity = %x %x %x/n",XYZ(&obj->mtype.phys_info.velocity));	#endif	do {		try_again = 0;		//Move the object		vm_vec_copy_scale(&frame_vec, &obj->mtype.phys_info.velocity, sim_time);		#ifdef EXTRA_DEBUG		if (obj == debug_obj)			printf("  pass %d, frame_vec = %x %x %x/n",count,XYZ(&frame_vec));		#endif
开发者ID:devint1,项目名称:descent-win,代码行数:67,



注:本文中的vm_vec_scale_add函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ vm_vec_scale_add2函数代码示例
C++ vm_vec_scale函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。