本文整理汇总了C++中BG_EvaluateTrajectory函数的典型用法代码示例。如果您正苦于以下问题:C++ BG_EvaluateTrajectory函数的具体用法?C++ BG_EvaluateTrajectory怎么用?C++ BG_EvaluateTrajectory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BG_EvaluateTrajectory函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:LoudHoward,项目名称:Quake3,代码行数:25,代码来源:bg_misc.c
示例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,代码来源:cg_luaentity.c
示例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 );
}
开发者ID:3ddy,项目名称:Jedi-Outcast,代码行数:50,代码来源:g_missile.c
示例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,代码来源:cg_localents.c
示例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,代码来源:cg_localents.c
示例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;
}
}
开发者ID:KuehnhammerTobias,项目名称:ioqw,代码行数:28,代码来源:cg_localents.c
示例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,代码来源:lua_mover.c
示例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 );
}
开发者ID:MilitaryForces,项目名称:MilitaryForces,代码行数:45,代码来源:cg_event.c
示例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,代码来源:lua_mover.c
示例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,代码来源:cg_localents.cpp
示例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);
}
}
开发者ID:AlienHoboken,项目名称:Tremulous-Z-Server,代码行数:37,代码来源:g_missile.c
示例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 );
}
开发者ID:Mauii,项目名称:Rend2,代码行数:43,代码来源:g_missile.c
示例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,代码来源:cg_localents.cpp
示例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,代码来源:cg_localents.c
示例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,代码来源:cg_localents.c
示例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,代码来源:cg_localents.c
示例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,代码来源:g_turret.c
示例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,代码来源:g_missile.c
示例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,代码来源:g_object.cpp
示例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, ð32.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, ð32.cg.media.fontArial, true);
}
开发者ID:rabb,项目名称:eth32nix-rabbmod,代码行数:76,代码来源:CCam.cpp
注:本文中的BG_EvaluateTrajectory函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论