当前位置: 首页>>代码示例>>C++>>正文


C++ SHORT2ANGLE函数代码示例

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


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

示例1: BotUpdateInput

/*
 * BotUpdateInput
 */
void
BotUpdateInput(bot_state_t *bs, int time, int elapsed_time)
{
	bot_input_t bi;
	int j;

	/* add the delta angles to the bot's current view angles */
	for(j = 0; j < 3; j++)
		bs->viewangles[j] =
			modeuler(bs->viewangles[j] +
				SHORT2ANGLE(bs->cur_ps.delta_angles[j]));
	/* change the bot view angles */
	BotChangeViewAngles(bs, (float)elapsed_time / 1000);
	/* retrieve the bot input */
	trap_EA_GetInput(bs->client, (float)time / 1000, &bi);
	/* respawn hack */
	if(bi.actionflags & ACTION_RESPAWN)
		if(bs->lastucmd.buttons & BUTTON_PRIATTACK) bi.actionflags &=
				~(ACTION_RESPAWN|ACTION_ATTACK);
	/* convert the bot input to a usercmd */
	BotInputToUserCommand(&bi, &bs->lastucmd, bs->cur_ps.delta_angles, time);
	/* subtract the delta angles */
	for(j = 0; j < 3; j++)
		bs->viewangles[j] =
			modeuler(bs->viewangles[j] -
				SHORT2ANGLE(bs->cur_ps.delta_angles[j]));
}
开发者ID:icanhas,项目名称:yantar,代码行数:30,代码来源:main.c

示例2: BotUpdateInput

/*
==============
BotUpdateInput
==============
*/
void BotUpdateInput(bot_state_t *bs, int time, int elapsed_time)
{
    bot_input_t bi;
    int j;

    //add the delta angles to the bot's current view angles
    for (j = 0; j < 3; j++)
    {
        bs->viewangles[j] = AngleMod(bs->viewangles[j] + SHORT2ANGLE(bs->cur_ps.delta_angles[j]));
    }
    //change the bot view angles
    BotChangeViewAngles(bs, (float) elapsed_time / 1000);
    //retrieve the bot input
    botlib_export->ea.EA_GetInput(bs->client, (float) time / 1000, &bi);
    //respawn hack
    if (bi.actionflags & ACTION_RESPAWN)
    {
        if (bs->lastucmd.buttons & BUTTON_ATTACK) bi.actionflags &= ~(ACTION_RESPAWN|ACTION_ATTACK);
    }
    //convert the bot input to a usercmd
    BotInputToUserCommand(&bi, &bs->lastucmd, bs->cur_ps.delta_angles, time);
    //subtract the delta angles
    for (j = 0; j < 3; j++)
    {
        bs->viewangles[j] = AngleMod(bs->viewangles[j] - SHORT2ANGLE(bs->cur_ps.delta_angles[j]));
    }
}
开发者ID:zturtleman,项目名称:recoil,代码行数:32,代码来源:ai_main.c

示例3: deltas

/*
===================
MoveCmdToViewAngles

Given a movement command, computes the
floating point view angles requested by
that command, given the inputted delta
angles for that entity.  The computed angles
are stored in "view"

NOTE: Remember that the deltas (ps->delta_angles)
have the same type as the command angles-- they are
stored as integers, not floating points.

NOTE: This code is based on PM_UpdateViewAngles()
in bg_pmove.c.
===================
*/
void MoveCmdToViewAngles(usercmd_t *cmd, int *delta, vec3_t view)
{
	int short_angle;

	// The pitch angle has extra boundary checks
	short_angle = cmd->angles[PITCH] + delta[PITCH];
	if (short_angle > 16000)
		short_angle = 16000;
	else if (short_angle < -16000)
		short_angle = -16000;
	view[PITCH] = SHORT2ANGLE(short_angle);

	// Translate the yaw and roll angles from shorts to floats
	view[YAW ] = SHORT2ANGLE(cmd->angles[YAW ] + delta[YAW ]);
	view[ROLL] = SHORT2ANGLE(cmd->angles[ROLL] + delta[ROLL]);

	// Make sure the angles are bounded in the standard manner
	//
	// NOTE: If the rest of the code is written well, this shouldn't
	// matter.  Bounding in [0,360) should be just as good as [-180,+180).
	// But better safe than sorry.
	view[PITCH] = AngleNormalize180(view[PITCH]);
	view[YAW  ] = AngleNormalize180(view[YAW  ]);
	view[ROLL ] = AngleNormalize180(view[ROLL ]);
}
开发者ID:Garey27,项目名称:quake3-brainworks,代码行数:43,代码来源:ai_command.c

示例4: PM_ScaleUcmd

void PM_ScaleUcmd( playerState_t *ps, usercmd_t *cmd, gentity_t *gent )
{
	if ( ps->vehicleModel != 0 )
	{//driving a vehicle
		//clamp the turn rate
		int maxPitchSpeed = MAX_PITCHSPEED_X_WING;//switch, eventually?  Or read from file?
		int diff = AngleNormalize180(SHORT2ANGLE((cmd->angles[PITCH]+ps->delta_angles[PITCH]))) - floor(ps->viewangles[PITCH]);
	
		if ( diff > maxPitchSpeed )
		{
			cmd->angles[PITCH] = ANGLE2SHORT( ps->viewangles[PITCH] + maxPitchSpeed ) - ps->delta_angles[PITCH];
		}
		else if ( diff < -maxPitchSpeed )
		{
			cmd->angles[PITCH] = ANGLE2SHORT( ps->viewangles[PITCH] - maxPitchSpeed ) - ps->delta_angles[PITCH];
		}

		//Um, WTF?  When I turn in a certain direction, I start going backwards?  Or strafing?
		int maxYawSpeed = MAX_YAWSPEED_X_WING;//switch, eventually?  Or read from file?
		diff = AngleNormalize180(SHORT2ANGLE(cmd->angles[YAW]+ps->delta_angles[YAW]) - floor(ps->viewangles[YAW]));

		//clamp the turn rate
		if ( diff > maxYawSpeed )
		{
			cmd->angles[YAW] = ANGLE2SHORT( ps->viewangles[YAW] + maxYawSpeed ) - ps->delta_angles[YAW];
		}
		else if ( diff < -maxYawSpeed )
		{
			cmd->angles[YAW] = ANGLE2SHORT( ps->viewangles[YAW] - maxYawSpeed ) - ps->delta_angles[YAW];
		}
	}
}
开发者ID:Ced2911,项目名称:massive-tyrion,代码行数:32,代码来源:bg_pangles.cpp

示例5: BotUpdateInput

/*
==============
BotUpdateInput
==============
*/
void BotUpdateInput( bot_state_t *bs, int time ) {
	bot_input_t bi;
	int j;

	//add the delta angles to the bot's current view angles
	for ( j = 0; j < 3; j++ ) {
		bs->viewangles[j] = AngleMod( bs->viewangles[j] + SHORT2ANGLE( bs->cur_ps.delta_angles[j] ) );
	}
	//
	BotChangeViewAngles( bs, (float) time / 1000 );
	trap_EA_GetInput( bs->client, (float) time / 1000, &bi );
	//respawn hack
	if ( bi.actionflags & ACTION_RESPAWN ) {
		if ( bs->lastucmd.buttons & BUTTON_ATTACK ) {
			bi.actionflags &= ~( ACTION_RESPAWN | ACTION_ATTACK );
		}
	}
	//
	BotInputToUserCommand( &bi, &bs->lastucmd, bs->cur_ps.delta_angles, time );
	bs->lastucmd.serverTime = time;
	//subtract the delta angles
	for ( j = 0; j < 3; j++ ) {
		bs->viewangles[j] = AngleMod( bs->viewangles[j] - SHORT2ANGLE( bs->cur_ps.delta_angles[j] ) );
	}
}
开发者ID:MAN-AT-ARMS,项目名称:iortcw-archive,代码行数:30,代码来源:ai_main.c

示例6: PM_ClampAngles

void PM_ClampAngles (void)
{
	short	temp;
	int		i;

	if (pm->s.pm_flags & PMF_TIME_TELEPORT)
	{
		pm->viewangles[YAW] = SHORT2ANGLE(pm->cmd.angles[YAW] + pm->s.delta_angles[YAW]);
		pm->viewangles[PITCH] = 0;
		pm->viewangles[ROLL] = 0;
	}

	else
	{
		/* circularly clamp the angles with deltas */
		for (i=0 ; i<3 ; i++)
		{
			temp = pm->cmd.angles[i] + pm->s.delta_angles[i];
			pm->viewangles[i] = SHORT2ANGLE(temp);
		}

		/* don't let the player look up or down more than 90 degrees */
		if (pm->viewangles[PITCH] > 89 && pm->viewangles[PITCH] < 180)
			pm->viewangles[PITCH] = 89;

		else if (pm->viewangles[PITCH] < 271 && pm->viewangles[PITCH] >= 180)
			pm->viewangles[PITCH] = 271;
	}

	AngleVectors (pm->viewangles, pml.forward, pml.right, pml.up);
}
开发者ID:Nekrofage,项目名称:Quake2RPi,代码行数:31,代码来源:pmove.c

示例7: demoMoveUpdateAngles

void demoMoveUpdateAngles(void) {
	float oldAngle, newAngle;int i;
	for (i=0;i<3;i++) {
		oldAngle = SHORT2ANGLE( demo.oldcmd.angles[i] );
		newAngle = SHORT2ANGLE( demo.cmd.angles[i] );
		demo.cmdDeltaAngles[i] = AngleNormalize180( newAngle - oldAngle );
	}
}
开发者ID:entdark,项目名称:q3mme,代码行数:8,代码来源:cg_demos_move.c

示例8: NPC_FacePosition

qboolean NPC_FacePosition( vec3_t position, qboolean doPitch )
{
	vec3_t		muzzle;
	vec3_t		angles;
	float		yawDelta;
	qboolean	facing = qtrue;

	//Get the positions
	if ( NPC->client && (NPC->client->NPC_class == CLASS_RANCOR || NPC->client->NPC_class == CLASS_WAMPA) )// || NPC->client->NPC_class == CLASS_SAND_CREATURE) )
	{
		CalcEntitySpot( NPC, SPOT_ORIGIN, muzzle );
		muzzle[2] += NPC->r.maxs[2] * 0.75f;
	}
	else if ( NPC->client && NPC->client->NPC_class == CLASS_GALAKMECH )
	{
		CalcEntitySpot( NPC, SPOT_WEAPON, muzzle );
	}
	else
	{
		CalcEntitySpot( NPC, SPOT_HEAD_LEAN, muzzle );//SPOT_HEAD
	}

	//Find the desired angles
	GetAnglesForDirection( muzzle, position, angles );

	NPCInfo->desiredYaw		= AngleNormalize360( angles[YAW] );
	NPCInfo->desiredPitch	= AngleNormalize360( angles[PITCH] );

	if ( NPC->enemy && NPC->enemy->client && NPC->enemy->client->NPC_class == CLASS_ATST )
	{
		// FIXME: this is kind of dumb, but it was the easiest way to get it to look sort of ok
		NPCInfo->desiredYaw	+= flrand( -5, 5 ) + sin( level.time * 0.004f ) * 7;
		NPCInfo->desiredPitch += flrand( -2, 2 );
	}
	//Face that yaw
	NPC_UpdateAngles( qtrue, qtrue );

	//Find the delta between our goal and our current facing
	yawDelta = AngleNormalize360( NPCInfo->desiredYaw - ( SHORT2ANGLE( ucmd.angles[YAW] + client->ps.delta_angles[YAW] ) ) );
	
	//See if we are facing properly
	if ( fabs( yawDelta ) > VALID_ATTACK_CONE )
		facing = qfalse;

	if ( doPitch )
	{
		//Find the delta between our goal and our current facing
		float currentAngles = ( SHORT2ANGLE( ucmd.angles[PITCH] + client->ps.delta_angles[PITCH] ) );
		float pitchDelta = NPCInfo->desiredPitch - currentAngles;
		
		//See if we are facing properly
		if ( fabs( pitchDelta ) > VALID_ATTACK_CONE )
			facing = qfalse;
	}

	return facing;
}
开发者ID:jwginge,项目名称:ojpa,代码行数:57,代码来源:NPC_utils.c

示例9: PM_UpdateViewAngles

/*
================
PM_UpdateViewAngles

This can be used as another entry point when only the viewangles
are being updated isntead of a full move
================
*/
void PM_UpdateViewAngles( playerState_t *ps, const usercmd_t *cmd ) {
	short		temp;
	int		i;

	if ( ps->pm_type == PM_INTERMISSION || ps->pm_type == PM_SPINTERMISSION) {
		return;		// no view changes at all
	}

	if ( ps->pm_type != PM_SPECTATOR && ps->stats[STAT_HEALTH] <= 0 ) {
		return;		// no view changes at all
	}

	// circularly clamp the angles with deltas
	for (i=0 ; i<3 ; i++) {
		temp = cmd->angles[i] + ps->delta_angles[i];
		if ( i == PITCH ) {
			// don't let the player look up or down more than 90 degrees
			if ( temp > 16000 ) {
				ps->delta_angles[i] = 16000 - cmd->angles[i];
				temp = 16000;
			} else if ( temp < -16000 ) {
				ps->delta_angles[i] = -16000 - cmd->angles[i];
				temp = -16000;
			}
		}
		ps->viewangles[i] = SHORT2ANGLE(temp);
	}

}
开发者ID:mecwerks,项目名称:spearmint-ios,代码行数:37,代码来源:bg_pmove.c

示例10: Cl_PredictMovement

/*
 * Cl_PredictMovement
 *
 * Run the latest movement command through the player movement code locally,
 * using the resulting origin and angles to reduce perceived latency.
 */
void Cl_PredictMovement(void) {
	int i, ack, current;
	pm_move_t pm;
	float step;

	if (cls.state != CL_ACTIVE)
		return;

	if (!cl_predict->value || (cl.frame.ps.pmove.pm_flags & PMF_NO_PREDICTION)) {
		for (i = 0; i < 3; i++) { // just set angles
			cl.predicted_angles[i] = cl.angles[i]
					+ SHORT2ANGLE(cl.frame.ps.pmove.delta_angles[i]);
		}
		return;
	}

	ack = cls.netchan.incoming_acknowledged;
	current = cls.netchan.outgoing_sequence;

	// if we are too far out of date, just freeze
	if (current - ack >= CMD_BACKUP) {
		Com_Warn("Cl_PredictMovement: Exceeded CMD_BACKUP.\n");
		return;
	}

	// copy current state to pmove
	memset(&pm, 0, sizeof(pm));
	pm.Trace = Cl_Trace;
	pm.PointContents = Cl_Pointcontents;
	pm.s = cl.frame.ps.pmove;
	pm.s.gravity = cl_gravity;

	// run frames
	while (++ack <= current) {
		const int frame = ack & CMD_MASK;
		const user_cmd_t *cmd = &cl.cmds[frame];

		if (!cmd->msec)
			continue;

		pm.cmd = *cmd;
		Pmove(&pm);

		// save for debug checking
		VectorCopy(pm.s.origin, cl.predicted_origins[frame]);
	}

	step = pm.s.origin[2] * 0.125 - cl.predicted_origin[2];

	if ((pm.s.pm_flags & PMF_ON_STAIRS) && step > 4.0) { // save for stair lerping
		cl.predicted_step_time = cls.real_time;
		cl.predicted_step = step;
	}

	// copy results out for rendering
	VectorScale(pm.s.origin, 0.125, cl.predicted_origin);
	VectorCopy(pm.angles, cl.predicted_angles);

	cl.underwater = pm.water_level > 2;
}
开发者ID:darkshade9,项目名称:aq2w,代码行数:66,代码来源:cl_pred.c

示例11: CL_ClampPitch

void CL_ClampPitch(void)
{
  float pitch;

  pitch = SHORT2ANGLE(cl.frame.playerstate.pmove.delta_angles[PITCH]);

  if (pitch > 180) {
    pitch -= 360;
  }

  if (cl.viewangles[PITCH] + pitch < -360) {
    cl.viewangles[PITCH] += 360; /* wrapped */
  }

  if (cl.viewangles[PITCH] + pitch > 360) {
    cl.viewangles[PITCH] -= 360; /* wrapped */
  }

  if (cl.viewangles[PITCH] + pitch > 89) {
    cl.viewangles[PITCH] = 89 - pitch;
  }

  if (cl.viewangles[PITCH] + pitch < -89) {
    cl.viewangles[PITCH] = -89 - pitch;
  }
}
开发者ID:greck2908,项目名称:qengine,代码行数:26,代码来源:cl_input.c

示例12: IN_MLookUp

static void IN_MLookUp()
{
	in_mlooking = qfalse;
	if ( !cl_freelook->integer ) {
		cl.viewangles[PITCH] = -SHORT2ANGLE(cl.snap.ps.delta_angles[PITCH]);
	}
}
开发者ID:DaTa-,项目名称:cnq3x,代码行数:7,代码来源:cl_input.cpp

示例13: SHORT2ANGLE

void Player::Think()
{
	speed *= player_speed.GetFloat();
	orgin.x += _usercmd.forwardmove * speed.x;
	orgin.y += _usercmd.forwardmove * speed.y;

	orgin.x += _usercmd.rightmove * speed.y;
	orgin.y += -_usercmd.rightmove * speed.x;
	orgin.z += _usercmd.upmove * player_speed.GetFloat();

	for (int i = 0; i < 3; i++ ) {
		cmdAngles[i] = SHORT2ANGLE( _usercmd.angles[i] );
		viewAngles[i] = idMath::AngleNormalize180( SHORT2ANGLE( _usercmd.angles[i]));
	}

	CalculateRenderView();
}
开发者ID:wang35666,项目名称:doom3,代码行数:17,代码来源:Player.cpp

示例14: IN_CenterView

void IN_CenterView( void ) {
	qboolean ok = qtrue;
	if ( cgvm ) {
		ok = VM_Call( cgvm, CG_CHECKCENTERVIEW );
	}
	if ( ok ) {
		cl.viewangles[PITCH] = -SHORT2ANGLE( cl.snap.ps.delta_angles[PITCH] );
	}
}
开发者ID:chegestar,项目名称:omni-bot,代码行数:9,代码来源:cl_input.c

示例15: IN_CenterView

/*
* IN_CenterView
*/
void IN_CenterView( void )
{
	if( cl.currentSnapNum > 0 )
	{
		player_state_t *playerState;
		playerState = &cl.snapShots[cl.currentSnapNum & UPDATE_MASK].playerState;
		cl.viewangles[PITCH] = -SHORT2ANGLE( playerState->pmove.delta_angles[PITCH] );
	}
}
开发者ID:tenght,项目名称:qfusion,代码行数:12,代码来源:cl_input.c


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