本文整理汇总了C++中BG_EvaluateTrajectory函数的典型用法代码示例。如果您正苦于以下问题:C++ BG_EvaluateTrajectory函数的具体用法?C++ BG_EvaluateTrajectory怎么用?C++ BG_EvaluateTrajectory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BG_EvaluateTrajectory函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BG_PlayerTouchesItem
/*
============
BG_PlayerTouchesItem
Items can be picked up without actually touching their physical bounds to make
grabbing 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;
}
示例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;
}
示例3: G_ExplodeMissile
/*
================
G_ExplodeMissile
Explode 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 );
}
示例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 );
}
示例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);
}
示例6: CG_BloodTrail
/*
=======================================================================================================================================
CG_BloodTrail
Leave 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;
}
}
示例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;
}
示例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( ¢->currentState.pos, cg.snap->serverTime, cent->lerpOrigin );
CG_SetEntitySoundPosition( cent );
CG_EntityEvent( cent, cent->lerpOrigin );
}
示例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;
}
示例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 );
}
示例11: G_minethink
void
G_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);
}
}
示例12: G_ExplodeMissile
/*
================
G_ExplodeMissile
Explode 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 );
}
示例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 );
}
示例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;
}
}
}
示例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;
//.........这里部分代码省略.........