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

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

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

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

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

示例1: BG_PlayerTouchesItem

/*============BG_PlayerTouchesItemItems can be picked up without actually touching their physical bounds to makegrabbing them easier============*/qboolean	BG_PlayerTouchesItem( playerState_t *ps, entityState_t *item, int atTime ) {	vec3_t		origin;	BG_EvaluateTrajectory( &item->pos, atTime, origin );	// we are ignoring ducked differences here	if ( ps->origin[0] - origin[0] > 44		|| ps->origin[0] - origin[0] < -50		|| ps->origin[1] - origin[1] > 36		|| ps->origin[1] - origin[1] < -36		|| ps->origin[2] - origin[2] > 36		|| ps->origin[2] - origin[2] < -36 ) {		return qfalse;	}	return qtrue;}
开发者ID:LoudHoward,项目名称:Quake3,代码行数:25,


示例2: qlua_setpos

int qlua_setpos(lua_State *L) {	centity_t	*luaentity;	vec3_t		origin;	luaL_checktype(L,1,LUA_TUSERDATA);	luaL_checktype(L,2,LUA_TVECTOR);	luaentity = lua_toentity(L,1);	if(luaentity != NULL) {			BG_EvaluateTrajectory( &luaentity->currentState.pos, cg.time, origin );			lua_tovector(L,2,luaentity->currentState.pos.trBase);			luaentity->currentState.pos.trDuration += (cg.time - luaentity->currentState.pos.trTime);			luaentity->currentState.pos.trTime = cg.time;						VectorCopy(luaentity->currentState.pos.trBase, luaentity->currentState.origin);		return 1;	}	return 0;}
开发者ID:redrumrobot,项目名称:quakeconstruct,代码行数:19,


示例3: G_ExplodeMissile

/*================G_ExplodeMissileExplode a missile without an impact================*/void G_ExplodeMissile( gentity_t *ent ) {	vec3_t		dir;	vec3_t		origin;	BG_EvaluateTrajectory( &ent->s.pos, level.time, origin );	SnapVector( origin );	G_SetOrigin( ent, origin );	// we don't have a valid direction, so just point straight up	dir[0] = dir[1] = 0;	dir[2] = 1;	ent->s.eType = ET_GENERAL;	G_AddEvent( ent, EV_MISSILE_MISS, DirToByte( dir ) );	ent->freeAfterEvent = qtrue;	ent->takedamage = qfalse;	// splash damage	if ( ent->splashDamage ) {		//NOTE: vehicle missiles don't have an ent->parent set, so check that here and set it		if ( ent->s.eType == ET_MISSILE//missile			&& (ent->s.eFlags&EF_JETPACK_ACTIVE)//vehicle missile			&& ent->r.ownerNum < MAX_CLIENTS )//valid client owner		{//set my parent to my owner for purposes of damage credit...			ent->parent = &g_entities[ent->r.ownerNum];		}		if( G_RadiusDamage( ent->r.currentOrigin, ent->parent, ent->splashDamage, ent->splashRadius, ent, 				ent, ent->splashMethodOfDeath ) ) 		{			if (ent->parent)			{				g_entities[ent->parent->s.number].client->accuracy_hits++;			}			else if (ent->activator)			{				g_entities[ent->activator->s.number].client->accuracy_hits++;			}		}	}	trap_LinkEntity( ent );}
开发者ID:3ddy,项目名称:Jedi-Outcast,代码行数:50,


示例4: CG_AddMoveScaleFade

/*==================CG_AddMoveScaleFade==================*/static void CG_AddMoveScaleFade( localEntity_t *le ) {	refEntity_t	*re;	float		c;	vec3_t		delta;	float		len;	re = &le->refEntity;	// fade / grow time//	c = ( le->endTime - cg.time ) * le->lifeRate;	if ( le->fadeInTime > le->startTime && cg.time < le->fadeInTime ) {		// fade / grow time		c = 1.0 - (float) ( le->fadeInTime - cg.time ) / ( le->fadeInTime - le->startTime );	}	else {		// fade / grow time		c = ( le->endTime - cg.time ) * le->lifeRate;	}	// Ridah, spark	if ( !( le->leFlags & LEF_NOFADEALPHA ) )	// done.	re->shaderRGBA[3] = 0xff * c * le->color[3];	if ( !( le->leFlags & LEF_PUFF_DONT_SCALE ) ) {		c = ( le->endTime - cg.time ) * le->lifeRate;		re->radius = le->radius * ( 1.0 - c ) + 8;	}	BG_EvaluateTrajectory( &le->pos, cg.time, re->origin );	// if the view would be "inside" the sprite, kill the sprite	// so it doesn't add too much overdraw	VectorSubtract( re->origin, cg.refdef.vieworg, delta );	len = VectorLength( delta );	if ( len < le->radius ) {		CG_FreeLocalEntity( le );		return;	}	trap_R_AddRefEntityToScene( re );}
开发者ID:natelo,项目名称:rtcwPub,代码行数:47,


示例5: CG_BubbleThink

/*=======================================================================================================================================CG_BubbleThink=======================================================================================================================================*/void CG_BubbleThink(localEntity_t *le) {	int contents;	vec3_t newOrigin;	trace_t trace;	// calculate new position	BG_EvaluateTrajectory(&le->pos, cg.time, newOrigin);	// trace a line from previous position to new position	CG_Trace(&trace, le->refEntity.origin, NULL, NULL, newOrigin, -1, CONTENTS_SOLID);	contents = CG_PointContents(trace.endpos, -1);	if (!(contents & (CONTENTS_WATER|CONTENTS_SLIME|CONTENTS_LAVA))) {		// bubble isn't in liquid anymore, remove it		CG_FreeLocalEntity(le);		return;	}	CG_AddMoveScaleFade(le);}
开发者ID:KuehnhammerTobias,项目名称:ioqw,代码行数:25,


示例6: CG_BloodTrail

/*=======================================================================================================================================CG_BloodTrailLeave expanding blood puffs behind gibs.=======================================================================================================================================*/void CG_BloodTrail(localEntity_t *le) {	int t;	int t2;	int step;	vec3_t newOrigin;	localEntity_t *blood;	step = 150;	t = step * ((cg.time - cg.frametime + step) / step);	t2 = step * (cg.time / step);	for (; t <= t2; t += step) {		BG_EvaluateTrajectory(&le->pos, t, newOrigin);		blood = CG_SmokePuff(newOrigin, vec3_origin, 20, 1, 1, 1, 1, 2000, t, 0, 0, cgs.media.bloodTrailShader);		// use the optimized version		blood->leType = LE_FALL_SCALE_FADE;		// drop a total of 40 units over its lifetime		blood->pos.trDelta[2] = 40;	}}
开发者ID:KuehnhammerTobias,项目名称:ioqw,代码行数:28,


示例7: Mover_HaltAngles

/***Stops rotational movement on ent immediately.@function HaltAngles@param ent Entity or entity number.@return Success or failure.*/static int Mover_HaltAngles(lua_State * L){	lent_t			*lent;	gentity_t       *ent = NULL;	int				id = 0;	if(lua_isnumber(L, 1)) {		id = luaL_checkint(L, 1);		if(id < 0 || id > MAX_GENTITIES - 1) {			lua_pushboolean(L, qfalse);			return 1;		}		ent = &g_entities[id];		if(ent) {			lua_pushboolean(L, qfalse);			return 1;		}	} else {		lent = Lua_GetEntity(L, 1);		if(lent == NULL || lent->e == NULL) {			lua_pushboolean(L, qfalse);			return 1;		}		ent = lent->e;	}	LUA_DEBUG("Mover_HaltAngles - start: ent=%d", ent->s.number);	if(ent)	{		BG_EvaluateTrajectory(&ent->s.apos, level.time, ent->s.apos.trBase);		ent->s.apos.trType = TR_STATIONARY;		ent->s.apos.trTime = level.time;		trap_LinkEntity(ent);		LUA_DEBUG("Mover_HaltAngles - return: halted ent");	}	lua_pushboolean(L, qtrue);	return 1;}
开发者ID:gitter-badger,项目名称:rpgxEF,代码行数:45,


示例8: CG_CheckEvents

/*==============CG_CheckEvents==============*/void CG_CheckEvents( centity_t *cent ){	// check for event-only entities	if ( cent->currentState.eType > ET_EVENTS )	{		if ( cent->previousEvent )		{			return;	// already fired		}		cent->previousEvent = 1;		// if this is a player event set the entity number of the client entity number		if ( cent->currentState.eFlags & EF_PLAYER_EVENT )		{			cent->currentState.number = cent->currentState.otherEntityNum;		}		cent->currentState.event = cent->currentState.eType - ET_EVENTS;	} 	else 	{		// check for events riding with another entity		if ( cent->currentState.event == cent->previousEvent )		{			return;		}		cent->previousEvent = cent->currentState.event;		if ( ( cent->currentState.event & ~EV_EVENT_BITS ) == 0 )		{			return;		}	}	// calculate the position at exactly the frame time	BG_EvaluateTrajectory( &cent->currentState.pos, cg.snap->serverTime, cent->lerpOrigin );	CG_SetEntitySoundPosition( cent );	CG_EntityEvent( cent, cent->lerpOrigin );}
开发者ID:MilitaryForces,项目名称:MilitaryForces,代码行数:45,


示例9: Mover_Halt

/***Stops translational movement on ent immediately.@function Halt@param ent Entity or entity number.@return Success or failure.*/static int Mover_Halt(lua_State *L) {	lent_t		*lent;	gentity_t	*ent = NULL;	int			id = 0;		if(lua_isnumber(L, 1)) {		id =  luaL_checkint(L, 1);		if(id < 0 || id > MAX_GENTITIES - 1) {			lua_pushboolean(L, qfalse);			return 1;		}		ent = &g_entities[id];		if(ent == NULL) {			lua_pushboolean(L, qfalse);			return 1;		}	} else {		lent = Lua_GetEntity(L, 1);		if(lent == NULL || lent->e == NULL) {			lua_pushboolean(L, qfalse);			return 1;		}		ent = lent->e;	}	LUA_DEBUG("Mover_Halt - start: end=%d", ent->s.number);	BG_EvaluateTrajectory(&ent->s.pos, level.time, ent->r.currentOrigin);	VectorCopy(ent->r.currentOrigin, ent->s.pos.trBase);	ent->s.pos.trType = TR_STATIONARY;	ent->s.pos.trTime = level.time;	ent->nextthink = 0;	ent->think = NULL;	ent->nextTrain = NULL;	trap_LinkEntity(ent);	LUA_DEBUG("Mover_Halt - return: halted ent");	lua_pushboolean(L, qtrue);	return 1;}
开发者ID:gitter-badger,项目名称:rpgxEF,代码行数:44,


示例10: CG_AddMoveScaleFade

static void CG_AddMoveScaleFade( localEntity_t *le ) {	refEntity_t	*re;	float		c;	vector3		delta;	float		len;	refdef_t *refdef = CG_GetRefdef();	re = &le->refEntity;	if ( le->fadeInTime > le->startTime && cg.time < le->fadeInTime ) {		// fade / grow time		c = 1.0f - (float)(le->fadeInTime - cg.time) / (le->fadeInTime - le->startTime);	}	else {		// fade / grow time		c = (le->endTime - cg.time) * le->lifeRate;	}	re->shaderRGBA[3] = 0xff * c * le->color[3];	if ( !(le->leFlags & LEF_PUFF_DONT_SCALE) ) {		re->radius = le->radius * (1.0f - c) + 8;	}	BG_EvaluateTrajectory( &le->pos, cg.time, &re->origin );	// if the view would be "inside" the sprite, kill the sprite	// so it doesn't add too much overdraw	VectorSubtract( &re->origin, &refdef->vieworg, &delta );	len = VectorLength( &delta );	if ( len < le->radius ) {		CG_FreeLocalEntity( le );		return;	}	SE_R_AddRefEntityToScene( re, MAX_CLIENTS );}
开发者ID:Arcadiaprime,项目名称:japp,代码行数:37,


示例11: G_minethink

voidG_minethink(gentity_t *ent){  trace_t tr;  vec3_t end, origin, dir;  gentity_t *traceEnt;  ent->nextthink = level.time + 100;  BG_EvaluateTrajectory(&ent->s.pos, level.time, origin);  SnapVector(origin);  G_SetOrigin(ent, origin);  // set aiming directions  VectorCopy(origin,end);  end[2] += 10;//aim up  trap_Trace(&tr, origin, NULL, NULL, end, ent->s.number, MASK_SHOT);  if (tr.surfaceFlags & SURF_NOIMPACT)    return;  traceEnt = &g_entities[tr.entityNum];  dir[0] = dir[1] = 0;  dir[2] = 1;  if (traceEnt->client && (traceEnt->r.svFlags & SVF_BOT)      && traceEnt->health > 0 && traceEnt->client->ps.stats[STAT_PTEAM] == PTE_ALIENS)//FIRE IN ZE HOLE!  {//Might want to check team too    ent->s.eType = ET_GENERAL;    G_AddEvent(ent, EV_MISSILE_MISS, DirToByte(dir));    ent->freeAfterEvent = qtrue;    G_RadiusDamage(ent->r.currentOrigin, ent->parent, ent->splashDamage, ent->splashRadius, ent, ent->splashMethodOfDeath);    ent->parent->numMines -= 1;    trap_LinkEntity(ent);  }}
开发者ID:AlienHoboken,项目名称:Tremulous-Z-Server,代码行数:37,


示例12: G_ExplodeMissile

/*================G_ExplodeMissileExplode a missile without an impact================*/void G_ExplodeMissile( gentity_t *ent ) {    vec3_t		dir;    vec3_t		origin;    BG_EvaluateTrajectory( &ent->s.pos, level.time, origin );    SnapVector( origin );    G_SetOrigin( ent, origin );    // we don't have a valid direction, so just point straight up    dir[0] = dir[1] = 0;    dir[2] = 1;    ent->s.eType = ET_GENERAL;    G_AddEvent( ent, EV_MISSILE_MISS, DirToByte( dir ) );    ent->freeAfterEvent = qtrue;    ent->takedamage = qfalse;    // splash damage    if ( ent->splashDamage ) {        if( G_RadiusDamage( ent->r.currentOrigin, ent->parent, ent->splashDamage, ent->splashRadius, ent,                            ent, ent->splashMethodOfDeath ) )        {            if (ent->parent)            {                g_entities[ent->parent->s.number].client->accuracy_hits++;            }            else if (ent->activator)            {                g_entities[ent->activator->s.number].client->accuracy_hits++;            }        }    }    trap->LinkEntity( (sharedEntity_t *)ent );}
开发者ID:Mauii,项目名称:Rend2,代码行数:43,


示例13: CG_AddMoveScaleFade

/*==================CG_AddMoveScaleFade==================*/static void CG_AddMoveScaleFade( localEntity_t *le ) {	refEntity_t	*re;	gfixed		c;	bvec3_t		delta;	bfixed		len;	re = &le->refEntity;	if ( le->fadeInTime > le->startTime && cg.time < le->fadeInTime ) {		// fade / grow time		c = GFIXED_1 - MAKE_GFIXED( le->fadeInTime - cg.time ) / MAKE_GFIXED( le->fadeInTime - le->startTime );	}	else {		// fade / grow time		c = MAKE_GFIXED( le->endTime - cg.time ) * le->lifeRate;	}	re->shaderRGBA[3] = FIXED_TO_INT( GFIXED(255,0) * c * le->color[3] );	if ( !( le->leFlags & LEF_PUFF_DONT_SCALE ) ) {		re->radius = (le->radius * ( GFIXED_1 - c )) + BFIXED(8,0);	}	BG_EvaluateTrajectory( &le->pos, cg.time, re->origin );	// if the view would be "inside" the sprite, kill the sprite	// so it doesn't add too much overdraw	VectorSubtract( re->origin, cg.refdef.vieworg, delta );	len = FIXED_VEC3LEN( delta );	if ( len < le->radius ) {		CG_FreeLocalEntity( le );		return;	}	_CG_trap_R_AddRefEntityToScene( re );}
开发者ID:Jsoucek,项目名称:q3ce,代码行数:41,


示例14: CG_AddSparkElements

/*================CG_AddSparkElements================*/void CG_AddSparkElements( localEntity_t *le ) {	vec3_t	newOrigin;	trace_t	trace;	float	time;	float	lifeFrac;	time = (float)(cg.time - cg.frametime);	while (1) {		// calculate new position		BG_EvaluateTrajectory( &le->pos, cg.time, newOrigin );//		if ((le->endTime - le->startTime) > 500) {			// trace a line from previous position to new position			CG_Trace( &trace, le->refEntity.origin, NULL, NULL, newOrigin, -1, MASK_SHOT );			// if stuck, kill it			if (trace.startsolid) {				// HACK, some walls screw up, so just pass through if starting in a solid				VectorCopy( newOrigin, trace.endpos );				trace.fraction = 1.0;			}			// moved some distance			VectorCopy( trace.endpos, le->refEntity.origin );/*		} else		{	// just move it there			VectorCopy( newOrigin, le->refEntity.origin );			trace.fraction = 1.0;		}*/		time += cg.frametime * trace.fraction;		lifeFrac = (float)(cg.time - le->startTime) / (float)(le->endTime - le->startTime);		// add a trail		le->headJuncIndex = CG_AddSparkJunc( le->headJuncIndex,									le->refEntity.customShader,									le->refEntity.origin,									200,									1.0 - lifeFrac,	// start alpha									0.0,//1.0 - lifeFrac,	// end alpha									lifeFrac * 2.0 * (((le->endTime - le->startTime) > 400)+1)*1.5,									lifeFrac * 2.0 * (((le->endTime - le->startTime) > 400)+1)*1.5 );		// if it is in a nodrop zone, remove it		// this keeps gibs from waiting at the bottom of pits of death		// and floating levels// for some reason SFM1.BSP is one big NODROP zone//		if ( trap_CM_PointContents( le->refEntity.origin, 0 ) & CONTENTS_NODROP ) {//			CG_FreeLocalEntity( le );//			return;//		}		if (trace.fraction < 1.0) {			// just kill it			CG_FreeLocalEntity( le );			return;/*			// reflect the velocity on the trace plane			CG_ReflectVelocity( le, &trace );			// the intersection is a fraction of the frametime			le->pos.trTime = (int)time;*/		}		if ( trace.fraction == 1.0 || time >= (float)cg.time ) {			return;		}	}}
开发者ID:natelo,项目名称:rtcwPub,代码行数:81,


示例15: CG_AddClientCritter

/*================CG_AddClientCritter================*/void CG_AddClientCritter( localEntity_t *le ) {	vec3_t	newOrigin;	trace_t	trace;	int		time, step = 25, i;	vec3_t	v, ang, v2, oDelta;	localEntity_t backup;	float	oldSpeed, enemyDist, of;	vec3_t	enemyPos;	float alpha;	if (cg_entities[le->ownerNum].currentState.otherEntityNum2 == cg.snap->ps.clientNum) {		VectorCopy( cg.snap->ps.origin, enemyPos );		enemyPos[2] += cg.snap->ps.viewheight;	} else {		VectorCopy( cg_entities[le->ownerNum].currentState.origin2, enemyPos );	}	VectorCopy( le->pos.trDelta, oDelta );	// vary the enemyPos to create a psuedo-randomness	of = (float)cg.time + le->startTime;	enemyPos[0] += 12 * (sin(of/100) * cos(of/78));	enemyPos[1] += 12 * (sin(of/70) * cos(of/82));	enemyPos[2] += 12 * (sin(of/67) * cos(of/98));	time = le->lastTrailTime+step;	while (time <= cg.time) {		if (time > le->refEntity.fadeStartTime) {			alpha = (float)(time - le->refEntity.fadeStartTime)/(float)(le->refEntity.fadeEndTime - le->refEntity.fadeStartTime);			if (alpha < 0) alpha = 0;			else if (alpha > 1) alpha = 1;		} else {			alpha = 1.0;		}		// calculate new position		BG_EvaluateTrajectory( &le->pos, time, newOrigin );		VectorSubtract( enemyPos, le->refEntity.origin, v );		enemyDist = VectorNormalize( v );		// trace a line from previous position to new position		CG_Trace( &trace, le->refEntity.origin, NULL, NULL, newOrigin, le->ownerNum, MASK_SHOT );		// if stuck, kill it		if (trace.startsolid || (trace.fraction < 1.0)) {			// kill it			CG_FreeLocalEntity( le );			return;		}		// moved some distance		VectorCopy( trace.endpos, le->refEntity.origin );		if (le->leType == LE_ZOMBIE_SPIRIT) {			le->headJuncIndex = CG_AddTrailJunc( le->headJuncIndex,												cgs.media.zombieSpiritTrailShader,												time,												STYPE_STRETCH,												le->refEntity.origin,												(int)le->effectWidth,	// trail life												0.3 * alpha,												0.0,												le->radius,												0,												0,//TJFL_FIXDISTORT,												colorWhite,												colorWhite,												1.0, 1 );		}		// tracking factor		if (le->leType == LE_ZOMBIE_BAT)			le->bounceFactor = 3.0*(float)step/1000.0;		else			le->bounceFactor = 5.0*(float)step/1000.0;		oldSpeed = VectorLength( le->pos.trDelta );		// track the enemy		backup = *le;		VectorSubtract( enemyPos, le->refEntity.origin, v );		enemyDist = VectorNormalize( v );		if (alpha > 0.5 && (le->lastSpiritDmgTime < time - 100) && enemyDist < 24) {			// inflict the damage!			CG_ClientDamage( cg_entities[le->ownerNum].currentState.otherEntityNum2, le->ownerNum, CLDMG_SPIRIT );			le->lastSpiritDmgTime = time;		}		VectorMA( le->pos.trDelta, le->bounceFactor*oldSpeed, v, le->pos.trDelta );		//VectorCopy( v, le->pos.trDelta );		if (VectorLength(le->pos.trDelta) < 1) {			CG_FreeLocalEntity( le );			return;//.........这里部分代码省略.........
开发者ID:natelo,项目名称:rtcwPub,代码行数:101,


示例16: CG_AddFragment

//.........这里部分代码省略.........			le->refEntity.shaderRGBA[3] = (unsigned char)(255.0*flameAlpha);			VectorCopy( flameDir, le->refEntity.fireRiseDir );			le->refEntity.customShader = cgs.media.onFireShader;			trap_R_AddRefEntityToScene( &le->refEntity );			le->refEntity.customShader = cgs.media.onFireShader2;			trap_R_AddRefEntityToScene( &le->refEntity );			le->refEntity = backupEnt;		}				t = le->endTime - cg.time;		trap_R_AddRefEntityToScene( &le->refEntity );		// trace a line from previous position down, to see if I should start falling again		VectorCopy(le->refEntity.origin, newOrigin);		newOrigin [2] -= 5;		CG_Trace( &trace, le->refEntity.origin, NULL, NULL, newOrigin, -1, CONTENTS_SOLID|CONTENTS_PLAYERCLIP|CONTENTS_MISSILECLIP );		if(trace.fraction == 1.0)	// it's clear, start moving again		{			VectorClear(le->pos.trDelta);			VectorClear(le->angles.trDelta);			le->pos.trType = TR_GRAVITY;	// nothing below me, start falling again		}		else			return;	}	// calculate new position	BG_EvaluateTrajectory( &le->pos, cg.time, newOrigin );	if (hasFlame) {		// calc the flame dir		VectorSubtract( le->refEntity.origin, newOrigin, flameDir );		if (VectorLength( flameDir ) == 0) {			flameDir[2] = 1;			// play a burning sound when not moving			trap_S_AddLoopingSound( 0, newOrigin, vec3_origin, cgs.media.flameSound, (int)(0.3*255.0*flameAlpha) );		} else {			VectorNormalize( flameDir );			// play a flame blow sound when moving			trap_S_AddLoopingSound( 0, newOrigin, vec3_origin, cgs.media.flameBlowSound, (int)(0.3*255.0*flameAlpha) );		}	}	// trace a line from previous position to new position	CG_Trace( &trace, le->refEntity.origin, NULL, NULL, newOrigin, -1, CONTENTS_SOLID );	if ( trace.fraction == 1.0 ) {		// still in free fall		VectorCopy( newOrigin, le->refEntity.origin );		if ( le->leFlags & LEF_TUMBLE || le->angles.trType == TR_LINEAR) {			vec3_t angles;			BG_EvaluateTrajectory( &le->angles, cg.time, angles );			AnglesToAxis( angles, le->refEntity.axis );			if (le->sizeScale && le->sizeScale != 1.0) {				for (i=0;i<3;i++) VectorScale( le->refEntity.axis[i], le->sizeScale, le->refEntity.axis[i] );			}		}
开发者ID:natelo,项目名称:rtcwPub,代码行数:66,


示例17: turret_aim

//-----------------------------------------------------static void turret_aim( gentity_t *self )//-----------------------------------------------------{	vec3_t	enemyDir, org, org2;	vec3_t	desiredAngles, setAngle;	float	diffYaw = 0.0f, diffPitch = 0.0f, turnSpeed;	const float pitchCap = 40.0f;	gentity_t *top = &g_entities[self->r.ownerNum];	if ( !top )	{		return;	}	// move our gun base yaw to where we should be at this time....	BG_EvaluateTrajectory( &top->s.apos, level.time, top->r.currentAngles );	top->r.currentAngles[YAW] = AngleNormalize180( top->r.currentAngles[YAW] );	top->r.currentAngles[PITCH] = AngleNormalize180( top->r.currentAngles[PITCH] );	turnSpeed = top->speed;	if ( self->painDebounceTime > level.time )	{		desiredAngles[YAW] = top->r.currentAngles[YAW]+flrand(-45,45);		desiredAngles[PITCH] = top->r.currentAngles[PITCH]+flrand(-10,10);		if (desiredAngles[PITCH] < -pitchCap)		{			desiredAngles[PITCH] = -pitchCap;		}		else if (desiredAngles[PITCH] > pitchCap)		{			desiredAngles[PITCH] = pitchCap;		}		diffYaw = AngleSubtract( desiredAngles[YAW], top->r.currentAngles[YAW] );		diffPitch = AngleSubtract( desiredAngles[PITCH], top->r.currentAngles[PITCH] );		turnSpeed = flrand( -5, 5 );	}	else if ( self->enemy )	{		// ...then we'll calculate what new aim adjustments we should attempt to make this frame		// Aim at enemy		VectorCopy( self->enemy->r.currentOrigin, org );		org[2]+=self->enemy->r.maxs[2]*0.5f;		if (self->enemy->s.eType == ET_NPC &&			self->enemy->s.NPC_class == CLASS_VEHICLE &&			self->enemy->m_pVehicle &&			self->enemy->m_pVehicle->m_pVehicleInfo->type == VH_WALKER)		{ //hack!			org[2] += 32.0f;		}		/*		mdxaBone_t	boltMatrix;		// Getting the "eye" here		gi.G2API_GetBoltMatrix( self->ghoul2, self->playerModel, 					self->torsoBolt,					&boltMatrix, self->r.currentAngles, self->s.origin, (cg.time?cg.time:level.time),					NULL, self->s.modelScale );		gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, org2 );		*/		VectorCopy( top->r.currentOrigin, org2 );		VectorSubtract( org, org2, enemyDir );		vectoangles( enemyDir, desiredAngles );		desiredAngles[PITCH] = AngleNormalize180(desiredAngles[PITCH]);		if (desiredAngles[PITCH] < -pitchCap)		{			desiredAngles[PITCH] = -pitchCap;		}		else if (desiredAngles[PITCH] > pitchCap)		{			desiredAngles[PITCH] = pitchCap;		}		diffYaw = AngleSubtract( desiredAngles[YAW], top->r.currentAngles[YAW] );		diffPitch = AngleSubtract( desiredAngles[PITCH], top->r.currentAngles[PITCH] );	}	else	{//FIXME: Pan back and forth in original facing		// no enemy, so make us slowly sweep back and forth as if searching for a new one		desiredAngles[YAW] = sin( level.time * 0.0001f + top->count );		desiredAngles[YAW] *=  60.0f;		desiredAngles[YAW] += self->s.angles[YAW];		desiredAngles[YAW] = AngleNormalize180( desiredAngles[YAW] );		diffYaw = AngleSubtract( desiredAngles[YAW], top->r.currentAngles[YAW] );		diffPitch = AngleSubtract( 0, top->r.currentAngles[PITCH] );		turnSpeed = 1.0f;	}	if ( diffYaw )	{		// cap max speed....		if ( fabs(diffYaw) > turnSpeed )		{			diffYaw = ( diffYaw >= 0 ? turnSpeed : -turnSpeed );		}	}//.........这里部分代码省略.........
开发者ID:jwginge,项目名称:ojpa,代码行数:101,


示例18: G_RunMissile

/*================G_RunMissile================*/void G_RunMissile( gentity_t *ent ) {    vec3_t		origin, groundSpot;    trace_t		tr;    int			passent;    qboolean	isKnockedSaber = qfalse;    if (ent->neverFree && ent->s.weapon == WP_SABER && (ent->flags & FL_BOUNCE_HALF))    {        isKnockedSaber = qtrue;        ent->s.pos.trType = TR_GRAVITY;    }    // get current position    BG_EvaluateTrajectory( &ent->s.pos, level.time, origin );    //If its a rocket, and older than 500ms, make it solid to the shooter.    if ((g_tweakWeapons.integer & WT_SOLID_ROCKET) && (ent->s.weapon == WP_ROCKET_LAUNCHER) && (!ent->raceModeShooter) && (ent->nextthink - level.time < 9500)) {        ent->r.ownerNum = ENTITYNUM_WORLD;    }    // if this missile bounced off an invulnerability sphere    if ( ent->target_ent ) {        passent = ent->target_ent->s.number;    }    else {        // ignore interactions with the missile owner        if ( (ent->r.svFlags&SVF_OWNERNOTSHARED)                && (ent->s.eFlags&EF_JETPACK_ACTIVE) )        {   //A vehicle missile that should be solid to its owner            //I don't care about hitting my owner            passent = ent->s.number;        }        else        {            passent = ent->r.ownerNum;        }    }    // trace a line from the previous position to the current position    if (d_projectileGhoul2Collision.integer == 1) //JAPRO - Serverside - Weapons - New Hitbox Option    {        JP_Trace( &tr, ent->r.currentOrigin, ent->r.mins, ent->r.maxs, origin, passent, ent->clipmask, qfalse, G2TRFLAG_DOGHOULTRACE|G2TRFLAG_GETSURFINDEX|G2TRFLAG_THICK|G2TRFLAG_HITCORPSES, g_g2TraceLod.integer );        if (tr.fraction != 1.0 && tr.entityNum < ENTITYNUM_WORLD)        {            gentity_t *g2Hit = &g_entities[tr.entityNum];            if (g2Hit->inuse && g2Hit->client && g2Hit->ghoul2)            {   //since we used G2TRFLAG_GETSURFINDEX, tr.surfaceFlags will actually contain the index of the surface on the ghoul2 model we collided with.                g2Hit->client->g2LastSurfaceHit = tr.surfaceFlags;                g2Hit->client->g2LastSurfaceTime = level.time;            }            if (g2Hit->ghoul2)            {                tr.surfaceFlags = 0; //clear the surface flags after, since we actually care about them in here.            }        }    }    else    {        JP_Trace( &tr, ent->r.currentOrigin, ent->r.mins, ent->r.maxs, origin, passent, ent->clipmask, qfalse, 0, 0 );    }    if ( tr.startsolid || tr.allsolid ) {        // make sure the tr.entityNum is set to the entity we're stuck in        JP_Trace( &tr, ent->r.currentOrigin, ent->r.mins, ent->r.maxs, ent->r.currentOrigin, passent, ent->clipmask, qfalse, 0, 0 );        tr.fraction = 0;    }    else {        VectorCopy( tr.endpos, ent->r.currentOrigin );    }    if (ent->passThroughNum && tr.entityNum == (ent->passThroughNum-1))    {        VectorCopy( origin, ent->r.currentOrigin );        trap->LinkEntity( (sharedEntity_t *)ent );        goto passthrough;    }    trap->LinkEntity( (sharedEntity_t *)ent );    if (ent->s.weapon == G2_MODEL_PART && !ent->bounceCount)    {        vec3_t lowerOrg;        trace_t trG;        VectorCopy(ent->r.currentOrigin, lowerOrg);        lowerOrg[2] -= 1;        JP_Trace( &trG, ent->r.currentOrigin, ent->r.mins, ent->r.maxs, lowerOrg, passent, ent->clipmask, qfalse, 0, 0 );        VectorCopy(trG.endpos, groundSpot);        if (!trG.startsolid && !trG.allsolid && trG.entityNum == ENTITYNUM_WORLD)        {//.........这里部分代码省略.........
开发者ID:videoP,项目名称:jaPRO,代码行数:101,


示例19: G_RunObject

//TODO:  When transition to 0 grav, push away from surface you were resting on//TODO:  When free-floating in air, apply some friction to your trDelta (based on mass?)void G_RunObject( gentity_t *ent ) {	vector3		origin, oldOrg;	trace_t		tr;	gentity_t	*traceEnt = NULL;	//FIXME: floaters need to stop floating up after a while, even if gravity stays negative?	if ( ent->s.pos.trType == TR_STATIONARY )//g_gravity.value <= 0 &&	{		ent->s.pos.trType = TR_GRAVITY;		VectorCopy( &ent->r.currentOrigin, &ent->s.pos.trBase );		ent->s.pos.trTime = level.previousTime;//?necc?		if ( !g_gravity.value ) {			ent->s.pos.trDelta.z += 100;		}	}	ent->nextthink = level.time + FRAMETIME;	VectorCopy( &ent->r.currentOrigin, &oldOrg );	// get current position	BG_EvaluateTrajectory( &ent->s.pos, level.time, &origin );	//Get current angles?	BG_EvaluateTrajectory( &ent->s.apos, level.time, &ent->r.currentAngles );	if ( VectorCompare( &ent->r.currentOrigin, &origin ) ) {//error - didn't move at all!		return;	}	// trace a line from the previous position to the current position,	// ignoring interactions with the missile owner	trap->Trace( &tr, &ent->r.currentOrigin, &ent->r.mins, &ent->r.maxs, &origin, ent->parent ? ent->parent->s.number : ent->s.number, ent->clipmask, qfalse, 0, 0 );	if ( !tr.startsolid && !tr.allsolid && tr.fraction ) {		VectorCopy( &tr.endpos, &ent->r.currentOrigin );		trap->LinkEntity( (sharedEntity_t *)ent );	}	else		//if ( tr.startsolid )	{		tr.fraction = 0;	}	G_MoverTouchPushTriggers( ent, &oldOrg );	/*	if ( !(ent->s.eFlags & EF_TELEPORT_BIT) && !(ent->svFlags & SVF_NO_TELEPORT) )	{	G_MoverTouchTeleportTriggers( ent, oldOrg );	if ( ent->s.eFlags & EF_TELEPORT_BIT )	{//was teleported	return;	}	}	else	{	ent->s.eFlags &= ~EF_TELEPORT_BIT;	}	*/	if ( tr.fraction == 1 ) {		if ( g_gravity.value <= 0 ) {			if ( ent->s.apos.trType == TR_STATIONARY ) {				VectorCopy( &ent->r.currentAngles, &ent->s.apos.trBase );				ent->s.apos.trType = TR_LINEAR;				ent->s.apos.trDelta.y = flrand( -300, 300 );				ent->s.apos.trDelta.x = flrand( -10, 10 );				ent->s.apos.trDelta.z = flrand( -10, 10 );				ent->s.apos.trTime = level.time;			}		}		//friction in zero-G		if ( !g_gravity.value ) {			float friction = 0.975f;			//friction -= ent->mass/1000.0f;			if ( friction < 0.1f ) {				friction = 0.1f;			}			VectorScale( &ent->s.pos.trDelta, friction, &ent->s.pos.trDelta );			VectorCopy( &ent->r.currentOrigin, &ent->s.pos.trBase );			ent->s.pos.trTime = level.time;		}		return;	}	//hit something	//Do impact damage	traceEnt = &g_entities[tr.entityNum];	if ( tr.fraction || (traceEnt && traceEnt->takedamage) ) {		if ( !VectorCompare( &ent->r.currentOrigin, &oldOrg ) ) {//moved and impacted			if ( (traceEnt && traceEnt->takedamage) ) {//hurt someone				//				G_Sound( ent, G_SoundIndex( "sound/movers/objects/objectHurt.wav" ) );			}			//			G_Sound( ent, G_SoundIndex( "sound/movers/objects/objectHit.wav" ) );		}		if ( ent->s.weapon != WP_SABER ) {			DoImpact( ent, traceEnt, qtrue );		}//.........这里部分代码省略.........
开发者ID:MatthewCZ,项目名称:Ja,代码行数:101,


示例20: VectorCopy

void CCam::mortarCam(camInfo_t *ci){	if (eth32.cg.snap->ps.ammo == 0)		return;// Set mortar trajectory from current view	vec3_t angles, forward;	VectorCopy(eth32.cg.refdef->viewaxis[ROLL], forward);	VectorCopy(eth32.cg.snap->ps.viewangles, angles);	angles[PITCH] -= 60.f;	AngleVectors(angles, forward, NULL, NULL);	forward[0] *= 3000 * 1.1f;	forward[1] *= 3000 * 1.1f;	forward[2] *= 1500 * 1.1f;	trajectory_t mortarTrajectory;	mortarTrajectory.trType = TR_GRAVITY;	mortarTrajectory.trTime = eth32.cg.time;	VectorCopy(eth32.cg.muzzle, mortarTrajectory.trBase);	VectorCopy(forward, mortarTrajectory.trDelta);	// Calculate mortar impact	int timeOffset = 0;	trace_t mortarTrace;	vec3_t mortarImpact;	VectorCopy(mortarTrajectory.trBase, mortarImpact);	#define TIME_STEP 20	while (timeOffset < 10000) {		vec3_t nextPos;		timeOffset += TIME_STEP;		BG_EvaluateTrajectory(&mortarTrajectory, eth32.cg.time + timeOffset, nextPos, qfalse, 0);		orig_CG_Trace(&mortarTrace, mortarImpact, 0, 0, nextPos, eth32.cg.snap->ps.clientNum, MASK_MISSILESHOT);		if ((mortarTrace.fraction != 1)				// Stop if we hit sky				&& !((mortarTrace.surfaceFlags & SURF_NODRAW) || (mortarTrace.surfaceFlags & SURF_NOIMPACT))				&& (mortarTrace.contents != 0)) {			break;		}		VectorCopy(nextPos, mortarImpact);	}	memcpy(&camRefDef, &eth32.cg.refdef, sizeof(refdef_t));	// kobject: add some angles	vec3_t	dpos;	vec3_t	camOrg;	dpos[0] = eth32.cg.refdef->vieworg[0]-mortarImpact[0];	dpos[1] = eth32.cg.refdef->vieworg[1]-mortarImpact[1];	dpos[2] = 0.0f;	VectorNormalizeFast( dpos );	VectorCopy( mortarImpact, camOrg );	VectorMA( camOrg, ci->distance * sinf(ci->angle * M_PI/180.0), zAxis, camOrg );	VectorMA( camOrg, ci->distance * cosf(ci->angle * M_PI/180.0), dpos, camOrg );	int w = ci->x2 - ci->x1;	int h = ci->y2 - ci->y1;	camRefDef.fov_x = (w>h) ? ci->fov : ci->fov * w / h;	camRefDef.fov_y = (h>w) ? ci->fov : ci->fov * h / w;	VectorCopy(camOrg, camRefDef.vieworg);	vec3_t camAngle;	VectorCopy(eth32.cg.refdefViewAngles, camAngle);	camAngle[PITCH] = ci->angle;	AnglesToAxis(camAngle, camRefDef.viewaxis);	drawCam(ci->x1, ci->y1, w, h, &camRefDef, qtrue);	// Draw impact time	sprintf(this->str, "^7Impact Time: ^b%.1f ^7seconds", (float)timeOffset / 1000.0f);	Draw.Text(ci->x1 + (w / 2) - (TEXTWIDTH(this->str) / 2), ci->y1 + h - 22 , 0.24f, str, GUI_FONTCOLOR1, qfalse, qtrue, &eth32.cg.media.fontArial, true);}
开发者ID:rabb,项目名称:eth32nix-rabbmod,代码行数:76,


示例21: CG_AddFragment

/*================CG_AddFragment================*/void CG_AddFragment( localEntity_t *le ) {	vec3_t	newOrigin;	trace_t	trace;	if ( le->pos.trType == TR_STATIONARY ) {		// sink into the ground if near the removal time		int		t;		float	oldZ;				t = le->endTime - cg.time;		if ( t < SINK_TIME ) {			// we must use an explicit lighting origin, otherwise the			// lighting would be lost as soon as the origin went			// into the ground			VectorCopy( le->refEntity.origin, le->refEntity.lightingOrigin );			le->refEntity.renderfx |= RF_LIGHTING_ORIGIN;			oldZ = le->refEntity.origin[2];			le->refEntity.origin[2] -= 16 * ( 1.0 - (float)t / SINK_TIME );			CG_AddRefEntityWithMinLight( &le->refEntity );			le->refEntity.origin[2] = oldZ;		} else {			CG_AddRefEntityWithMinLight( &le->refEntity );		}		return;	}	// calculate new position	BG_EvaluateTrajectory( &le->pos, cg.time, newOrigin );	// trace a line from previous position to new position	CG_Trace( &trace, le->refEntity.origin, NULL, NULL, newOrigin, -1, CONTENTS_SOLID );	if ( trace.fraction == 1.0 ) {		// still in free fall		VectorCopy( newOrigin, le->refEntity.origin );		if ( le->leFlags & LEF_TUMBLE ) {			vec3_t angles;			BG_EvaluateTrajectory( &le->angles, cg.time, angles );			AnglesToAxis( angles, le->refEntity.axis );		}		CG_AddRefEntityWithMinLight( &le->refEntity );		// add a blood trail		if ( le->leBounceSoundType == LEBS_BLOOD ) {			CG_BloodTrail( le );		}		return;	}	// if it is in a nodrop zone, remove it	// this keeps gibs from waiting at the bottom of pits of death	// and floating levels	if ( CG_PointContents( trace.endpos, 0 ) & CONTENTS_NODROP ) {		CG_FreeLocalEntity( le );		return;	}	// leave a mark	CG_FragmentBounceMark( le, &trace );	// do a bouncy sound	CG_FragmentBounceSound( le, &trace );	// reflect the velocity on the trace plane	CG_ReflectVelocity( le, &trace );	CG_AddRefEntityWithMinLight( &le->refEntity );}
开发者ID:mecwerks,项目名称:spearmint-ios,代码行数:77,


示例22: G_RunItem

/*================G_RunItem================*/void G_RunItem( gentity_t *ent ) {	vec3_t origin;	trace_t tr;	int contents;	int mask;	// if its groundentity has been set to none, it may have been pushed off an edge	if ( ent->s.groundEntityNum == ENTITYNUM_NONE ) {		if ( ent->s.pos.trType != TR_GRAVITY ) {			ent->s.pos.trType = TR_GRAVITY;			ent->s.pos.trTime = level.time;		}	}	if ( ent->s.pos.trType == TR_STATIONARY || ent->s.pos.trType == TR_GRAVITY_PAUSED ) { //----(SA)		// check think function		G_RunThink( ent );		return;	}	// get current position	BG_EvaluateTrajectory( &ent->s.pos, level.time, origin );	// trace a line from the previous position to the current position	if ( ent->clipmask ) {		mask = ent->clipmask;	} else {		mask = MASK_SOLID;	}	trap_Trace( &tr, ent->r.currentOrigin, ent->r.mins, ent->r.maxs, origin,				ent->r.ownerNum, mask );	if ( ent->isProp && ent->takedamage ) {		G_RunItemProp( ent, origin );	}	VectorCopy( tr.endpos, ent->r.currentOrigin );	if ( tr.startsolid ) {		tr.fraction = 0;	}	trap_LinkEntity( ent ); // FIXME: avoid this for stationary?	// check think function	G_RunThink( ent );	if ( tr.fraction == 1 ) {		return;	}	// if it is in a nodrop volume, remove it	contents = trap_PointContents( ent->r.currentOrigin, -1 );	if ( contents & CONTENTS_NODROP ) {		if ( ent->item && ent->item->giType == IT_TEAM ) {			Team_FreeEntity( ent );		} else {			G_FreeEntity( ent );		}		return;	}	G_BounceItem( ent, &tr );}
开发者ID:MAN-AT-ARMS,项目名称:iortcw-archive,代码行数:70,


示例23: G_MissileImpact

void G_MissileImpact( gentity_t *ent, trace_t *trace ) {#elsevoid G_MissileImpact( gentity_t *ent, trace_t *trace, int shaderNum ) {#endif	gentity_t		*other;	qboolean		hitClient = qfalse;#ifndef SMOKINGUNS#ifdef MISSIONPACK	vec3_t			forward, impactpoint, bouncedir;	int				eFlags;#endif#else	qboolean		hitKnife  = qfalse;	vec3_t			bottledirs[ALC_COUNT];#endif	other = &g_entities[trace->entityNum];#ifndef SMOKINGUNS	// check for bounce	if ( !other->takedamage &&		( ent->s.eFlags & ( EF_BOUNCE | EF_BOUNCE_HALF ) ) ) {		G_BounceMissile( ent, trace );		G_AddEvent( ent, EV_GRENADE_BOUNCE, 0 );		return;	}#ifdef MISSIONPACK	if ( other->takedamage ) {		if ( ent->s.weapon != WP_PROX_LAUNCHER ) {			if ( other->client && other->client->invulnerabilityTime > level.time ) {				//				VectorCopy( ent->s.pos.trDelta, forward );				VectorNormalize( forward );				if (G_InvulnerabilityEffect( other, forward, ent->s.pos.trBase, impactpoint, bouncedir )) {					VectorCopy( bouncedir, trace->plane.normal );					eFlags = ent->s.eFlags & EF_BOUNCE_HALF;					ent->s.eFlags &= ~EF_BOUNCE_HALF;					G_BounceMissile( ent, trace );					ent->s.eFlags |= eFlags;				}				ent->target_ent = other;				return;			}		}	}#endif	// impact damage	if (other->takedamage) {#else	if(other->takedamage)		hitKnife = qtrue;	// check for bounce	if ( ( ent->s.eFlags & ( EF_BOUNCE | EF_BOUNCE_HALF ) ) ) {		G_BounceMissile( ent, trace );		return;	}	if (other->takedamage && ent->s.weapon != WP_DYNAMITE) {#endif		// FIXME: wrong damage direction?		if ( ent->damage ) {			vec3_t	velocity;			if( LogAccuracyHit( other, &g_entities[ent->r.ownerNum] ) ) {				g_entities[ent->r.ownerNum].client->accuracy_hits++;				hitClient = qtrue;			}			BG_EvaluateTrajectoryDelta( &ent->s.pos, level.time, velocity );			if ( VectorLength( velocity ) == 0 ) {				velocity[2] = 1;	// stepped on a grenade			}#ifndef SMOKINGUNS			G_Damage (other, ent, &g_entities[ent->r.ownerNum], velocity,				ent->s.origin, ent->damage,				0, ent->methodOfDeath);#else			// you can't make dynamite exploding by using a knife			if(!(ent->s.weapon == WP_KNIFE && other->s.weapon == WP_DYNAMITE &&				other->s.eType == ET_ITEM)){				// prepare breakable, if not already initialized				if(!(other->flags & FL_BREAKABLE_INIT))					G_BreakablePrepare(other, shaderNum);				G_Damage (other, ent, &g_entities[ent->r.ownerNum], velocity,					ent->s.origin, ent->damage,					0, ent->methodOfDeath);			}#endif		}	}#ifndef SMOKINGUNS	if( ent->s.weapon == WP_PROX_LAUNCHER ) {		if( ent->s.pos.trType != TR_GRAVITY ) {			return;		}//.........这里部分代码省略.........
开发者ID:OADoctor,项目名称:SmokinGuns,代码行数:101,


示例24: NPC_Jump

static qboolean NPC_Jump( vec3_t dest, int goalEntNum ){//FIXME: if land on enemy, knock him down & jump off again	float	targetDist, travelTime, impactDist, bestImpactDist = Q3_INFINITE;//fireSpeed, 	float originalShotSpeed, shotSpeed, speedStep = 50.0f, minShotSpeed = 30.0f, maxShotSpeed = 500.0f;	qboolean belowBlocked = qfalse, aboveBlocked = qfalse;	vec3_t	targetDir, shotVel, failCase; 	trace_t	trace;	trajectory_t	tr;	qboolean	blocked;	int		elapsedTime, timeStep = 250, hitCount = 0, aboveTries = 0, belowTries = 0, maxHits = 10;	vec3_t	lastPos, testPos, bottom;	VectorSubtract( dest, NPC->r.currentOrigin, targetDir );	targetDist = VectorNormalize( targetDir );	//make our shotSpeed reliant on the distance	originalShotSpeed = targetDist;//DistanceHorizontal( dest, NPC->currentOrigin )/2.0f;	if ( originalShotSpeed > maxShotSpeed )	{		originalShotSpeed = maxShotSpeed;	}	else if ( originalShotSpeed < minShotSpeed )	{		originalShotSpeed = minShotSpeed;	}	shotSpeed = originalShotSpeed;	while ( hitCount < maxHits )	{		VectorScale( targetDir, shotSpeed, shotVel );		travelTime = targetDist/shotSpeed;		shotVel[2] += travelTime * 0.5 * NPC->client->ps.gravity;		if ( !hitCount )				{//save the first one as the worst case scenario			VectorCopy( shotVel, failCase );		}		if ( 1 )//tracePath )		{//do a rough trace of the path			blocked = qfalse;			VectorCopy( NPC->r.currentOrigin, tr.trBase );			VectorCopy( shotVel, tr.trDelta );			tr.trType = TR_GRAVITY;			tr.trTime = level.time;			travelTime *= 1000.0f;			VectorCopy( NPC->r.currentOrigin, lastPos );						//This may be kind of wasteful, especially on long throws... use larger steps?  Divide the travelTime into a certain hard number of slices?  Trace just to apex and down?			for ( elapsedTime = timeStep; elapsedTime < floor(travelTime)+timeStep; elapsedTime += timeStep )			{				if ( (float)elapsedTime > travelTime )				{//cap it					elapsedTime = floor( travelTime );				}				BG_EvaluateTrajectory( &tr, level.time + elapsedTime, testPos );				//FUCK IT, always check for do not enter...				trap_Trace( &trace, lastPos, NPC->r.mins, NPC->r.maxs, testPos, NPC->s.number, NPC->clipmask|CONTENTS_BOTCLIP );				/*				if ( testPos[2] < lastPos[2] 					&& elapsedTime < floor( travelTime ) )				{//going down, haven't reached end, ignore botclip					gi.trace( &trace, lastPos, NPC->mins, NPC->maxs, testPos, NPC->s.number, NPC->clipmask );				}				else				{//going up, check for botclip					gi.trace( &trace, lastPos, NPC->mins, NPC->maxs, testPos, NPC->s.number, NPC->clipmask|CONTENTS_BOTCLIP );				}				*/				if ( trace.allsolid || trace.startsolid )				{//started in solid					if ( NAVDEBUG_showCollision )					{						G_DrawEdge( lastPos, trace.endpos, EDGE_RED_TWOSECOND );					}					return qfalse;//you're hosed, dude				}				if ( trace.fraction < 1.0f )				{//hit something					if ( NAVDEBUG_showCollision )					{						G_DrawEdge( lastPos, trace.endpos, EDGE_RED_TWOSECOND );	// TryJump					}					if ( trace.entityNum == goalEntNum )					{//hit the enemy, that's bad!						blocked = qtrue;						/*						if ( g_entities[goalEntNum].client && g_entities[goalEntNum].client->ps.groundEntityNum == ENTITYNUM_NONE )						{//bah, would collide in mid-air, no good							blocked = qtrue;						}						else						{//he's on the ground, good enough, I guess							//Hmm, don't want to land on him, though...?						}						*/						break;					}					else //.........这里部分代码省略.........
开发者ID:jwginge,项目名称:ojpa,代码行数:101,


示例25: G_RunMissile

/*================G_RunMissile================*/void G_RunMissile( gentity_t *ent ) {    vec3_t		origin, groundSpot;    trace_t		tr;    int			passent;    qboolean	isKnockedSaber = qfalse;    if (ent->neverFree && ent->s.weapon == WP_SABER && (ent->flags & FL_BOUNCE_HALF))    {        isKnockedSaber = qtrue;        ent->s.pos.trType = TR_GRAVITY;    }    // get current position    BG_EvaluateTrajectory( &ent->s.pos, level.time, origin );    // if this missile bounced off an invulnerability sphere    if ( ent->target_ent ) {        passent = ent->target_ent->s.number;    }    else {        // ignore interactions with the missile owner        if ( (ent->r.svFlags&SVF_OWNERNOTSHARED)                && (ent->s.eFlags&EF_JETPACK_ACTIVE) )        {   //A vehicle missile that should be solid to its owner            //I don't care about hitting my owner            passent = ent->s.number;        }        else        {            passent = ent->r.ownerNum;        }    }    // trace a line from the previous position to the current position    if (d_projectileGhoul2Collision.integer)    {        trap->Trace( &tr, ent->r.currentOrigin, ent->r.mins, ent->r.maxs, origin, passent, ent->clipmask, qfalse, G2TRFLAG_DOGHOULTRACE|G2TRFLAG_GETSURFINDEX|G2TRFLAG_THICK|G2TRFLAG_HITCORPSES, g_g2TraceLod.integer );        if (tr.fraction != 1.0 && tr.entityNum < ENTITYNUM_WORLD)        {            gentity_t *g2Hit = &g_entities[tr.entityNum];            if (g2Hit->inuse && g2Hit->client && g2Hit->ghoul2)            {   //since we used G2TRFLAG_GETSURFINDEX, tr.surfaceFlags will actually contain the index of the surface on the ghoul2 model we collided with.                g2Hit->client->g2LastSurfaceHit = tr.surfaceFlags;                g2Hit->client->g2LastSurfaceTime = level.time;            }            if (g2Hit->ghoul2)            {                tr.surfaceFlags = 0; //clear the surface flags after, since we actually care about them in here.            }        }    }    else    {        trap->Trace( &tr, ent->r.currentOrigin, ent->r.mins, ent->r.maxs, origin, passent, ent->clipmask, qfalse, 0, 0 );    }    if ( tr.startsolid || tr.allsolid ) {        // make sure the tr.entityNum is set to the entity we're stuck in        trap->Trace( &tr, ent->r.currentOrigin, ent->r.mins, ent->r.maxs, ent->r.currentOrigin, passent, ent->clipmask, qfalse, 0, 0 );        tr.fraction = 0;    }    else {        VectorCopy( tr.endpos, ent->r.currentOrigin );    }    if (ent->passThroughNum && tr.entityNum == (ent->passThroughNum-1))    {        VectorCopy( origin, ent->r.currentOrigin );        trap->LinkEntity( (sharedEntity_t *)ent );        goto passthrough;    }    trap->LinkEntity( (sharedEntity_t *)ent );    if (ent->s.weapon == G2_MODEL_PART && !ent->bounceCount)    {        vec3_t lowerOrg;        trace_t trG;        VectorCopy(ent->r.currentOrigin, lowerOrg);        lowerOrg[2] -= 1;        trap->Trace( &trG, ent->r.currentOrigin, ent->r.mins, ent->r.maxs, lowerOrg, passent, ent->clipmask, qfalse, 0, 0 );        VectorCopy(trG.endpos, groundSpot);        if (!trG.startsolid && !trG.allsolid && trG.entityNum == ENTITYNUM_WORLD)        {            ent->s.groundEntityNum = trG.entityNum;        }        else        {            ent->s.groundEntityNum = ENTITYNUM_NONE;        }//.........这里部分代码省略.........
开发者ID:Mauii,项目名称:Rend2,代码行数:101,


示例26: G_RunMissile

/*================G_RunMissile================*/void G_RunMissile( gentity_t *ent ) {	vec3_t		origin;	trace_t		tr;	int			passent;	// get current position	BG_EvaluateTrajectory( &ent->s.pos, level.time, origin );	// if this missile bounced off an invulnerability sphere	if ( ent->target_ent ) {		passent = ent->target_ent->s.number;	}#ifdef MISSIONPACK	// prox mines that left the owner bbox will attach to anything, even the owner	else if (ent->s.weapon == WP_PROX_LAUNCHER && ent->count) {		passent = ENTITYNUM_NONE;	}#endif	else {		// ignore interactions with the missile owner		passent = ent->r.ownerNum;	}	// trace a line from the previous position to the current position	trap_Trace( &tr, ent->r.currentOrigin, ent->r.mins, ent->r.maxs, origin, passent, ent->clipmask );	if ( tr.startsolid || tr.allsolid ) {		// make sure the tr.entityNum is set to the entity we're stuck in		trap_Trace( &tr, ent->r.currentOrigin, ent->r.mins, ent->r.maxs, ent->r.currentOrigin, passent, ent->clipmask );		tr.fraction = 0;	}	else {		VectorCopy( tr.endpos, ent->r.currentOrigin );	}	trap_LinkEntity( ent );	if ( tr.fraction != 1 ) {		// never explode or bounce on sky		if ( tr.surfaceFlags & SURF_NOIMPACT ) {			// If grapple, reset owner			if (ent->parent && ent->parent->client && ent->parent->client->hook == ent) {				ent->parent->client->hook = NULL;			}			G_FreeEntity( ent );			return;		}		G_MissileImpact( ent, &tr );		if ( ent->s.eType != ET_MISSILE ) {			return;		// exploded		}	}#ifdef MISSIONPACK	// if the prox mine wasn't yet outside the player body	if (ent->s.weapon == WP_PROX_LAUNCHER && !ent->count) {		// check if the prox mine is outside the owner bbox		trap_Trace( &tr, ent->r.currentOrigin, ent->r.mins, ent->r.maxs, ent->r.currentOrigin, ENTITYNUM_NONE, ent->clipmask );		if (!tr.startsolid || tr.entityNum != ent->r.ownerNum) {			ent->count = 1;		}	}#endif	// check think function after bouncing	G_RunThink( ent );}
开发者ID:aSneakyCow,项目名称:WWC,代码行数:69,


示例27: G_RunMissile

void G_RunMissile( gentity_t *ent ) {	vector3		origin, groundSpot;	trace_t		tr;	int			passent;	qboolean	isKnockedSaber = qfalse;	if ( ent->neverFree && ent->s.weapon == WP_SABER && (ent->flags & FL_BOUNCE_HALF) ) {		isKnockedSaber = qtrue;		ent->s.pos.trType = TR_GRAVITY;	}	// get current position	BG_EvaluateTrajectory( &ent->s.pos, level.time, &origin );	// if this missile bounced off an invulnerability sphere	if ( ent->target_ent ) {		passent = ent->target_ent->s.number;	}	else {		// ignore interactions with the missile owner		if ( (ent->r.svFlags&SVF_OWNERNOTSHARED)			&& (ent->s.eFlags&EF_JETPACK_ACTIVE) ) {//A vehicle missile that should be solid to its owner			//I don't care about hitting my owner			passent = ent->s.number;		}		else {			passent = ent->r.ownerNum;		}	}	// trace a line from the previous position to the current position	if ( d_projectileGhoul2Collision.integer ) {		trap->Trace( &tr, &ent->r.currentOrigin, &ent->r.mins, &ent->r.maxs, &origin, passent, ent->clipmask, qfalse, G2TRFLAG_DOGHOULTRACE | G2TRFLAG_GETSURFINDEX | G2TRFLAG_THICK | G2TRFLAG_HITCORPSES, g_g2TraceLod.integer );		if ( tr.fraction != 1.0f && tr.entityNum < ENTITYNUM_WORLD ) {			gentity_t *g2Hit = &g_entities[tr.entityNum];			if ( g2Hit->inuse && g2Hit->client && g2Hit->ghoul2 ) { //since we used G2TRFLAG_GETSURFINDEX, tr.surfaceFlags will actually contain the index of the surface on the ghoul2 model we collided with.				g2Hit->client->g2LastSurfaceHit = tr.surfaceFlags;				g2Hit->client->g2LastSurfaceTime = level.time;			}			if ( g2Hit->ghoul2 ) {				tr.surfaceFlags = 0; //clear the surface flags after, since we actually care about them in here.			}			//Raz: Portals!			if ( g2Hit->s.eType == ET_SPECIAL && g2Hit->s.userInt1 ) {				if ( g2Hit->touch ) {					g2Hit->touch( g2Hit, ent, &tr );				}				JPLua::Entity_CallFunction( g2Hit, JPLua::JPLUA_ENTITY_TOUCH, (intptr_t)ent, (intptr_t)&tr );				goto passthrough;			}		}	}	else {		trap->Trace( &tr, &ent->r.currentOrigin, &ent->r.mins, &ent->r.maxs, &origin, passent, ent->clipmask, qfalse, 0, 0 );	}	if ( tr.startsolid || tr.allsolid ) {		// make sure the tr.entityNum is set to the entity we're stuck in		trap->Trace( &tr, &ent->r.currentOrigin, &ent->r.mins, &ent->r.maxs, &ent->r.currentOrigin, passent, ent->clipmask, qfalse, 0, 0 );		tr.fraction = 0;	}	else {		VectorCopy( &tr.endpos, &ent->r.currentOrigin );	}	if ( ent->passThroughNum && tr.entityNum == (ent->passThroughNum - 1) ) {		VectorCopy( &origin, &ent->r.currentOrigin );		trap->LinkEntity( (sharedEntity_t *)ent );		goto passthrough;	}	trap->LinkEntity( (sharedEntity_t *)ent );	if ( ent->s.weapon == G2_MODEL_PART && !ent->bounceCount ) {		vector3 lowerOrg;		trace_t trG;		VectorCopy( &ent->r.currentOrigin, &lowerOrg );		lowerOrg.z -= 1;		trap->Trace( &trG, &ent->r.currentOrigin, &ent->r.mins, &ent->r.maxs, &lowerOrg, passent, ent->clipmask, qfalse, 0, 0 );		VectorCopy( &trG.endpos, &groundSpot );		if ( !trG.startsolid && !trG.allsolid && trG.entityNum == ENTITYNUM_WORLD ) {			ent->s.groundEntityNum = trG.entityNum;		}		else {			ent->s.groundEntityNum = ENTITYNUM_NONE;		}	}	if ( ent->parent && ent->parent->client && ent->parent->client->hook && ent->parent->client->hook == ent		&& (ent->parent->client->ps.duelInProgress		|| BG_SaberInSpecial( ent->parent->client->ps.saberMove )		|| !(japp_allowHook.integer & (1 << level.gametype))		|| ent->parent->client->pers.adminData.isSlept		|| g_entities[tr.entityNum].client) )//.........这里部分代码省略.........
开发者ID:Arcadiaprime,项目名称:japp,代码行数:101,


示例28: CG_AddDebrisElements

/*================CG_AddDebrisElements================*/void CG_AddDebrisElements( localEntity_t *le ) {	vec3_t	newOrigin;	trace_t	trace;	float	lifeFrac;	int		t, step = 50;	for (t = le->lastTrailTime + step; t < cg.time; t += step) {		// calculate new position		BG_EvaluateTrajectory( &le->pos, t, newOrigin );		// trace a line from previous position to new position		CG_Trace( &trace, le->refEntity.origin, NULL, NULL, newOrigin, -1, MASK_SHOT );		// if stuck, kill it		if (trace.startsolid) {			// HACK, some walls screw up, so just pass through if starting in a solid			VectorCopy( newOrigin, trace.endpos );			trace.fraction = 1.0;		}		// moved some distance		VectorCopy( trace.endpos, le->refEntity.origin );		// add a trail		lifeFrac = (float)(t - le->startTime) / (float)(le->endTime - le->startTime);#if 0		// fire#if 1	// flame		if (le->effectWidth > 0) {			le->headJuncIndex = CG_AddSparkJunc( le->headJuncIndex,										cgs.media.fireTrailShader,										le->refEntity.origin,										(int)(500.0 * (0.5 + 0.5*(1.0 - lifeFrac))),	// trail life										1.0,	// alpha										0.5,	// end alpha										3,		// start width										le->effectWidth );	// end width#else	// spark line		if (le->effectWidth > 0) {			le->headJuncIndex = CG_AddSparkJunc( le->headJuncIndex,										cgs.media.sparkParticleShader,										le->refEntity.origin,										(int)(600.0 * (0.5 + 0.5*(0.5 - lifeFrac))),	// trail life										1.0 - lifeFrac*2,	// alpha										0.5 * (1.0 - lifeFrac),	// end alpha										5.0 * (1.0 - lifeFrac),	// start width										5.0 * (1.0 - lifeFrac) );	// end width#endif		}#endif		// smoke		if (le->effectFlags & 1)		{			le->headJuncIndex2 = CG_AddSmokeJunc( le->headJuncIndex2,										cgs.media.smokeTrailShader,										le->refEntity.origin,										(int)(2000.0 * (0.5 + 0.5*(1.0 - lifeFrac))),	// trail life										1.0 * (trace.fraction == 1.0) * (0.5 + 0.5 * (1.0 - lifeFrac)),	// alpha										1,		// start width										(int)(60.0 * (0.5 + 0.5*(1.0 - lifeFrac))) );	// end width		}		// if it is in a nodrop zone, remove it		// this keeps gibs from waiting at the bottom of pits of death		// and floating levels//		if ( trap_CM_PointContents( trace.endpos, 0 ) & CONTENTS_NODROP ) {//			CG_FreeLocalEntity( le );//			return;//		}		if (trace.fraction < 1.0) {			// reflect the velocity on the trace plane			CG_ReflectVelocity( le, &trace );			if (VectorLength(le->pos.trDelta) < 1) {				CG_FreeLocalEntity( le );				return;			}			// the intersection is a fraction of the frametime			le->pos.trTime = t;		}		le->lastTrailTime = t;	}}// Rafael Shrapnel/*===============CG_AddShrapnel===============*/void CG_AddShrapnel (localEntity_t *le) //.........这里部分代码省略.........
开发者ID:natelo,项目名称:rtcwPub,代码行数:101,


示例29: CG_AddFragment

/*================CG_AddFragment================*/void CG_AddFragment( localEntity_t *le ) {	vec3_t	newOrigin;	trace_t	trace;	if (le->forceAlpha)	{		le->refEntity.renderfx |= RF_FORCE_ENT_ALPHA;		le->refEntity.shaderRGBA[3] = le->forceAlpha;	}	if ( le->pos.trType == TR_STATIONARY ) {		// sink into the ground if near the removal time		int		t;		float	t_e;				t = le->endTime - cg.time;		if ( t < (SINK_TIME*2) ) {			le->refEntity.renderfx |= RF_FORCE_ENT_ALPHA;			t_e = (float)((float)(le->endTime - cg.time)/(SINK_TIME*2));			t_e = (int)((t_e)*255);			if (t_e > 255)			{				t_e = 255;			}			if (t_e < 1)			{				t_e = 1;			}			if (le->refEntity.shaderRGBA[3] && t_e > le->refEntity.shaderRGBA[3])			{				t_e = le->refEntity.shaderRGBA[3];			}			le->refEntity.shaderRGBA[3] = t_e;			trap->R_AddRefEntityToScene( &le->refEntity );		} else {			trap->R_AddRefEntityToScene( &le->refEntity );		}		return;	}	// calculate new position	BG_EvaluateTrajectory( &le->pos, cg.time, newOrigin );	// trace a line from previous position to new position	CG_Trace( &trace, le->refEntity.origin, NULL, NULL, newOrigin, -1, CONTENTS_SOLID );	if ( trace.fraction == 1.0 ) {		// still in free fall		VectorCopy( newOrigin, le->refEntity.origin );		if ( le->leFlags & LEF_TUMBLE ) {			vec3_t angles;			BG_EvaluateTrajectory( &le->angles, cg.time, angles );			AnglesToAxis( angles, le->refEntity.axis );			ScaleModelAxis(&le->refEntity);		}		trap->R_AddRefEntityToScene( &le->refEntity );		// add a blood trail		if ( le->leBounceSoundType == LEBS_BLOOD ) {			CG_BloodTrail( le );		}		return;	}	// if it is in a nodrop zone, remove it	// this keeps gibs from waiting at the bottom of pits of death	// and floating levels	if ( trap->CM_PointContents( trace.endpos, 0 ) & CONTENTS_NODROP ) {		CG_FreeLocalEntity( le );		return;	}	if (!trace.startsolid)	{		// leave a mark		CG_FragmentBounceMark( le, &trace );		// do a bouncy sound		CG_FragmentBounceSound( le, &trace );		if (le->bounceSound)		{ //specified bounce sound (debris)			trap->S_StartSound(le->pos.trBase, ENTITYNUM_WORLD, CHAN_AUTO, le->bounceSound);		}		// reflect the velocity on the trace plane		CG_ReflectVelocity( le, &trace );//.........这里部分代码省略.........
开发者ID:CaptainSkyhawk,项目名称:OpenJK-VR,代码行数:101,


示例30: CG_BloodTrail

// use this to change between particle and trail code//#define BLOOD_PARTICLE_TRAILvoid CG_BloodTrail( localEntity_t *le ) {	int		t;	int		t2;	int		step;	vec3_t	newOrigin;#ifndef BLOOD_PARTICLE_TRAIL	static vec3_t col = {1,1,1};#endifcentity_t	*cent;cent = &cg_entities[le->ownerNum];	if ( !cg_blood.integer ) {		return;	}	// step = 150;#ifdef BLOOD_PARTICLE_TRAIL	step = 10;#else	// time it takes to move 3 units	step = (1000*3)/VectorLength(le->pos.trDelta);#endif	if (cent && cent->currentState.aiChar == AICHAR_ZOMBIE)		step = 30;	t = step * ( (cg.time - cg.frametime + step ) / step );	t2 = step * ( cg.time / step );	for ( ; t <= t2; t += step ) {		BG_EvaluateTrajectory( &le->pos, t, newOrigin );		#ifdef BLOOD_PARTICLE_TRAIL		CG_Particle_Bleed (cgs.media.smokePuffShader, newOrigin, vec3_origin, 0, 500+rand()%200);#else							if (cent && cent->currentState.aiChar == AICHAR_ZOMBIE)		{			CG_Particle_Bleed (cgs.media.smokePuffShader, newOrigin, vec3_origin, 1, 500+rand()%200);		}		else		// Ridah, blood trail using trail code (should be faster since we don't have to spawn as many)		le->headJuncIndex = CG_AddTrailJunc( le->headJuncIndex,									cgs.media.bloodTrailShader,									t,									STYPE_STRETCH,									newOrigin,									180,									1.0,	// start alpha									0.0,	// end alpha									12.0,									12.0,									TJFL_NOCULL,									col, col,									0, 0 );#endif	}}
开发者ID:natelo,项目名称:rtcwPub,代码行数:64,



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


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