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

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

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

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

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

示例1: rotate_object

int rotate_object(short objnum, int p, int b, int h){	object *obj = &Objects[objnum];	vms_angvec ang;	vms_matrix rotmat,tempm;	//	vm_extract_angles_matrix( &ang,&obj->orient);//	ang.p += p;//	ang.b += b;//	ang.h += h;	ang.p = p;	ang.b = b;	ang.h = h;	vm_angles_2_matrix(&rotmat, &ang);	vm_matrix_x_matrix(&tempm, &obj->orient, &rotmat);	obj->orient = tempm;//   vm_angles_2_matrix(&obj->orient, &ang);	Update_flags |= UF_WORLD_CHANGED;	return 1;}
开发者ID:devint1,项目名称:descent-win,代码行数:26,


示例2: draw_model_picture

//draws the given model in the current canvas.  The distance is set to//more-or-less fill the canvas.  Note that this routine actually renders//into an off-screen canvas that it creates, then copies to the current//canvas.void draw_model_picture(int mn,vms_angvec *orient_angles){	vms_vector	temp_pos=ZERO_VECTOR;	vms_matrix	temp_orient = IDENTITY_MATRIX;	grs_canvas	*save_canv = grd_curcanv,*temp_canv;	Assert(mn>=0 && mn<N_polygon_models);	temp_canv = gr_create_canvas(save_canv->cv_bitmap.bm_w,save_canv->cv_bitmap.bm_h);	gr_set_current_canvas(temp_canv);	gr_clear_canvas( BM_XRGB(0,0,0) );	g3_start_frame();	g3_set_view_matrix(&temp_pos,&temp_orient,0x9000);	if (Polygon_models[mn].rad != 0)		temp_pos.z = fixmuldiv(DEFAULT_VIEW_DIST,Polygon_models[mn].rad,BASE_MODEL_SIZE);	else		temp_pos.z = DEFAULT_VIEW_DIST;	vm_angles_2_matrix(&temp_orient, orient_angles);	PA_DFX(save_light = Lighting_on);	PA_DFX(Lighting_on = 0);	draw_polygon_model(&temp_pos,&temp_orient,NULL,mn,0,f1_0,NULL,NULL);	PA_DFX (Lighting_on = save_light);	gr_set_current_canvas(save_canv);	gr_bitmap(0,0,&temp_canv->cv_bitmap);	gr_free_canvas(temp_canv);}
开发者ID:gameplayer22,项目名称:d2x-1,代码行数:37,


示例3: g3_set_view_angles

/** * Set view from x,y,z & p,b,h, zoom.  Must call one of g3_set_view_*() */void g3_set_view_angles(const vec3d *view_pos, const angles *view_orient, float zoom){	matrix tmp;	Assert( G3_count == 1 );	vm_angles_2_matrix(&tmp,view_orient);	g3_set_view_matrix(view_pos,&tmp,zoom);}
开发者ID:Admiral-MS,项目名称:fs2open.github.com,代码行数:12,


示例4: g3_set_view_angles

//set view from x,y,z & p,b,h, zoom.  Must call one of g3_set_view_*() void g3_set_view_angles(const vms_vector *view_pos,const vms_angvec *view_orient,fix zoom){	View_zoom = zoom;	View_position = *view_pos;	vm_angles_2_matrix(&View_matrix,view_orient);	scale_matrix();}
开发者ID:Foran,项目名称:dxx-rebirth,代码行数:10,


示例5: gr_start_angles_instance_matrix

void gr_start_angles_instance_matrix(const vec3d *pos, const angles *rotation){	Assert(htl_view_matrix_set);	matrix m;	vm_angles_2_matrix(&m, rotation);	gr_start_instance_matrix(pos, &m);}
开发者ID:mirakus-0f-tyr,项目名称:fs2open.github.com,代码行数:9,


示例6: do_object_flythrough

void do_object_flythrough(object * obj )		//set true if init{	if ( obj->fly_info.ft_mode == FP_FIRST_TIME )	{	 	obj->fly_info.ft_mode = FP_FORWARD;		objfly_move_to_new_segment( obj, obj->segnum, 1 );	} else {		//move the object for this frame		angvec_add2_scale(&obj->phys_info.rotvel,&obj->fly_info.angle_step,FrameTime);		vm_angles_2_matrix(&obj->orient,&obj->phys_info.rotvel);	}}
开发者ID:NonCreature0714,项目名称:descent,代码行数:11,


示例7: medlisp_rotate_segment

int medlisp_rotate_segment(void){	vms_matrix	rotmat;	Seg_orientation.p = func_get_param(0);	Seg_orientation.b = func_get_param(1);	Seg_orientation.h = func_get_param(2);	med_rotate_segment(Cursegp,vm_angles_2_matrix(&rotmat,&Seg_orientation));	Update_flags |= UF_WORLD_CHANGED | UF_VIEWPOINT_MOVED;	mine_changed = 1;	return 1;}
开发者ID:devint1,项目名称:descent-win,代码行数:12,


示例8: g3_start_instance_angles

//instance at specified point with specified orientation//if angles==NULL, don't modify matrix.  This will be like doing an offsetvoid g3_start_instance_angles(vms_vector *pos, vms_angvec *angles) {	vms_matrix tm;	if (angles == NULL) {		g3_start_instance_matrix(pos, NULL);		return;	}	vm_angles_2_matrix(&tm, angles);	g3_start_instance_matrix(pos, &tm);}
开发者ID:devint1,项目名称:descent-win,代码行数:15,


示例9: physics_sim_rot_editor

void physics_sim_rot_editor(matrix * orient, physics_info * pi, float sim_time){	angles	tangles;	vec3d	new_vel;	matrix	tmp;	angles	t1, t2;	apply_physics( pi->rotdamp, pi->desired_rotvel.xyz.x, pi->rotvel.xyz.x, sim_time,								 &new_vel.xyz.x, NULL );	apply_physics( pi->rotdamp, pi->desired_rotvel.xyz.y, pi->rotvel.xyz.y, sim_time,								 &new_vel.xyz.y, NULL );	apply_physics( pi->rotdamp, pi->desired_rotvel.xyz.z, pi->rotvel.xyz.z, sim_time,								 &new_vel.xyz.z, NULL );	pi->rotvel = new_vel;	tangles.p = pi->rotvel.xyz.x*sim_time;	tangles.h = pi->rotvel.xyz.y*sim_time;	tangles.b = pi->rotvel.xyz.z*sim_time;	t1 = t2 = tangles;	t1.h = 0.0f;  t1.b = 0.0f;	t2.p = 0.0f; t2.b = 0.0f;	// put in p & b like normal	vm_angles_2_matrix(&pi->last_rotmat, &t1 );	vm_matrix_x_matrix( &tmp, orient, &pi->last_rotmat );	// Put in heading separately	vm_angles_2_matrix(&pi->last_rotmat, &t2 );	vm_matrix_x_matrix( orient, &pi->last_rotmat, &tmp );	vm_orthogonalize_matrix(orient);}
开发者ID:DahBlount,项目名称:Freespace-Open-Swifty,代码行数:37,


示例10: medlisp_scale_segment

int medlisp_scale_segment(void){	vms_matrix	rotmat;	vms_vector	scale;	scale.x = fl2f((float) func_get_param(0));	scale.y = fl2f((float) func_get_param(1));	scale.z = fl2f((float) func_get_param(2));	med_create_new_segment(&scale);	med_rotate_segment(Cursegp,vm_angles_2_matrix(&rotmat,&Seg_orientation));	Update_flags |= UF_WORLD_CHANGED;	mine_changed = 1;	return 1;}
开发者ID:devint1,项目名称:descent-win,代码行数:15,


示例11: calc_gun_point

//given an object and a gun number, return position in 3-space of gun//fills in gun_pointvoid calc_gun_point(vms_vector *gun_point,object *obj,int gun_num){	polymodel *pm;	robot_info *r;	vms_vector pnt;	vms_matrix m;	int mn;				//submodel number	Assert(obj->render_type==RT_POLYOBJ || obj->render_type==RT_MORPH);	Assert(obj->id < N_robot_types);	r = &Robot_info[obj->id];	pm =&Polygon_models[r->model_num];	if (gun_num >= r->n_guns)	{		mprintf((1, "Bashing gun num %d to 0./n", gun_num));		//Int3();		gun_num = 0;	}//	Assert(gun_num < r->n_guns);	pnt = r->gun_points[gun_num];	mn = r->gun_submodels[gun_num];	//instance up the tree for this gun	while (mn != 0) {		vms_vector tpnt;		vm_angles_2_matrix(&m,&obj->rtype.pobj_info.anim_angles[mn]);		vm_transpose_matrix(&m);		vm_vec_rotate(&tpnt,&pnt,&m);		vm_vec_add(&pnt,&tpnt,&pm->submodel_offsets[mn]);		mn = pm->submodel_parents[mn];	}	//now instance for the entire object	vm_copy_transpose_matrix(&m,&obj->orient);	vm_vec_rotate(gun_point,&pnt,&m);	vm_vec_add2(gun_point,&obj->pos);}
开发者ID:gameplayer22,项目名称:d2x-1,代码行数:48,


示例12: g3_start_instance_angles

//instance at specified point with specified orientation//if angles==NULL, don't modify matrix.  This will be like doing an offsetvoid g3_start_instance_angles(vector *pos,angles *orient){	matrix tm;	 Assert( G3_count == 1 );	if (orient==NULL) {		g3_start_instance_matrix(pos,NULL);		return;	}	vm_angles_2_matrix(&tm,orient);	g3_start_instance_matrix(pos,&tm, false);	if(!Cmdline_nohtl)gr_start_angles_instance_matrix(pos, orient);}
开发者ID:chief1983,项目名称:Imperial-Alliance,代码行数:20,


示例13: endlevel_render_mine

endlevel_render_mine(fix eye_offset){	int start_seg_num;	Viewer_eye = Viewer->pos;	if (Viewer->type == OBJ_PLAYER )		vm_vec_scale_add2(&Viewer_eye,&Viewer->orient.fvec,(Viewer->size*3)/4);	if (eye_offset)		vm_vec_scale_add2(&Viewer_eye,&Viewer->orient.rvec,eye_offset);	#ifdef EDITOR	if (Function_mode==FMODE_EDITOR)		Viewer_eye = Viewer->pos;	#endif	if (Endlevel_sequence >= EL_OUTSIDE) {		start_seg_num = exit_segnum;	}	else {		start_seg_num = find_point_seg(&Viewer_eye,Viewer->segnum);		if (start_seg_num==-1)			start_seg_num = Viewer->segnum;	}	if (Endlevel_sequence == EL_LOOKBACK) {		vms_matrix headm,viewm;		vms_angvec angles = {0,0,0x7fff};		vm_angles_2_matrix(&headm,&angles);		vm_matrix_x_matrix(&viewm,&Viewer->orient,&headm);		g3_set_view_matrix(&Viewer_eye,&viewm,Render_zoom);	}	else		g3_set_view_matrix(&Viewer_eye,&Viewer->orient,Render_zoom);	render_mine(start_seg_num,eye_offset);}
开发者ID:NonCreature0714,项目名称:descent,代码行数:41,


示例14: record_demo_frame

void record_demo_frame(void){	vms_angvec	pbh;//mprintf(0, "Record start...");mprintf(0, "Curtime = %6i, Last time = %6i/n", Player_stats.time_total, Demo_last_time);  if (GameTime - Demo_last_time >= 65536) {	Demo_last_time = GameTime;	if (Demo_record_index < MAX_DEMO_RECS) {		demorec *demo_ptr = &Demo_records[Demo_record_index];		vms_matrix tempmat;		demo_ptr->time = GameTime - Demo_start_time;		demo_ptr->x = Player->pos.x;		demo_ptr->y = Player->pos.y;		demo_ptr->z = Player->pos.z;		vm_extract_angles_matrix(&pbh, &Player->orient);		vm_angles_2_matrix(&tempmat, &pbh);		matrix_compare(&tempmat, &Player->orient);		demo_ptr->p = pbh.p;		demo_ptr->b = pbh.b;		demo_ptr->h = pbh.h;		demo_ptr->segnum = Player->segnum;		Demo_record_index++;		Num_demo_recs = Demo_record_index;//		if (firing)//			demo_ptr->specials = 1;//		else//			demo_ptr->specials = 0;	}  }//mprintf(0, "Record end/n");}
开发者ID:NonCreature0714,项目名称:descent,代码行数:40,


示例15: model_collide_preprocess_subobj

void model_collide_preprocess_subobj(vec3d *pos, matrix *orient, polymodel *pm,  polymodel_instance *pmi, int subobj_num){	submodel_instance *smi = &pmi->submodel[subobj_num];	smi->mc_base = *pos;	smi->mc_orient = *orient;	int i = pm->submodel[subobj_num].first_child;	while ( i >= 0 ) {		angles angs = pmi->submodel[i].angs;		bsp_info * csm = &pm->submodel[i];		matrix tm = IDENTITY_MATRIX;		vm_vec_unrotate(pos, &csm->offset, &smi->mc_orient );		vm_vec_add2(pos, &smi->mc_base);		if( vm_matrix_same(&tm, &csm->orientation)) {			// if submodel orientation matrix is identity matrix then don't bother with matrix ops			vm_angles_2_matrix(&tm, &angs);		} else {			matrix rotation_matrix = csm->orientation;			vm_rotate_matrix_by_angles(&rotation_matrix, &angs);			matrix inv_orientation;			vm_copy_transpose(&inv_orientation, &csm->orientation);			vm_matrix_x_matrix(&tm, &rotation_matrix, &inv_orientation);		}		vm_matrix_x_matrix(orient, &smi->mc_orient, &tm);		model_collide_preprocess_subobj(pos, orient, pm, pmi, i);		i = csm->next_sibling;	}}
开发者ID:Echelon9,项目名称:fs2open.github.com,代码行数:38,


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


示例17: techroom_ships_render

void techroom_ships_render(float frametime){	// render all the common stuff	tech_common_render();		if(Cur_entry_index == -1)		return;	// now render the trackball ship, which is unique to the ships tab	float rev_rate = REVOLUTION_RATE;	angles rot_angles, view_angles;	int z, i, j;	ship_info *sip = &Ship_info[Cur_entry_index];	model_render_params render_info;	if (sip->uses_team_colors) {		render_info.set_team_color(sip->default_team_name, "none", 0, 0);	}	// get correct revolution rate	z = sip->flags;	if (z & SIF_BIG_SHIP) {		rev_rate *= 1.7f;	}	if (z & SIF_HUGE_SHIP) {		rev_rate *= 3.0f;	}	// rotate the ship as much as required for this frame	Techroom_ship_rot += PI2 * frametime / rev_rate;	while (Techroom_ship_rot > PI2){		Techroom_ship_rot -= PI2;		}	//	reorient ship	if (Trackball_active) {		int dx, dy;		matrix mat1, mat2;		if (Trackball_active) {			mouse_get_delta(&dx, &dy);			if (dx || dy) {				vm_trackball(-dx, -dy, &mat1);				vm_matrix_x_matrix(&mat2, &mat1, &Techroom_ship_orient);				Techroom_ship_orient = mat2;			}		}	} else {		// setup stuff needed to render the ship		view_angles.p = -0.6f;		view_angles.b = 0.0f;		view_angles.h = 0.0f;		vm_angles_2_matrix(&Techroom_ship_orient, &view_angles);		rot_angles.p = 0.0f;		rot_angles.b = 0.0f;		rot_angles.h = Techroom_ship_rot;		vm_rotate_matrix_by_angles(&Techroom_ship_orient, &rot_angles);	}	gr_set_clip(Tech_ship_display_coords[gr_screen.res][SHIP_X_COORD], Tech_ship_display_coords[gr_screen.res][SHIP_Y_COORD], Tech_ship_display_coords[gr_screen.res][SHIP_W_COORD], Tech_ship_display_coords[gr_screen.res][SHIP_H_COORD], GR_RESIZE_MENU);		// render the ship	g3_start_frame(1);	g3_set_view_matrix(&sip->closeup_pos, &vmd_identity_matrix, sip->closeup_zoom * 1.3f);		// lighting for techroom	light_reset();	vec3d light_dir = vmd_zero_vector;	light_dir.xyz.y = 1.0f;		light_dir.xyz.x = 0.0000001f;		light_add_directional(&light_dir, 0.85f, 1.0f, 1.0f, 1.0f);	light_rotate_all();	// lighting for techroom	Glowpoint_use_depth_buffer = false;	model_clear_instance(Techroom_ship_modelnum);	render_info.set_detail_level_lock(0);	polymodel *pm = model_get(Techroom_ship_modelnum);		for (i = 0; i < sip->n_subsystems; i++) {		model_subsystem *msp = &sip->subsystems[i];		if (msp->type == SUBSYSTEM_TURRET) {			float p = 0.0f;			float h = 0.0f;			for (j = 0; j < msp->n_triggers; j++) {				// special case for turrets				p = msp->triggers[j].angle.xyz.x;				h = msp->triggers[j].angle.xyz.y;			}			if ( msp->subobj_num >= 0 )	{				model_set_instance_techroom(Techroom_ship_modelnum, msp->subobj_num, 0.0f, h );//.........这里部分代码省略.........
开发者ID:RandomTiger,项目名称:fs2open.github.com,代码行数:101,


示例18: automap_process_input

int automap_process_input(window *wind, d_event *event, automap *am){	vms_matrix tempm;	Controls = am->controls;	kconfig_read_controls(event, 1);	am->controls = Controls;	memset(&Controls, 0, sizeof(control_info));	if ( !am->controls.automap_state && (am->leave_mode==1) )	{		window_close(wind);		return 1;	}		if ( am->controls.automap_count > 0)	{		am->controls.automap_count = 0;		if (am->leave_mode==0)		{			window_close(wind);			return 1;		}	}		if (PlayerCfg.AutomapFreeFlight)	{		if ( am->controls.fire_primary_count > 0)		{			// Reset orientation			am->viewMatrix = Objects[Players[Player_num].objnum].orient;			vm_vec_scale_add(&am->view_position, &Objects[Players[Player_num].objnum].pos, &am->viewMatrix.fvec, -ZOOM_DEFAULT );			am->controls.fire_primary_count = 0;		}				if (am->controls.pitch_time || am->controls.heading_time || am->controls.bank_time)		{			vms_angvec tangles;			vms_matrix new_m;			tangles.p = fixdiv( am->controls.pitch_time, ROT_SPEED_DIVISOR );			tangles.h = fixdiv( am->controls.heading_time, ROT_SPEED_DIVISOR );			tangles.b = fixdiv( am->controls.bank_time, ROT_SPEED_DIVISOR*2 );			vm_angles_2_matrix(&tempm, &tangles);			vm_matrix_x_matrix(&new_m,&am->viewMatrix,&tempm);			am->viewMatrix = new_m;			check_and_fix_matrix(&am->viewMatrix);		}				if ( am->controls.forward_thrust_time || am->controls.vertical_thrust_time || am->controls.sideways_thrust_time )		{			vm_vec_scale_add2( &am->view_position, &am->viewMatrix.fvec, am->controls.forward_thrust_time*ZOOM_SPEED_FACTOR );			vm_vec_scale_add2( &am->view_position, &am->viewMatrix.uvec, am->controls.vertical_thrust_time*SLIDE_SPEED );			vm_vec_scale_add2( &am->view_position, &am->viewMatrix.rvec, am->controls.sideways_thrust_time*SLIDE_SPEED );						// Crude wrapping check			if (am->view_position.x >  F1_0*32000) am->view_position.x =  F1_0*32000;			if (am->view_position.x < -F1_0*32000) am->view_position.x = -F1_0*32000;			if (am->view_position.y >  F1_0*32000) am->view_position.y =  F1_0*32000;			if (am->view_position.y < -F1_0*32000) am->view_position.y = -F1_0*32000;			if (am->view_position.z >  F1_0*32000) am->view_position.z =  F1_0*32000;			if (am->view_position.z < -F1_0*32000) am->view_position.z = -F1_0*32000;		}	}	else	{		if ( am->controls.fire_primary_count > 0)		{			// Reset orientation			am->viewDist = ZOOM_DEFAULT;			am->tangles.p = PITCH_DEFAULT;			am->tangles.h  = 0;			am->tangles.b  = 0;			am->view_target = Objects[Players[Player_num].objnum].pos;			am->controls.fire_primary_count = 0;		}		am->viewDist -= am->controls.forward_thrust_time*ZOOM_SPEED_FACTOR;		am->tangles.p += fixdiv( am->controls.pitch_time, ROT_SPEED_DIVISOR );		am->tangles.h  += fixdiv( am->controls.heading_time, ROT_SPEED_DIVISOR );		am->tangles.b  += fixdiv( am->controls.bank_time, ROT_SPEED_DIVISOR*2 );		if ( am->controls.vertical_thrust_time || am->controls.sideways_thrust_time )		{			vms_angvec      tangles1;			vms_vector      old_vt;			old_vt = am->view_target;			tangles1 = am->tangles;			vm_angles_2_matrix(&tempm,&tangles1);			vm_matrix_x_matrix(&am->viewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm);			vm_vec_scale_add2( &am->view_target, &am->viewMatrix.uvec, am->controls.vertical_thrust_time*SLIDE_SPEED );			vm_vec_scale_add2( &am->view_target, &am->viewMatrix.rvec, am->controls.sideways_thrust_time*SLIDE_SPEED );			if ( vm_vec_dist_quick( &am->view_target, &Objects[Players[Player_num].objnum].pos) > i2f(1000) )				am->view_target = old_vt;		}		vm_angles_2_matrix(&tempm,&am->tangles);		vm_matrix_x_matrix(&am->viewMatrix,&Objects[Players[Player_num].objnum].orient,&tempm);//.........这里部分代码省略.........
开发者ID:CDarrow,项目名称:DXX-Retro,代码行数:101,


示例19: do_endlevel_frame

//.........这里部分代码省略.........				timer = i2f(2);				vm_vec_negate(&endlevel_camera->orient.fvec);				vm_vec_negate(&endlevel_camera->orient.rvec);				vm_extract_angles_matrix(&cam_angles,&endlevel_camera->orient);				vm_extract_angles_matrix(&exit_seg_angles,&mine_exit_orient);				bank_rate = (-exit_seg_angles.b - cam_angles.b)/2;				ConsoleObject->control_type = endlevel_camera->control_type = CT_NONE;				//_MARK_("Starting outside");//Commented out by KRB#ifdef SLEW_ON slew_obj = endlevel_camera;#endif			}							break;		}		case EL_OUTSIDE: {			#ifndef SLEW_ON			vms_angvec cam_angles;			#endif			vm_vec_scale_add2(&ConsoleObject->pos,&ConsoleObject->orient.fvec,fixmul(FrameTime,cur_fly_speed));#ifndef SLEW_ON			vm_vec_scale_add2(&endlevel_camera->pos,&endlevel_camera->orient.fvec,fixmul(FrameTime,-2*cur_fly_speed));			vm_vec_scale_add2(&endlevel_camera->pos,&endlevel_camera->orient.uvec,fixmul(FrameTime,-cur_fly_speed/10));			vm_extract_angles_matrix(&cam_angles,&endlevel_camera->orient);			cam_angles.b += fixmul(bank_rate,FrameTime);			vm_angles_2_matrix(&endlevel_camera->orient,&cam_angles);#endif			timer -= FrameTime;			if (timer < 0) {				Endlevel_sequence = EL_STOPPED;				vm_extract_angles_matrix(&player_angles,&ConsoleObject->orient);				timer = i2f(3);			}			break;		}		case EL_STOPPED: {			get_angs_to_object(&player_dest_angles,&station_pos,&ConsoleObject->pos);			chase_angles(&player_angles,&player_dest_angles);			vm_angles_2_matrix(&ConsoleObject->orient,&player_angles);			vm_vec_scale_add2(&ConsoleObject->pos,&ConsoleObject->orient.fvec,fixmul(FrameTime,cur_fly_speed));			timer -= FrameTime;			if (timer < 0) {				#ifdef SLEW_ON				slew_obj = endlevel_camera;				_do_slew_movement(endlevel_camera,1,1);
开发者ID:NonCreature0714,项目名称:descent,代码行数:67,


示例20: _do_slew_movement

int _do_slew_movement(object *obj, int check_keys, int check_joy ){	int moved = 0;	vms_vector svel, movement;				//scaled velocity (per this frame)	vms_matrix rotmat,new_pm;	int joy_x,joy_y,btns;	int joyx_moved,joyy_moved;	vms_angvec rotang;	if (keyd_pressed[KEY_PAD5])		vm_vec_zero(&obj->phys_info.velocity);	if (check_keys) {		obj->phys_info.velocity.x += VEL_SPEED * (key_down_time(KEY_PAD9) - key_down_time(KEY_PAD7));		obj->phys_info.velocity.y += VEL_SPEED * (key_down_time(KEY_PADMINUS) - key_down_time(KEY_PADPLUS));		obj->phys_info.velocity.z += VEL_SPEED * (key_down_time(KEY_PAD8) - key_down_time(KEY_PAD2));		rotang.pitch =  (key_down_time(KEY_LBRACKET) - key_down_time(KEY_RBRACKET))/ROT_SPEED;		rotang.bank  = (key_down_time(KEY_PAD1) - key_down_time(KEY_PAD3))/ROT_SPEED;		rotang.head  = (key_down_time(KEY_PAD6) - key_down_time(KEY_PAD4))/ROT_SPEED;	}	else		rotang.pitch = rotang.bank  = rotang.head  = 0;	//check for joystick movement	if (check_joy && joy_present)	{		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 (btns)			if (!rotang.pitch) rotang.pitch = fixmul(-joy_y * 512,FrameTime); else;		else			if (joyy_moved) obj->phys_info.velocity.z = -joy_y * 8192;			if (!rotang.head) rotang.head = fixmul(joy_x * 512,FrameTime);			if (joyx_moved) old_joy_x = joy_x;		if (joyy_moved) old_joy_y = joy_y;	}	moved = rotang.pitch | rotang.bank | rotang.head;	vm_angles_2_matrix(&rotmat,&rotang);	vm_matrix_x_matrix(&new_pm,&obj->orient,&rotmat);	obj->orient = new_pm;	vm_transpose_matrix(&new_pm);		//make those columns rows	moved |= obj->phys_info.velocity.x | obj->phys_info.velocity.y | obj->phys_info.velocity.z;	svel = obj->phys_info.velocity;	vm_vec_scale(&svel,FrameTime);		//movement in this frame	vm_vec_rotate(&movement,&svel,&new_pm);	vm_vec_add2(&obj->pos,&movement);	moved |= (movement.x || movement.y || movement.z);	return moved;}
开发者ID:NonCreature0714,项目名称:descent,代码行数:66,


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


示例22: load_endlevel_data

//.........这里部分代码省略.........				break;			case 4: {						//planet bitmap				int iff_error;				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;
开发者ID:NonCreature0714,项目名称:descent,代码行数:67,


示例23: physics_sim_rot

void physics_sim_rot(matrix * orient, physics_info * pi, float sim_time ){	angles	tangles;	vec3d	new_vel;	matrix	tmp;	float		shock_amplitude;	float		rotdamp;	float		shock_fraction_time_left;	Assert(is_valid_matrix(orient));	Assert(is_valid_vec(&pi->rotvel));	Assert(is_valid_vec(&pi->desired_rotvel));	// Handle special case of shockwave	shock_amplitude = 0.0f;	if ( pi->flags & PF_IN_SHOCKWAVE ) {		if ( timestamp_elapsed(pi->shockwave_decay) ) {			pi->flags &= ~PF_IN_SHOCKWAVE;			rotdamp = pi->rotdamp;		} else { 			shock_fraction_time_left = timestamp_until( pi->shockwave_decay ) / (float) SW_BLAST_DURATION;			rotdamp = pi->rotdamp + pi->rotdamp * (SW_ROT_FACTOR - 1) * shock_fraction_time_left;			shock_amplitude = pi->shockwave_shake_amp * shock_fraction_time_left;		}	} else {		rotdamp = pi->rotdamp;	}	// Do rotational physics with given damping	apply_physics( rotdamp, pi->desired_rotvel.xyz.x, pi->rotvel.xyz.x, sim_time, &new_vel.xyz.x, NULL );	apply_physics( rotdamp, pi->desired_rotvel.xyz.y, pi->rotvel.xyz.y, sim_time, &new_vel.xyz.y, NULL );	apply_physics( rotdamp, pi->desired_rotvel.xyz.z, pi->rotvel.xyz.z, sim_time, &new_vel.xyz.z, NULL );	Assert(is_valid_vec(&new_vel));	pi->rotvel = new_vel;	tangles.p = pi->rotvel.xyz.x*sim_time;	tangles.h = pi->rotvel.xyz.y*sim_time;	tangles.b = pi->rotvel.xyz.z*sim_time;/*	//	Make ship shake due to afterburner.	if (pi->flags & PF_AFTERBURNER_ON || !timestamp_elapsed(pi->afterburner_decay) ) {		float	max_speed;		max_speed = vm_vec_mag_quick(&pi->max_vel);		tangles.p += (float) (rand()-RAND_MAX_2) * RAND_MAX_1f * pi->speed/max_speed/64.0f;		tangles.h += (float) (rand()-RAND_MAX_2) * RAND_MAX_1f * pi->speed/max_speed/64.0f;		if ( pi->flags & PF_AFTERBURNER_ON ) {			pi->afterburner_decay = timestamp(ABURN_DECAY_TIME);		}	}*/	// Make ship shake due to shockwave, decreasing in amplitude at the end of the shockwave	if ( pi->flags & PF_IN_SHOCKWAVE ) {		tangles.p += (float) (myrand()-RAND_MAX_2) * RAND_MAX_1f * shock_amplitude;		tangles.h += (float) (myrand()-RAND_MAX_2) * RAND_MAX_1f * shock_amplitude;	}	vm_angles_2_matrix(&pi->last_rotmat, &tangles );	vm_matrix_x_matrix( &tmp, orient, &pi->last_rotmat );	*orient = tmp;	vm_orthogonalize_matrix(orient);}
开发者ID:DahBlount,项目名称:Freespace-Open-Swifty,代码行数:68,


示例24: shockwave_create

// ------------------------------------------------------------------------------------// shockwave_create()//// Call to create a shockwave////	input:	parent_objnum	=> object number of object spawning the shockwave//				pos				=>	vector specifing global position of shockwave center//				speed				=>	speed at which shockwave expands (m/s)//				inner_radius	=>	radius at which damage applied is at maximum//				outer_radius	=> damage decreases linearly to zero from inner_radius to//										outer_radius.  Outside outer_radius, damage is 0.//				damage			=>	the maximum damage (ie within inner_radius)//				blast				=> the maximux blast (within inner_radius)//				sw_flag			=> indicates whether shockwave is from weapon or ship explosion//				delay          => delay in ms before the shockwave actually starts////	return:	success			=>	object number of shockwave//				failure			=>	-1//// Goober5000 - now parent_objnum can be allowed to be -1int shockwave_create(int parent_objnum, vec3d *pos, shockwave_create_info *sci, int flag, int delay){	int				i, objnum, real_parent;	int				info_index = -1, model_id = -1;	shockwave		*sw;//	shockwave_info	*si;	matrix			orient; 	for (i = 0; i < MAX_SHOCKWAVES; i++) {		if ( !(Shockwaves[i].flags & SW_USED) )			break;	}	if (i == MAX_SHOCKWAVES)		return -1;	// try 2D shockwave first, then fall back to 3D, then fall back to default of either	// this should be pretty fool-proof and allow quick change between 2D and 3D effects	if ( strlen(sci->name) )		info_index = shockwave_load(sci->name, false);	if ( (info_index < 0) && strlen(sci->pof_name) )		info_index = shockwave_load(sci->pof_name, true);	if (info_index < 0) {		if ( (Shockwave_info[0].bitmap_id >= 0) || (Shockwave_info[0].model_id >= 0) ) {			info_index = 0;			model_id = Shockwave_info[0].model_id;		} else {			// crap, just bail			return -1;		}	} else {		model_id = Shockwave_info[info_index].model_id;	}	// real_parent is the guy who caused this shockwave to happen	if (parent_objnum == -1) {	// Goober5000		real_parent = -1;	} else if ( Objects[parent_objnum].type == OBJ_WEAPON ){		real_parent = Objects[parent_objnum].parent;	} else {		real_parent = parent_objnum;	}	sw = &Shockwaves[i];	sw->model_id = model_id;	sw->flags = (SW_USED | flag);	sw->speed = sci->speed;	sw->inner_radius = sci->inner_rad;	sw->outer_radius = sci->outer_rad;	sw->damage = sci->damage;	sw->blast = sci->blast;	sw->radius = 1.0f;	sw->pos = *pos;	sw->num_objs_hit = 0;	sw->shockwave_info_index = info_index;		// only one type for now... type could be passed is as a parameter	sw->current_bitmap = -1;	sw->time_elapsed=0.0f;	sw->delay_stamp = delay;	sw->rot_angles = sci->rot_angles;	sw->damage_type_idx = sci->damage_type_idx;//	si = &Shockwave_info[sw->shockwave_info_index];//	sw->total_time = i2fl(si->num_frames) / si->fps;	// in seconds	sw->total_time = sw->outer_radius / sw->speed;	if ( (parent_objnum != -1) && Objects[parent_objnum].type == OBJ_WEAPON ) {		// Goober5000: allow -1		sw->weapon_info_index = Weapons[Objects[parent_objnum].instance].weapon_info_index;	}	else {				sw->weapon_info_index = -1;	}	orient = vmd_identity_matrix;	vm_angles_2_matrix(&orient, &sw->rot_angles);//	angles a;//.........这里部分代码省略.........
开发者ID:svn2github,项目名称:FS2Open_Trunk,代码行数:101,


示例25: do_slew_movement

int do_slew_movement(object *obj, int check_keys, int check_joy ){	int moved = 0;	vms_vector svel, movement;				//scaled velocity (per this frame)	vms_matrix rotmat,new_pm;	int joy_x,joy_y,btns;	int joyx_moved,joyy_moved;	vms_angvec rotang;	if (!slew_obj || slew_obj->control_type!=CT_SLEW) return 0;	if (check_keys) {		if (Function_mode == FMODE_EDITOR) {			obj->mtype.phys_info.velocity.x += VEL_SPEED * (key_down_time(KEY_PAD9) - key_down_time(KEY_PAD7));			obj->mtype.phys_info.velocity.y += VEL_SPEED * (key_down_time(KEY_PADMINUS) - key_down_time(KEY_PADPLUS));			obj->mtype.phys_info.velocity.z += VEL_SPEED * (key_down_time(KEY_PAD8) - key_down_time(KEY_PAD2));			rotang.p = (key_down_time(KEY_LBRACKET) - key_down_time(KEY_RBRACKET))/ROT_SPEED ;			rotang.b  = (key_down_time(KEY_PAD1) - key_down_time(KEY_PAD3))/ROT_SPEED;			rotang.h  = (key_down_time(KEY_PAD6) - key_down_time(KEY_PAD4))/ROT_SPEED;		}		else {			obj->mtype.phys_info.velocity.x += VEL_SPEED * Controls.sideways_thrust_time;			obj->mtype.phys_info.velocity.y += VEL_SPEED * Controls.vertical_thrust_time;			obj->mtype.phys_info.velocity.z += VEL_SPEED * Controls.forward_thrust_time;			rotang.p = Controls.pitch_time/ROT_SPEED ;			rotang.b  = Controls.bank_time/ROT_SPEED;			rotang.h  = Controls.heading_time/ROT_SPEED;		}	}	else		rotang.p = rotang.b  = rotang.h  = 0;	//check for joystick movement	if (check_joy && joy_present && (Function_mode == FMODE_EDITOR) )	{		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 (btns)			if (!rotang.p) rotang.p = fixmul(-joy_y * 512,FrameTime); else;		else			if (joyy_moved) obj->mtype.phys_info.velocity.z = -joy_y * 8192;			if (!rotang.h) rotang.h = fixmul(joy_x * 512,FrameTime);			if (joyx_moved) old_joy_x = joy_x;		if (joyy_moved) old_joy_y = joy_y;	}	moved = rotang.p | rotang.b | rotang.h;	vm_angles_2_matrix(&rotmat,&rotang);	vm_matrix_x_matrix(&new_pm,&obj->orient,&rotmat);	obj->orient = new_pm;	vm_transpose_matrix(&new_pm);		//make those columns rows	moved |= obj->mtype.phys_info.velocity.x | obj->mtype.phys_info.velocity.y | obj->mtype.phys_info.velocity.z;	svel = obj->mtype.phys_info.velocity;	vm_vec_scale(&svel,FrameTime);		//movement in this frame	vm_vec_rotate(&movement,&svel,&new_pm);//	obj->last_pos = obj->pos;	vm_vec_add2(&obj->pos,&movement);	moved |= (movement.x || movement.y || movement.z);	if (moved) 		update_object_seg(obj);	//update segment id	return moved;}
开发者ID:NonCreature0714,项目名称:descent,代码行数:80,



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


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