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

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

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

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

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

示例1: opengl_post_lightshafts

void opengl_post_lightshafts(){	opengl_shader_set_current(gr_opengl_maybe_create_shader(SDR_TYPE_POST_PROCESS_LIGHTSHAFTS, 0));	float x, y;	// should we even be here?	if ( !Game_subspace_effect && ls_on && !ls_force_off ) {		int n_lights = light_get_global_count();		for ( int idx = 0; idx<n_lights; idx++ ) {			vec3d light_dir;			vec3d local_light_dir;			light_get_global_dir(&light_dir, idx);			vm_vec_rotate(&local_light_dir, &light_dir, &Eye_matrix);			if ( !stars_sun_has_glare(idx) ) {				continue;			}			float dot;			if ( (dot = vm_vec_dot(&light_dir, &Eye_matrix.vec.fvec)) > 0.7f ) {				x = asinf(vm_vec_dot(&light_dir, &Eye_matrix.vec.rvec)) / PI*1.5f + 0.5f; //cant get the coordinates right but this works for the limited glare fov				y = asinf(vm_vec_dot(&light_dir, &Eye_matrix.vec.uvec)) / PI*1.5f*gr_screen.clip_aspect + 0.5f;				Current_shader->program->Uniforms.setUniform2f("sun_pos", x, y);				Current_shader->program->Uniforms.setUniformi("scene", 0);				Current_shader->program->Uniforms.setUniformi("cockpit", 1);				Current_shader->program->Uniforms.setUniformf("density", ls_density);				Current_shader->program->Uniforms.setUniformf("falloff", ls_falloff);				Current_shader->program->Uniforms.setUniformf("weight", ls_weight);				Current_shader->program->Uniforms.setUniformf("intensity", Sun_spot * ls_intensity);				Current_shader->program->Uniforms.setUniformf("cp_intensity", Sun_spot * ls_cpintensity);				GL_state.Texture.SetActiveUnit(0);				GL_state.Texture.SetTarget(GL_TEXTURE_2D);				GL_state.Texture.Enable(Scene_depth_texture);				GL_state.Texture.SetActiveUnit(1);				GL_state.Texture.SetTarget(GL_TEXTURE_2D);				GL_state.Texture.Enable(Cockpit_depth_texture);				GL_state.Blend(GL_TRUE);				GL_state.SetAlphaBlendMode(ALPHA_BLEND_ADDITIVE);				opengl_draw_textured_quad(-1.0f, -1.0f, 0.0f, 0.0f, 1.0f, 1.0f, Scene_texture_u_scale, Scene_texture_u_scale);				GL_state.Blend(GL_FALSE);				break;			}		}	}	if ( zbuffer_saved ) {		zbuffer_saved = false;		gr_zbuffer_set(GR_ZBUFF_FULL);		glClear(GL_DEPTH_BUFFER_BIT);		gr_zbuffer_set(GR_ZBUFF_NONE);		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, Scene_depth_texture, 0);	}}
开发者ID:rtoijala,项目名称:fs2open.github.com,代码行数:59,


示例2: hud_lock_get_new_lock_pos

// Try and find a new locking pointvoid hud_lock_get_new_lock_pos(object *target_objp, vector *lock_world_pos){	ship			*target_shipp=NULL;	int			lock_in_range=0;	float			best_lock_dot=-1.0f, lock_dot=-1.0f;	ship_subsys	*ss;	vector		subsys_world_pos, vec_to_lock;	if ( target_objp->type == OBJ_SHIP ) {		target_shipp = &Ships[target_objp->instance];	}	// if a large ship, lock to pos closest to center and within range	if ( (target_shipp) && (Ship_info[target_shipp->ship_info_index].flags & (SIF_BIG_SHIP|SIF_HUGE_SHIP)) ) {		// check all the subsystems and the center of the ship				// assume best lock pos is the center of the ship		*lock_world_pos=target_objp->pos;		Player->locking_on_center=1;		Player->locking_subsys=NULL;		Player->locking_subsys_parent=-1;		lock_in_range = hud_lock_world_pos_in_range(lock_world_pos, &vec_to_lock);		vm_vec_normalize(&vec_to_lock);		if ( lock_in_range ) {			best_lock_dot=vm_vec_dot(&Player_obj->orient.vec.fvec, &vec_to_lock);		} 		// take center if reasonable dot		if ( best_lock_dot > 0.95 ) {			return;		}		// iterate through subsystems to see if we can get a better choice		ss = GET_FIRST(&target_shipp->subsys_list);		while ( ss != END_OF_LIST( &target_shipp->subsys_list ) ) {			// get world pos of subsystem			get_subsystem_world_pos(target_objp, ss, &subsys_world_pos);			if ( hud_lock_world_pos_in_range(&subsys_world_pos, &vec_to_lock) ) {				vm_vec_normalize(&vec_to_lock);				lock_dot=vm_vec_dot(&Player_obj->orient.vec.fvec, &vec_to_lock);				if ( lock_dot > best_lock_dot ) {					best_lock_dot=lock_dot;					Player->locking_on_center=0;					Player->locking_subsys=ss;					Player->locking_subsys_parent=Player_ai->target_objnum;					*lock_world_pos=subsys_world_pos;				}			}			ss = GET_NEXT( ss );		}	} else {		// if small ship (or weapon), just go for the center		*lock_world_pos = target_objp->pos;		Player->locking_on_center=1;		Player->locking_subsys=NULL;		Player->locking_subsys_parent=-1;	}}
开发者ID:chief1983,项目名称:Imperial-Alliance,代码行数:60,


示例3: calc_best_gun

//	-----------------------------------------------------------------------------//	Look at control center guns, find best one to fire at *objp.//	Return best gun number (one whose direction dotted with vector to player is largest).//	If best gun has negative dot, return -1, meaning no gun is good.int calc_best_gun(int num_guns, vms_vector *gun_pos, vms_vector *gun_dir, vms_vector *objpos){	int	i;	fix	best_dot;	int	best_gun;	best_dot = -F1_0*2;	best_gun = -1;	for (i=0; i<num_guns; i++) {		fix			dot;		vms_vector	gun_vec;		vm_vec_sub(&gun_vec, objpos, &gun_pos[i]);		vm_vec_normalize_quick(&gun_vec);		dot = vm_vec_dot(&gun_dir[i], &gun_vec);		if (dot > best_dot) {			best_dot = dot;			best_gun = i;		}	}	Assert(best_gun != -1);		// Contact Mike.  This is impossible.  Or maybe you're getting an unnormalized vector somewhere.	if (best_dot < 0)		return -1;	else		return best_gun;}
开发者ID:osgcc,项目名称:descent-mac,代码行数:35,


示例4: vm_vec_normalize

void HudGaugeRadarDradis::plotBlip(blip* b, vec3d *pos, float *alpha){	*pos = b->position;	vm_vec_normalize(pos);	if (ship_is_tagged(b->objp)) {		*alpha = 1.0f;		return;	}	float fade_multi = 1.5f;		if (b->objp->type == OBJ_SHIP) {		if (Ships[b->objp->instance].flags[Ship::Ship_Flags::Stealth]) {			fade_multi *= 2.0f;		}	}		b->time_since_update += flFrametime;	// If the blip has been pinged by the local x-axis sweep, update	if (std::abs(vm_vec_dot(&sweep_normal_x, pos)) < 0.01f) {		b->time_since_update = 0.0f;	}	*alpha = ((sweep_duration - b->time_since_update)/sweep_duration)*fade_multi/2.0f;		if (*alpha < 0.0f) {		*alpha = 0.0f;	}}
开发者ID:fjelliott,项目名称:fs2open.github.com,代码行数:30,


示例5: physics_sim_editor

//	-----------------------------------------------------------------------------------------------------------// Simulate a physics object for this frame.  Used by the editor.  The difference between// this function and physics_sim() is that this one uses a heading change to rotate around// the universal Y axis, rather than the local orientation's Y axis.  Banking is also ignored.void physics_sim_editor(vec3d *position, matrix * orient, physics_info * pi, float sim_time ){	physics_sim_vel(position, pi, sim_time, orient);	physics_sim_rot_editor(orient, pi, sim_time);	pi->speed = vm_vec_mag_quick(&pi->vel);	pi->fspeed = vm_vec_dot(&orient->vec.fvec, &pi->vel);		// instead of vector magnitude -- use only forward vector since we are only interested in forward velocity}
开发者ID:DahBlount,项目名称:Freespace-Open-Swifty,代码行数:11,


示例6: 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,


示例7: 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,


示例8: g3_check_normal_facing

//returns true if a plane is facing the viewer. takes the unrotated surface //normal of the plane, and a point on it.  The normal need not be normalizedbool g3_check_normal_facing(vms_vector *v,vms_vector *norm){	vms_vector tempv;	vm_vec_sub(&tempv,&View_position,v);	return (vm_vec_dot(&tempv,norm) > 0);}
开发者ID:jihnsius,项目名称:d2r,代码行数:10,


示例9: rs_compute_uvs

/** * Given a shield triangle, compute the uv coordinates at its vertices given * the center point of the explosion texture, distance to center of shield and * right and up vectors. * * For small distances (relative to radius), coordinates can be computed using * distance. For larger values, should compute angle. */void rs_compute_uvs(shield_tri *stp, shield_vertex *verts, vec3d *tcp, float radius, vec3d *rightv, vec3d *upv){    int	i;    shield_vertex *sv;    for (i=0; i<3; i++) {        vec3d	v2cp;        sv = &verts[stp->verts[i]];        vm_vec_sub(&v2cp, &sv->pos, tcp);        sv->u = vm_vec_dot(&v2cp, rightv) * Shield_scale + 0.5f;        sv->v = - vm_vec_dot(&v2cp, upv) * Shield_scale + 0.5f;        CLAMP(sv->u, 0.0f, UV_MAX);        CLAMP(sv->v, 0.0f, UV_MAX);    }}
开发者ID:sobczyk,项目名称:fs2open,代码行数:26,


示例10: render_shield_triangle

/** * Render one triangle of a shield hit effect on one ship. * Each frame, the triangle needs to be rotated into global coords. * * @param trip		pointer to triangle in global array * @param orient	orientation of object shield is associated with * @param pos		center point of object * @param r			Red colour * @param g			Green colour * @param b			Blue colour */void render_shield_triangle(gshield_tri *trip, matrix *orient, vec3d *pos, ubyte r, ubyte g, ubyte b){    int		j;    vec3d	pnt;    vertex	*verts[3];    vertex	points[3];    if (trip->trinum == -1)        return;	//	Means this is a quad, must have switched detail_level.    for (j=0; j<3; j++ )	{        // Rotate point into world coordinates        vm_vec_unrotate(&pnt, &trip->verts[j].pos, orient);        vm_vec_add2(&pnt, pos);        // Pnt is now the x,y,z world coordinates of this vert.        // For this example, I am just drawing a sphere at that point.        if (!Cmdline_nohtl) g3_transfer_vertex(&points[j],&pnt);        else g3_rotate_vertex(&points[j], &pnt);        points[j].texture_position.u = trip->verts[j].u;        points[j].texture_position.v = trip->verts[j].v;        Assert((trip->verts[j].u >= 0.0f) && (trip->verts[j].u <= UV_MAX));        Assert((trip->verts[j].v >= 0.0f) && (trip->verts[j].v <= UV_MAX));        verts[j] = &points[j];    }    verts[0]->r = r;    verts[0]->g = g;    verts[0]->b = b;    verts[1]->r = r;    verts[1]->g = g;    verts[1]->b = b;    verts[2]->r = r;    verts[2]->g = g;    verts[2]->b = b;    vec3d	norm;    Poly_count++;    vm_vec_perp(&norm,&verts[0]->world,&verts[1]->world,&verts[2]->world);    int flags=TMAP_FLAG_TEXTURED | TMAP_FLAG_RGB | TMAP_FLAG_GOURAUD;    if (!Cmdline_nohtl) flags |= TMAP_HTL_3D_UNLIT;    if ( vm_vec_dot(&norm,&verts[1]->world ) >= 0.0 )	{        vertex	*vertlist[3];        vertlist[0] = verts[2];        vertlist[1] = verts[1];        vertlist[2] = verts[0];        g3_draw_poly( 3, vertlist, flags);    } else {        g3_draw_poly( 3, verts, flags);    }}
开发者ID:sobczyk,项目名称:fs2open,代码行数:66,


示例11: g3_point_behind_user_plane

/** * Returns TRUE if point is behind user plane */int g3_point_behind_user_plane( const vec3d *pnt ){	if ( G3_user_clip ) {		vec3d tmp;		vm_vec_sub( &tmp, pnt, &G3_user_clip_point );		if ( vm_vec_dot( &tmp, &G3_user_clip_normal ) <= 0.0f )	{			return 1;		}	}	return 0;}
开发者ID:Admiral-MS,项目名称:fs2open.github.com,代码行数:15,


示例12: opengl_shader_set_default_material

void opengl_shader_set_default_material(bool textured, bool alpha, vec4 *clr, float color_scale, uint32_t array_index, const material::clip_plane& clip_plane){	Current_shader->program->Uniforms.setUniformi("baseMap", 0);	if ( textured ) {		Current_shader->program->Uniforms.setUniformi("noTexturing", 0);		Current_shader->program->Uniforms.setUniformi("baseMapIndex", array_index);	} else {		Current_shader->program->Uniforms.setUniformi("noTexturing", 1);		// array_index is probably not valid here		Current_shader->program->Uniforms.setUniformi("baseMapIndex", 0);	}	if ( alpha ) {		Current_shader->program->Uniforms.setUniformi("alphaTexture", 1);	} else {		Current_shader->program->Uniforms.setUniformi("alphaTexture", 0);	}	if ( High_dynamic_range ) {		Current_shader->program->Uniforms.setUniformi("srgb", 1);		Current_shader->program->Uniforms.setUniformf("intensity", color_scale);	} else {		Current_shader->program->Uniforms.setUniformi("srgb", 0);		Current_shader->program->Uniforms.setUniformf("intensity", 1.0f);	}	Current_shader->program->Uniforms.setUniformf("alphaThreshold", GL_alpha_threshold);	if ( clr != NULL ) {		Current_shader->program->Uniforms.setUniform4f("color", *clr);	} else {		Current_shader->program->Uniforms.setUniform4f("color", 1.0f, 1.0f, 1.0f, 1.0f);	}	if (clip_plane.enabled) {		Current_shader->program->Uniforms.setUniformi("clipEnabled", 1);		vec4 clip_equation;		clip_equation.xyzw.x = clip_plane.normal.xyz.x;		clip_equation.xyzw.y = clip_plane.normal.xyz.y;		clip_equation.xyzw.z = clip_plane.normal.xyz.z;		clip_equation.xyzw.w = -vm_vec_dot(&clip_plane.normal, &clip_plane.position);		Current_shader->program->Uniforms.setUniform4f("clipEquation", clip_equation);		Current_shader->program->Uniforms.setUniformMatrix4f("modelMatrix", gr_model_matrix_stack.get_transform());	} else {		Current_shader->program->Uniforms.setUniformi("clipEnabled", 0);	}	Current_shader->program->Uniforms.setUniformMatrix4f("modelViewMatrix", gr_model_view_matrix);	Current_shader->program->Uniforms.setUniformMatrix4f("projMatrix", gr_projection_matrix);}
开发者ID:DahBlount,项目名称:fs2open.github.com,代码行数:53,


示例13: hud_lock_check_if_target_in_lock_cone

// Determine if locking point is in the locking conevoid hud_lock_check_if_target_in_lock_cone(){	float	dot;	vec3d	vec_to_target;	vm_vec_normalized_dir(&vec_to_target, &lock_world_pos, &Player_obj->pos);	dot = vm_vec_dot(&Player_obj->orient.vec.fvec, &vec_to_target);	if ( dot > 0.85) {		Player->target_in_lock_cone = 1;	} else {		Player->target_in_lock_cone = 0;	}}
开发者ID:Echelon9,项目名称:fs2open.github.com,代码行数:15,


示例14: render_low_detail_shield_bitmap

void render_low_detail_shield_bitmap(gshield_tri *trip, matrix *orient, vec3d *pos, ubyte r, ubyte g, ubyte b){    int		j;    vec3d	pnt;    vertex	verts[4];    for (j=0; j<4; j++ )	{        // Rotate point into world coordinates        vm_vec_unrotate(&pnt, &trip->verts[j].pos, orient);        vm_vec_add2(&pnt, pos);        // Pnt is now the x,y,z world coordinates of this vert.        if(!Cmdline_nohtl) g3_transfer_vertex(&verts[j], &pnt);        else g3_rotate_vertex(&verts[j], &pnt);        verts[j].texture_position.u = trip->verts[j].u;        verts[j].texture_position.v = trip->verts[j].v;    }    verts[0].r = r;    verts[0].g = g;    verts[0].b = b;    verts[1].r = r;    verts[1].g = g;    verts[1].b = b;    verts[2].r = r;    verts[2].g = g;    verts[2].b = b;    verts[3].r = r;    verts[3].g = g;    verts[3].b = b;    vec3d	norm;    vm_vec_perp(&norm, &trip->verts[0].pos, &trip->verts[1].pos, &trip->verts[2].pos);    vertex	*vertlist[4];    if ( vm_vec_dot(&norm, &trip->verts[1].pos ) < 0.0 )	{        vertlist[0] = &verts[3];        vertlist[1] = &verts[2];        vertlist[2] = &verts[1];        vertlist[3] = &verts[0];        g3_draw_poly( 4, vertlist, TMAP_FLAG_TEXTURED | TMAP_FLAG_RGB | TMAP_FLAG_GOURAUD | TMAP_HTL_3D_UNLIT);    } else {        vertlist[0] = &verts[0];        vertlist[1] = &verts[1];        vertlist[2] = &verts[2];        vertlist[3] = &verts[3];        g3_draw_poly( 4, vertlist, TMAP_FLAG_TEXTURED | TMAP_FLAG_RGB | TMAP_FLAG_GOURAUD | TMAP_HTL_3D_UNLIT);    }}
开发者ID:sobczyk,项目名称:fs2open,代码行数:48,


示例15: physics_sim

//	-----------------------------------------------------------------------------------------------------------// Simulate a physics object for this framevoid physics_sim(vec3d* position, matrix* orient, physics_info* pi, float sim_time){	// check flag which tells us whether or not to do velocity translation	if (pi->flags & PF_CONST_VEL) {		vm_vec_scale_add2(position, &pi->vel, sim_time);	}	else	{		physics_sim_vel(position, pi, sim_time, orient);		physics_sim_rot(orient, pi, sim_time);		pi->speed = vm_vec_mag(&pi->vel);							//	Note, cannot use quick version, causes cumulative error, increasing speed.		pi->fspeed = vm_vec_dot(&orient->vec.fvec, &pi->vel);		// instead of vector magnitude -- use only forward vector since we are only interested in forward velocity	}}
开发者ID:DahBlount,项目名称:Freespace-Open-Swifty,代码行数:18,


示例16: warpin_batch_draw_face

void warpin_batch_draw_face( int texture, vertex *v1, vertex *v2, vertex *v3 ){	vec3d norm;	vertex vertlist[3];	vm_vec_perp(&norm,&v1->world, &v2->world, &v3->world);	if ( vm_vec_dot(&norm, &v1->world ) >= 0.0 ) {		vertlist[0] = *v3;		vertlist[1] = *v2;		vertlist[2] = *v1;	} else {		vertlist[0] = *v1;		vertlist[1] = *v2;		vertlist[2] = *v3;	}	batch_add_tri(texture, TMAP_FLAG_TEXTURED | TMAP_HTL_3D_UNLIT | TMAP_FLAG_EMISSIVE, vertlist, 1.0f);}
开发者ID:Kobrar,项目名称:fs2open.github.com,代码行数:18,


示例17: do_facing_check

bool do_facing_check(vms_vector *norm,g3s_point **vertlist,vms_vector *p){	if (norm) {		//have normal		Assert(norm->x || norm->y || norm->z);		return g3_check_normal_facing(p,norm);	}	else {	//normal not specified, so must compute		vms_vector tempv;		//get three points (rotated) and compute normal		vm_vec_perp(&tempv,&vertlist[0]->p3_vec,&vertlist[1]->p3_vec,&vertlist[2]->p3_vec);		return (vm_vec_dot(&tempv,&vertlist[1]->p3_vec) < 0);	}}
开发者ID:jihnsius,项目名称:d2r,代码行数:19,


示例18: draw_face

void draw_face( vertex *v1, vertex *v2, vertex *v3 ){	vec3d norm;	vertex *vertlist[3];	vm_vec_perp(&norm,&v1->world, &v2->world, &v3->world);	if ( vm_vec_dot(&norm, &v1->world ) >= 0.0 ) {		vertlist[0] = v3;		vertlist[1] = v2;		vertlist[2] = v1;	} else {		vertlist[0] = v1;		vertlist[1] = v2;		vertlist[2] = v3;	}	g3_draw_poly( 3, vertlist, TMAP_FLAG_TEXTURED | TMAP_HTL_3D_UNLIT );}
开发者ID:achilleas-k,项目名称:fs2open.github.com,代码行数:19,


示例19: get_temp_point

//clips an edge against one plane.vertex *clip_edge(int plane_flag,vertex *on_pnt,vertex *off_pnt, uint flags){	float ratio;	vertex *tmp;	tmp = get_temp_point();	if ( plane_flag & CC_OFF_USER )	{		// Clip with user-defined plane		vector w, ray_direction;		float num,den;		vm_vec_sub(&ray_direction,(vector *)&off_pnt->x,(vector *)&on_pnt->x);					vm_vec_sub(&w,(vector *)&on_pnt->x,&G3_user_clip_point);			den = -vm_vec_dot(&G3_user_clip_normal,&ray_direction);		if ( den == 0.0f ) {	// Ray & plane are parallel, so there is no intersection			Int3();	// Get John			ratio = 1.0f;		} else {			num =  vm_vec_dot(&G3_user_clip_normal,&w);				ratio = num / den;		}		tmp->x = on_pnt->x + (off_pnt->x-on_pnt->x) * ratio;		tmp->y = on_pnt->y + (off_pnt->y-on_pnt->y) * ratio;		tmp->z = on_pnt->z + (off_pnt->z-on_pnt->z) * ratio;	} else {		float a,b,kn,kd;		//compute clipping value k = (xs-zs) / (xs-xe-zs+ze)		//use x or y as appropriate, and negate x/y value as appropriate		if (plane_flag & (CC_OFF_RIGHT | CC_OFF_LEFT)) {			a = on_pnt->x;			b = off_pnt->x;		}		else {			a = on_pnt->y;			b = off_pnt->y;		}		if (plane_flag & (CC_OFF_LEFT | CC_OFF_BOT)) {			a = -a;			b = -b;		}		kn = a - on_pnt->z;						//xs-zs		kd = kn - b + off_pnt->z;				//xs-zs-xe+ze		ratio = kn / kd;		tmp->x = on_pnt->x + (off_pnt->x-on_pnt->x) * ratio;		tmp->y = on_pnt->y + (off_pnt->y-on_pnt->y) * ratio;		if (plane_flag & (CC_OFF_TOP|CC_OFF_BOT))	{			tmp->z = tmp->y;		} else {			tmp->z = tmp->x;		}		if (plane_flag & (CC_OFF_LEFT|CC_OFF_BOT))			tmp->z = -tmp->z;	}	if (flags & TMAP_FLAG_TEXTURED) {		tmp->u = on_pnt->u + (off_pnt->u-on_pnt->u) * ratio;		tmp->v = on_pnt->v + (off_pnt->v-on_pnt->v) * ratio;		tmp->env_u = on_pnt->env_u + (off_pnt->env_u-on_pnt->env_u) * ratio;		tmp->env_v = on_pnt->env_v + (off_pnt->env_v-on_pnt->env_v) * ratio;	}	if (flags & TMAP_FLAG_GOURAUD ) {		if (flags & TMAP_FLAG_RAMP) {			float on_b, off_b;			on_b = i2fl(on_pnt->b);			off_b = i2fl(off_pnt->b);			tmp->b = ubyte(fl2i(on_b + (off_b-on_b) * ratio));		}		if (flags & TMAP_FLAG_RGB) {			float on_r, on_b, on_g, onspec_r, onspec_g, onspec_b;			float off_r, off_b, off_g, offspec_r, offspec_g, offspec_b;			on_r = i2fl(on_pnt->r);			off_r = i2fl(off_pnt->r);			on_g = i2fl(on_pnt->g);			off_g = i2fl(off_pnt->g);			on_b = i2fl(on_pnt->b);//.........这里部分代码省略.........
开发者ID:chief1983,项目名称:Imperial-Alliance,代码行数:101,


示例20: g3_draw_morphing_model

//alternate interpreter for morphing objectbool g3_draw_morphing_model(ubyte *p,grs_bitmap **model_bitmaps,vms_angvec *anim_angles,g3s_lrgb model_light,vms_vector *new_points){	fix *glow_values = NULL;	glow_num = -1;		//glow off by default	while (w(p) != OP_EOF)		switch (w(p)) {			case OP_DEFPOINTS: {				int n = w(p+2);				rotate_point_list(Interp_point_list,new_points,n);				p += n*sizeof(struct vms_vector) + 4;				break;			}			case OP_DEFP_START: {				int n = w(p+2);				int s = w(p+4);				rotate_point_list(&Interp_point_list[s],new_points,n);				p += n*sizeof(struct vms_vector) + 8;				break;			}			case OP_FLATPOLY: {				int nv = w(p+2);				int i,ntris;				gr_setcolor(w(p+28));								for (i=0;i<2;i++)					point_list[i] = Interp_point_list + wp(p+30)[i];				for (ntris=nv-2;ntris;ntris--) {					point_list[2] = Interp_point_list + wp(p+30)[i++];					g3_check_and_draw_poly(3,point_list,NULL,NULL);					point_list[1] = point_list[2];				}				p += 30 + ((nv&~1)+1)*2;									break;			}			case OP_TMAPPOLY: {				int nv = w(p+2);				g3s_uvl *uvl_list;				g3s_lrgb light, *lrgb_list;				g3s_uvl morph_uvls[3];				int i,ntris;				MALLOC(lrgb_list, g3s_lrgb, nv);				//calculate light from surface normal				if (glow_num < 0) //no glow				{					light.r = light.g = light.b = -vm_vec_dot(&View_matrix.fvec,vp(p+16));					light.r = f1_0/4 + (light.r*3)/4;					light.r = fixmul(light.r,model_light.r);					light.g = f1_0/4 + (light.g*3)/4;					light.g = fixmul(light.g,model_light.g);					light.b = f1_0/4 + (light.b*3)/4;					light.b = fixmul(light.b,model_light.b);				}				else //yes glow				{					light.r = light.g = light.b = glow_values[glow_num];					glow_num = -1;				}				//now poke light into l values				uvl_list = (g3s_uvl *) (p+30+((nv&~1)+1)*2);				for (i=0;i<nv;i++)				{					lrgb_list[i].r = light.r;					lrgb_list[i].g = light.g;					lrgb_list[i].b = light.b;				}				for (i=0;i<3;i++)					morph_uvls[i].l = (light.r+light.g+light.b)/3;				for (i=0;i<2;i++) {					point_list[i] = Interp_point_list + wp(p+30)[i];					morph_uvls[i].u = uvl_list[i].u;					morph_uvls[i].v = uvl_list[i].v;				}//.........这里部分代码省略.........
开发者ID:Foran,项目名称:dxx-rebirth,代码行数:101,


示例21: g3_draw_polygon_model

//calls the object interpreter to render an object.  The object renderer//is really a seperate pipeline. returns true if drewbool g3_draw_polygon_model(ubyte *p,grs_bitmap **model_bitmaps,vms_angvec *anim_angles,g3s_lrgb model_light,fix *glow_values){	glow_num = -1;		//glow off by default	while (w(p) != OP_EOF)		switch (w(p)) {			case OP_DEFPOINTS: {				int n = w(p+2);				rotate_point_list(Interp_point_list,vp(p+4),n);				p += n*sizeof(struct vms_vector) + 4;				break;			}			case OP_DEFP_START: {				int n = w(p+2);				int s = w(p+4);				rotate_point_list(&Interp_point_list[s],vp(p+8),n);				p += n*sizeof(struct vms_vector) + 8;				break;			}			case OP_FLATPOLY: {				int nv = w(p+2);				Assert( nv < MAX_POINTS_PER_POLY );				if (g3_check_normal_facing(vp(p+4),vp(p+16)) > 0) {					int i;#ifdef FADE_FLATPOLY					short c;					unsigned char cc;					int l;#endif//					DPH: Now we treat this color as 15bpp//					gr_setcolor(w(p+28));					#ifndef FADE_FLATPOLY					gr_setcolor(gr_find_closest_color_15bpp(w(p + 28)));#else					//l = (32 * model_light) >> 16;					l = f2i(fixmul(i2f(32), (model_light.r+model_light.g+model_light.b)/3));					if (l<0) l = 0;					else if (l>32) l = 32;					cc = gr_find_closest_color_15bpp(w(p+28));					c = gr_fade_table[(l<<8)|cc];					gr_setcolor(c);#endif					for (i=0;i<nv;i++)						point_list[i] = Interp_point_list + wp(p+30)[i];					g3_draw_poly(nv,point_list);				}				p += 30 + ((nv&~1)+1)*2;									break;			}			case OP_TMAPPOLY: {				int nv = w(p+2);				g3s_uvl *uvl_list;				Assert( nv < MAX_POINTS_PER_POLY );				if (g3_check_normal_facing(vp(p+4),vp(p+16)) > 0) {					int i;					g3s_lrgb light, *lrgb_list;					MALLOC(lrgb_list, g3s_lrgb, nv);					//calculate light from surface normal					if (glow_num < 0) //no glow					{						light.r = light.g = light.b = -vm_vec_dot(&View_matrix.fvec,vp(p+16));						light.r = f1_0/4 + (light.r*3)/4;						light.r = fixmul(light.r,model_light.r);						light.g = f1_0/4 + (light.g*3)/4;						light.g = fixmul(light.g,model_light.g);						light.b = f1_0/4 + (light.b*3)/4;						light.b = fixmul(light.b,model_light.b);					}					else //yes glow					{						light.r = light.g = light.b = glow_values[glow_num];						glow_num = -1;					}					//now poke light into l values					uvl_list = (g3s_uvl *) (p+30+((nv&~1)+1)*2);					for (i=0;i<nv;i++)					{//.........这里部分代码省略.........
开发者ID:Foran,项目名称:dxx-rebirth,代码行数:101,


示例22: obj_collide_pair

//.........这里部分代码省略.........			collision_info->next_check_time = timestamp(0);		}	} else {		collision_info->a = A;		collision_info->b = B;		collision_info->signature_a = A->signature;		collision_info->signature_b = B->signature;		collision_info->initialized = true;		collision_info->next_check_time = timestamp(0);	}	if ( valid &&  A->type != OBJ_BEAM ) {		// if this signature is valid, make the necessary checks to see if we need to collide check		if ( collision_info->next_check_time == -1 ) {			return;		} else {			if ( !timestamp_elapsed(collision_info->next_check_time) ) {				return;			}		}	} else {		//if ( A->type == OBJ_BEAM ) {			//if(beam_collide_early_out(A, B)){				//collision_info->next_check_time = -1;				//return;			//}		//}		// only check debris:weapon collisions for player		if (check_collision == collide_debris_weapon) {			// weapon is B			if ( !(Weapon_info[Weapons[B->instance].weapon_info_index].wi_flags & WIF_TURNS) ) {				// check for dumbfire weapon				// check if debris is behind laser				float vdot;				if (Weapon_info[Weapons[B->instance].weapon_info_index].subtype == WP_LASER) {					vec3d velocity_rel_weapon;					vm_vec_sub(&velocity_rel_weapon, &B->phys_info.vel, &A->phys_info.vel);					vdot = -vm_vec_dot(&velocity_rel_weapon, &B->orient.vec.fvec);				} else {					vdot = vm_vec_dot( &A->phys_info.vel, &B->phys_info.vel);				}				if ( vdot <= 0.0f )	{					// They're heading in opposite directions...					// check their positions					vec3d weapon2other;					vm_vec_sub( &weapon2other, &A->pos, &B->pos );					float pdot = vm_vec_dot( &B->orient.vec.fvec, &weapon2other );					if ( pdot <= -A->radius )	{						// The other object is behind the weapon by more than						// its radius, so it will never hit...						collision_info->next_check_time = -1;						return;					}				}				// check dist vs. dist moved during weapon lifetime				vec3d delta_v;				vm_vec_sub(&delta_v, &B->phys_info.vel, &A->phys_info.vel);				if (vm_vec_dist_squared(&A->pos, &B->pos) > (vm_vec_mag_squared(&delta_v)*Weapons[B->instance].lifeleft*Weapons[B->instance].lifeleft)) {					collision_info->next_check_time = -1;					return;				}				// for nonplayer ships, only create collision pair if close enough				if ( (B->parent >= 0) && !(Objects[B->parent].flags & OF_PLAYER_SHIP) && (vm_vec_dist(&B->pos, &A->pos) < (4.0f*A->radius + 200.0f)) ) {					collision_info->next_check_time = -1;					return;				}			}		}		// don't check same team laser:ship collisions on small ships if not player		if (check_collision == collide_ship_weapon) {			// weapon is B			if ( (B->parent >= 0)				&& !(Objects[B->parent].flags & OF_PLAYER_SHIP)				&& (Ships[Objects[B->parent].instance].team == Ships[A->instance].team) 				&& (Ship_info[Ships[A->instance].ship_info_index].flags & SIF_SMALL_SHIP) 				&& (Weapon_info[Weapons[B->instance].weapon_info_index].subtype == WP_LASER) ) {				collision_info->next_check_time = -1;				return;			}		}	}	obj_pair new_pair;		new_pair.a = A;	new_pair.b = B;	new_pair.check_collision = check_collision;	new_pair.next_check_time = collision_info->next_check_time;	if ( check_collision(&new_pair) ) {		// don't have to check ever again		collision_info->next_check_time = -1;	} else {		collision_info->next_check_time = new_pair.next_check_time;	}}
开发者ID:achilleas-k,项目名称:fs2open.github.com,代码行数:101,


示例23: do_object_physics

void do_object_physics( object * obj ){	vms_angvec rotang;	vms_vector frame_vec;	//movement in this frame	vms_vector new_pos,ipos;		//position after this frame	int iseg;	int hit;	vms_matrix rotmat,new_pm;	int count=0;	short joy_x,joy_y,btns;	int joyx_moved,joyy_moved;	fix speed;	vms_vector *desired_upvec;	fixang delta_ang,roll_ang;	vms_vector forvec = {0,0,f1_0};	vms_matrix temp_matrix;	//check keys	rotang.pitch = ROT_SPEED * (key_down_time(KEY_UP) - key_down_time(KEY_DOWN));	rotang.head  = ROT_SPEED * (key_down_time(KEY_RIGHT) - key_down_time(KEY_LEFT));	rotang.bank = 0;	//check for joystick movement	joy_get_pos(&joy_x,&joy_y);	btns=joy_get_btns();	joyx_moved = (abs(joy_x - _old_joy_x)>JOY_NULL);	joyy_moved = (abs(joy_y - _old_joy_y)>JOY_NULL);	if (abs(joy_x) < JOY_NULL) joy_x = 0;	if (abs(joy_y) < JOY_NULL) joy_y = 0;	if (!rotang.pitch) rotang.pitch = fixmul(-joy_y * 128,FrameTime);	if (!rotang.head) rotang.head = fixmul(joy_x * 128,FrameTime);		if (joyx_moved) _old_joy_x = joy_x;	if (joyy_moved) _old_joy_y = joy_y;	speed = ((btns&2) || keyd_pressed[KEY_A])?SLOW_SPEED*3:(keyd_pressed[KEY_Z]?SLOW_SPEED/2:SLOW_SPEED);	//now build matrices, do rotations, etc., etc.	vm_angles_2_matrix(&rotmat,&rotang);	vm_matrix_x_matrix(&new_pm,&obj->orient,&rotmat);	obj->orient = new_pm;	//move player	vm_vec_copy_scale(&obj->velocity,&obj->orient.fvec,speed);	vm_vec_copy_scale(&frame_vec,&obj->velocity,FrameTime);	do {		fix wall_part;		vms_vector tvec;		count++;		vm_vec_add(&new_pos,&obj->pos,&frame_vec);		hit = find_vector_intersection(&ipos,&iseg,&obj->pos,obj->seg_id,&new_pos,obj->size,-1);		obj->seg_id = iseg;		obj->pos = ipos;		//-FIXJOHN-if (hit==HIT_OBJECT) ExplodeObject(hit_objnum);		if (hit==HIT_WALL) {			vm_vec_sub(&frame_vec,&new_pos,&obj->pos);	//part through wall			wall_part = vm_vec_dot(wall_norm,&frame_vec);			vm_vec_copy_scale(&tvec,wall_norm,wall_part);			if ((wall_part == 0) || (vm_vec_mag(&tvec) < 5)) Int3();			vm_vec_sub2(&frame_vec,&tvec);		}	} while (hit == HIT_WALL);	Assert(check_point_in_seg(&obj->pos,obj->seg_id,0).centermask==0);	//now bank player according to segment orientation	desired_upvec = &Segments[obj->seg_id].sides[3].faces[0].normal;	if (labs(vm_vec_dot(desired_upvec,&obj->orient.fvec)) < f1_0/2) {		vm_vector_2_matrix(&temp_matrix,&obj->orient.fvec,desired_upvec,NULL);		delta_ang = vm_vec_delta_ang(&obj->orient.uvec,&temp_matrix.uvec,&obj->orient.fvec);		if (rotang.head) delta_ang += (rotang.head<0)?TURNROLL_ANG:-TURNROLL_ANG;		if (abs(delta_ang) > DAMP_ANG) {			roll_ang = fixmul(FrameTime,ROLL_RATE);			if (abs(delta_ang) < roll_ang) roll_ang = delta_ang;			else if (delta_ang<0) roll_ang = -roll_ang;			vm_vec_ang_2_matrix(&rotmat,&forvec,roll_ang);//.........这里部分代码省略.........
开发者ID:NonCreature0714,项目名称:descent,代码行数:101,


示例24: do_endlevel_flythrough

do_endlevel_flythrough(int n){	object *obj;	segment *pseg;	int old_player_seg;	flydata = &fly_objects[n];	obj = flydata->obj;		old_player_seg = obj->segnum;	//move the player for this frame	if (!flydata->first_time) {		vm_vec_scale_add2(&obj->pos,&flydata->step,FrameTime);		angvec_add2_scale(&flydata->angles,&flydata->angstep,FrameTime);		vm_angles_2_matrix(&obj->orient,&flydata->angles);	}	//check new player seg	update_object_seg(obj);	pseg = &Segments[obj->segnum];	if (flydata->first_time || obj->segnum != old_player_seg) {		//moved into new seg		vms_vector curcenter,nextcenter;		fix step_size,seg_time;		short entry_side,exit_side;	//what sides we entry and leave through		vms_vector dest_point;		//where we are heading (center of exit_side)		vms_angvec dest_angles;		//where we want to be pointing		vms_matrix dest_orient;		int up_side;		//find new exit side		if (!flydata->first_time) {			entry_side = matt_find_connect_side(obj->segnum,old_player_seg);			exit_side = Side_opposite[entry_side];		}		if (flydata->first_time || entry_side==-1 || pseg->children[exit_side]==-1)			exit_side = find_exit_side(obj);		{										//find closest side to align to			fix d,largest_d=-f1_0;			int i;			for (i=0;i<6;i++) {				#ifdef COMPACT_SEGS				vms_vector v1;				get_side_normal(pseg, i, 0, &v1 );				d = vm_vec_dot(&v1,&flydata->obj->orient.uvec);				#else				d = vm_vec_dot(&pseg->sides[i].normals[0],&flydata->obj->orient.uvec);				#endif				if (d > largest_d) {largest_d = d; up_side=i;}			}		}		//update target point & angles		compute_center_point_on_side(&dest_point,pseg,exit_side);		//update target point and movement points		//offset object sideways		if (flydata->offset_frac) {			int s0=-1,s1,i;			vms_vector s0p,s1p;			fix dist;			for (i=0;i<6;i++)				if (i!=entry_side && i!=exit_side && i!=up_side && i!=Side_opposite[up_side])					if (s0==-1)						s0 = i;					else						s1 = i;			compute_center_point_on_side(&s0p,pseg,s0);			compute_center_point_on_side(&s1p,pseg,s1);			dist = fixmul(vm_vec_dist(&s0p,&s1p),flydata->offset_frac);			if (dist-flydata->offset_dist > MAX_SLIDE_PER_SEGMENT)				dist = flydata->offset_dist + MAX_SLIDE_PER_SEGMENT;			flydata->offset_dist = dist;			vm_vec_scale_add2(&dest_point,&obj->orient.rvec,dist);		}		vm_vec_sub(&flydata->step,&dest_point,&obj->pos);		step_size = vm_vec_normalize_quick(&flydata->step);		vm_vec_scale(&flydata->step,flydata->speed);		compute_segment_center(&curcenter,pseg);//.........这里部分代码省略.........
开发者ID:NonCreature0714,项目名称:descent,代码行数:101,


示例25: 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,


示例26: weapon_will_never_hit

// Returns TRUE if the weapon will never hit the other object.// If it can it predicts how long until these two objects need// to be checked and fills the time in in current_pair.int weapon_will_never_hit( object *obj_weapon, object *other, obj_pair * current_pair ){	Assert( obj_weapon->type == OBJ_WEAPON );	weapon *wp = &Weapons[obj_weapon->instance];	weapon_info *wip = &Weapon_info[wp->weapon_info_index];//	mprintf(( "Frame: %d,  Weapon=%d, Other=%d, pair=$%08x/n", G3_frame_count, OBJ_INDEX(weapon), OBJ_INDEX(other), current_pair ));		// Do some checks for weapons that don't turn	if ( !(wip->wi_flags & WIF_TURNS) )	{		// This first check is to see if a weapon is behind an object, and they		// are heading in opposite directions.   If so, we don't need to ever check			// them again.   This is only valid for weapons that don't turn. 		float vdot;		if (wip->subtype == WP_LASER) {			vec3d velocity_rel_weapon;			vm_vec_sub(&velocity_rel_weapon, &obj_weapon->phys_info.vel, &other->phys_info.vel);			vdot = -vm_vec_dot(&velocity_rel_weapon, &obj_weapon->orient.vec.fvec);		} else {			vdot = vm_vec_dot( &other->phys_info.vel, &obj_weapon->phys_info.vel);		}		if ( vdot <= 0.0f )	{			// They're heading in opposite directions...			// check their positions			vec3d weapon2other;			vm_vec_sub( &weapon2other, &other->pos, &obj_weapon->pos );			float pdot = vm_vec_dot( &obj_weapon->orient.vec.fvec, &weapon2other );			if ( pdot <= -other->radius )	{				// The other object is behind the weapon by more than				// its radius, so it will never hit...				return 1;			}		}		// FUTURE ENHANCEMENT IDEAS 		// Given a laser does it hit a slow or not moving object		// in its life or the next n seconds?  We'd actually need to check the 		// model for this.					}	// This check doesn't care about orient, only looks at the maximum speed	// of the two objects, so it knows that in the next n seconds, they can't	// go further than some distance, so don't bother checking collisions for 	// that time.   This is very rough, but is so general that it works for	// everything and immidiately gets rid of a lot of cases.		if ( current_pair )	{		// Find the time it will take before these get within each others distances.		// tmp->next_check_time = timestamp(500);		//vector	max_vel;			//maximum foward velocity in x,y,z		float max_vel_weapon, max_vel_other;		//SUSHI: Fix bug where additive weapon velocity screws up collisions		//Assumes that weapons which don't home don't change speed, which is currently the case.		if (!(wip->wi_flags & WIF_TURNS))			max_vel_weapon = obj_weapon->phys_info.speed;		else if (wp->lssm_stage==5)			max_vel_weapon = wip->lssm_stage5_vel;		else			max_vel_weapon = wp->weapon_max_vel;		max_vel_other = other->phys_info.max_vel.xyz.z;		if (max_vel_other < 10.0f) {			if ( vm_vec_mag_squared( &other->phys_info.vel ) > 100 ) {				// bump up velocity from collision				max_vel_other = vm_vec_mag( &other->phys_info.vel ) + 10.0f;			} else {				max_vel_other = 10.0f;		// object may move from collision			}		}		// check weapon that does not turn against sphere expanding at ship maxvel		// compare (weeapon) ray with expanding sphere (ship) to find earliest possible collision time		// look for two time solutions to Xw = Xs, where Xw = Xw0 + Vwt*t  Xs = Xs + Vs*(t+dt), where Vs*dt = radius of ship 		// Since direction of Vs is unknown, solve for (Vs*t) and find norm of both sides		if ( !(wip->wi_flags & WIF_TURNS) ) {			vec3d delta_x, laser_vel;			float a,b,c, delta_x_dot_vl, delta_t;			float root1, root2, root, earliest_time;			if (max_vel_weapon == max_vel_other) {				// this will give us NAN using the below formula, so check every frame				current_pair->next_check_time = timestamp(0);				return 0;			}			vm_vec_sub( &delta_x, &obj_weapon->pos, &other->pos );			laser_vel = obj_weapon->phys_info.vel;			// vm_vec_copy_scale( &laser_vel, &weapon->orient.vec.fvec, max_vel_weapon );//.........这里部分代码省略.........
开发者ID:achilleas-k,项目名称:fs2open.github.com,代码行数:101,


示例27: obj_add_pair

//.........这里部分代码省略.........	}	// Swap them if needed	if ( swapped )	{		object *tmp = A;		A = B;		B = tmp;	}	// if there are any more obj_pair checks	// we should then add function int maybe_not_add_obj_pair()	// MWA -- 4/1/98 -- I'd do it, but I don't want to bust anything, so I'm doing my stuff here instead :-)	//if ( MULTIPLAYER_CLIENT && !(Netgame.debug_flags & NETD_FLAG_CLIENT_NODAMAGE)){		// multiplayer clients will only do ship/ship collisions, and their own ship to boot	//	if ( check_collision != collide_ship_ship ){	//		return;	//	}	//	if ( (A != Player_obj) && (B != Player_obj) ){	//		return;	//	}	//}		// only check debris:weapon collisions for player	if (check_collision == collide_debris_weapon) {		// weapon is B		if ( !(Weapon_info[Weapons[B->instance].weapon_info_index].wi_flags & WIF_TURNS) ) {		// check for dumbfire weapon			// check if debris is behind laser			float vdot;			if (Weapon_info[Weapons[B->instance].weapon_info_index].subtype == WP_LASER) {				vec3d velocity_rel_weapon;				vm_vec_sub(&velocity_rel_weapon, &B->phys_info.vel, &A->phys_info.vel);				vdot = -vm_vec_dot(&velocity_rel_weapon, &B->orient.vec.fvec);			} else {				vdot = vm_vec_dot( &A->phys_info.vel, &B->phys_info.vel);			}			if ( vdot <= 0.0f )	{				// They're heading in opposite directions...				// check their positions				vec3d weapon2other;				vm_vec_sub( &weapon2other, &A->pos, &B->pos );				float pdot = vm_vec_dot( &B->orient.vec.fvec, &weapon2other );				if ( pdot <= -A->radius )	{					// The other object is behind the weapon by more than					// its radius, so it will never hit...					return;				}			}			// check dist vs. dist moved during weapon lifetime			vec3d delta_v;			vm_vec_sub(&delta_v, &B->phys_info.vel, &A->phys_info.vel);			if (vm_vec_dist_squared(&A->pos, &B->pos) > (vm_vec_mag_squared(&delta_v)*Weapons[B->instance].lifeleft*Weapons[B->instance].lifeleft)) {				return;			}			// for nonplayer ships, only create collision pair if close enough			if ( (B->parent >= 0) && !(Objects[B->parent].flags & OF_PLAYER_SHIP) && (vm_vec_dist(&B->pos, &A->pos) < (4.0f*A->radius + 200.0f)) )				return;		}	}	// don't check same team laser:ship collisions on small ships if not player	if (check_collision == collide_ship_weapon) {		// weapon is B
开发者ID:achilleas-k,项目名称:fs2open.github.com,代码行数:67,



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


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