本文整理汇总了C++中VectorCopy函数的典型用法代码示例。如果您正苦于以下问题:C++ VectorCopy函数的具体用法?C++ VectorCopy怎么用?C++ VectorCopy使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了VectorCopy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UI_DrawPlayer
/*
===============
UI_DrawPlayer
===============
*/
void UI_DrawPlayer( float x, float y, float w, float h, playerInfo_t *pi, int time ) {
refdef_t refdef;
refEntity_t legs;
refEntity_t torso;
refEntity_t head;
refEntity_t gun;
refEntity_t barrel;
refEntity_t flash;
vec3_t origin;
int renderfx;
vec3_t mins = {-16, -16, -24};
vec3_t maxs = {16, 16, 32};
float len;
float xx;
float xscale;
float yscale;
if ( !pi->legsModel || !pi->torsoModel || !pi->headModel || !pi->animations[0].numFrames ) {
return;
}
dp_realtime = time;
if ( pi->pendingWeapon != WP_NUM_WEAPONS && dp_realtime > pi->weaponTimer ) {
pi->weapon = pi->pendingWeapon;
pi->lastWeapon = pi->pendingWeapon;
pi->pendingWeapon = WP_NUM_WEAPONS;
pi->weaponTimer = 0;
if( pi->currentWeapon != pi->weapon ) {
trap_S_StartLocalSound( weaponChangeSound, CHAN_LOCAL );
}
}
CG_AdjustFrom640( &x, &y, &w, &h );
y -= jumpHeight;
memset( &refdef, 0, sizeof( refdef ) );
memset( &legs, 0, sizeof(legs) );
memset( &torso, 0, sizeof(torso) );
memset( &head, 0, sizeof(head) );
refdef.rdflags = RDF_NOWORLDMODEL;
AxisClear( refdef.viewaxis );
refdef.x = x;
refdef.y = y;
refdef.width = w;
refdef.height = h;
if ( ui_stretch.integer ) {
xscale = cgs.screenXScaleStretch;
yscale = cgs.screenYScaleStretch;
} else {
xscale = cgs.screenXScale;
yscale = cgs.screenYScale;
}
refdef.fov_x = (int)((float)refdef.width / xscale / 640.0f * 90.0f);
xx = refdef.width / xscale / tan( refdef.fov_x / 360 * M_PI );
refdef.fov_y = atan2( refdef.height / yscale, xx );
refdef.fov_y *= ( 360 / M_PI );
// calculate distance so the player nearly fills the box
len = 0.7 * ( maxs[2] - mins[2] );
origin[0] = len / tan( DEG2RAD(refdef.fov_x) * 0.5 );
origin[1] = 0.5 * ( mins[1] + maxs[1] );
origin[2] = -0.5 * ( mins[2] + maxs[2] );
refdef.time = dp_realtime;
trap_R_ClearScene();
// get the rotation information
UI_PlayerAngles( pi, legs.axis, torso.axis, head.axis );
// get the animation state (after rotation, to allow feet shuffle)
UI_PlayerAnimation( pi, &legs.oldframe, &legs.frame, &legs.backlerp,
&torso.oldframe, &torso.frame, &torso.backlerp );
renderfx = RF_LIGHTING_ORIGIN | RF_NOSHADOW;
//
// add the legs
//
legs.hModel = pi->legsModel;
legs.customSkin = CG_AddSkinToFrame( &pi->modelSkin );
VectorCopy( origin, legs.origin );
VectorCopy( origin, legs.lightingOrigin );
legs.renderfx = renderfx;
VectorCopy (legs.origin, legs.oldorigin);
//.........这里部分代码省略.........
示例2: target_laser_think
void target_laser_think (edict_t *self)
{
edict_t *ignore;
vec3_t start;
vec3_t end;
trace_t tr;
vec3_t point;
vec3_t last_movedir;
int count;
if (self->spawnflags & 0x80000000)
count = 8;
else
count = 4;
if (self->enemy)
{
VectorCopy (self->movedir, last_movedir);
VectorMA (self->enemy->absmin, 0.5, self->enemy->size, point);
VectorSubtract (point, self->s.origin, self->movedir);
VectorNormalize (self->movedir);
if (!VectorCompare(self->movedir, last_movedir))
self->spawnflags |= 0x80000000;
}
ignore = self;
VectorCopy (self->s.origin, start);
VectorMA (start, 2048, self->movedir, end);
while(1)
{
tr = gi.trace (start, NULL, NULL, end, ignore, CONTENTS_SOLID|CONTENTS_MONSTER|CONTENTS_DEADMONSTER);
VectorCopy (tr.endpos,self->moveinfo.end_origin);
if (!tr.ent)
break;
// hurt it if we can
if ((tr.ent->takedamage) && !(tr.ent->flags & FL_IMMUNE_LASER))
T_Damage (tr.ent, self, self->activator, self->movedir, tr.endpos, vec3_origin, self->dmg, 1, DAMAGE_ENERGY, MOD_TARGET_LASER);
// if we hit something that's not a monster or player or is immune to lasers, we're done
if (!(tr.ent->svflags & SVF_MONSTER) && (!tr.ent->client))
{
if (self->spawnflags & 0x80000000)
{
self->spawnflags &= ~0x80000000;
gi.WriteByte (svc_temp_entity);
gi.WriteByte (TE_LASER_SPARKS);
gi.WriteByte (count);
gi.WritePosition (tr.endpos);
gi.WriteDir (tr.plane.normal);
gi.WriteByte (self->s.skinnum);
gi.multicast (tr.endpos, MULTICAST_PVS);
}
break;
}
ignore = tr.ent;
VectorCopy (tr.endpos, start);
}
VectorCopy (tr.endpos, self->s.old_origin);
self->nextthink = level.time + FRAMETIME;
}
示例3: BotUpdateEntityItems
void BotUpdateEntityItems() {
int ent, i, modelindex;
vec3_t dir;
levelitem_t* li, * nextli;
aas_entityinfo_t entinfo;
itemconfig_t* ic;
//timeout current entity items if necessary
for ( li = levelitems; li; li = nextli ) {
nextli = li->next;
//if it is a item that will time out
if ( li->timeout ) {
//timeout the item
if ( li->timeout < AAS_Time() ) {
RemoveLevelItemFromList( li );
FreeLevelItem( li );
} //end if
} //end if
} //end for
//find new entity items
ic = itemconfig;
if ( !itemconfig ) {
return;
}
//
for ( ent = AAS_NextEntity( 0 ); ent; ent = AAS_NextEntity( ent ) ) {
if ( AAS_EntityType( ent ) != Q3ET_ITEM ) {
continue;
}
//get the model index of the entity
modelindex = AAS_EntityModelindex( ent );
//
if ( !modelindex ) {
continue;
}
//get info about the entity
AAS_EntityInfo( ent, &entinfo );
//FIXME: don't do this
//skip all floating items for now
if ( !( GGameType & GAME_Quake3 ) && entinfo.groundent != Q3ENTITYNUM_WORLD ) {
continue;
}
//if the entity is still moving
if ( entinfo.origin[ 0 ] != entinfo.lastvisorigin[ 0 ] ||
entinfo.origin[ 1 ] != entinfo.lastvisorigin[ 1 ] ||
entinfo.origin[ 2 ] != entinfo.lastvisorigin[ 2 ] ) {
continue;
}
//check if the entity is already stored as a level item
for ( li = levelitems; li; li = li->next ) {
if ( GGameType & GAME_Quake3 ) {
//if the level item is linked to an entity
if ( li->entitynum && li->entitynum == ent ) {
//the entity is re-used if the models are different
if ( ic->iteminfo[ li->iteminfo ].modelindex != modelindex ) {
//remove this level item
RemoveLevelItemFromList( li );
FreeLevelItem( li );
li = NULL;
break;
} else {
if ( entinfo.origin[ 0 ] != li->origin[ 0 ] ||
entinfo.origin[ 1 ] != li->origin[ 1 ] ||
entinfo.origin[ 2 ] != li->origin[ 2 ] ) {
VectorCopy( entinfo.origin, li->origin );
//also update the goal area number
li->goalareanum = AAS_BestReachableArea( li->origin,
ic->iteminfo[ li->iteminfo ].mins, ic->iteminfo[ li->iteminfo ].maxs,
li->goalorigin );
}
break;
}
}
} else {
//if the model of the level item and the entity are different
if ( ic->iteminfo[ li->iteminfo ].modelindex != modelindex ) {
continue;
}
//if the level item is linked to an entity
if ( li->entitynum ) {
if ( li->entitynum == ent ) {
VectorCopy( entinfo.origin, li->origin );
break;
} //end if
} //end if
else {
//check if the entity is very close
VectorSubtract( li->origin, entinfo.origin, dir );
if ( VectorLength( dir ) < 30 ) {
//found an entity for this level item
li->entitynum = ent;
//keep updating the entity origin
VectorCopy( entinfo.origin, li->origin );
//also update the goal area number
li->goalareanum = AAS_BestReachableArea( li->origin,
ic->iteminfo[ li->iteminfo ].mins, ic->iteminfo[ li->iteminfo ].maxs,
li->goalorigin );
//Log_Write("found item %s entity", ic->iteminfo[li->iteminfo].classname);
break;
} //end if
//.........这里部分代码省略.........
示例4: BotGetLevelItemGoalQ3
int BotGetLevelItemGoalQ3( int index, const char* name, bot_goal_q3_t* goal ) {
if ( !itemconfig ) {
return -1;
}
levelitem_t* li = levelitems;
if ( index >= 0 ) {
for (; li; li = li->next ) {
if ( li->number == index ) {
li = li->next;
break;
}
}
}
for (; li; li = li->next ) {
if ( GGameType & GAME_WolfSP ) {
if ( g_gametype == Q3GT_SINGLE_PLAYER ) {
if ( li->flags & IFL_NOTSINGLE ) {
continue;
}
} else if ( g_gametype >= Q3GT_TEAM ) {
if ( li->flags & IFL_NOTTEAM ) {
continue;
}
} else {
if ( li->flags & IFL_NOTFREE ) {
continue;
}
}
} else if ( GGameType & GAME_WolfMP ) {
if ( g_gametype == Q3GT_SINGLE_PLAYER ) {
if ( li->flags & IFL_NOTSINGLE ) {
continue;
}
} else if ( g_gametype >= Q3GT_TEAM ) {
if ( li->flags & IFL_NOTTEAM ) {
continue;
}
} else {
if ( li->flags & IFL_NOTFREE ) {
continue;
}
}
} else {
if ( g_gametype == Q3GT_SINGLE_PLAYER ) {
if ( li->flags & IFL_NOTSINGLE ) {
continue;
}
} else if ( g_gametype >= Q3GT_TEAM ) {
if ( li->flags & IFL_NOTTEAM ) {
continue;
}
} else {
if ( li->flags & IFL_NOTFREE ) {
continue;
}
}
if ( li->flags & IFL_NOTBOT ) {
continue;
}
}
if ( !String::ICmp( name, itemconfig->iteminfo[ li->iteminfo ].name ) ) {
goal->areanum = li->goalareanum;
VectorCopy( li->goalorigin, goal->origin );
goal->entitynum = li->entitynum;
VectorCopy( itemconfig->iteminfo[ li->iteminfo ].mins, goal->mins );
VectorCopy( itemconfig->iteminfo[ li->iteminfo ].maxs, goal->maxs );
goal->number = li->number;
if ( GGameType & GAME_Quake3 ) {
goal->flags = GFL_ITEM;
if ( li->timeout ) {
goal->flags |= GFL_DROPPED;
}
}
return li->number;
}
}
return -1;
}
示例5: BotAIStartFrame
//.........这里部分代码省略.........
trap_BotLibUpdateEntity(i, NULL);
continue;
}
if (!ent->r.linked) {
trap_BotLibUpdateEntity(i, NULL);
continue;
}
if (ent->r.svFlags & SVF_NOCLIENT) {
trap_BotLibUpdateEntity(i, NULL);
continue;
}
// do not update missiles
if (ent->s.eType == ET_MISSILE && ent->s.weapon != WP_GRAPPLING_HOOK) {
trap_BotLibUpdateEntity(i, NULL);
continue;
}
// do not update event only entities
if (ent->s.eType > ET_EVENTS) {
trap_BotLibUpdateEntity(i, NULL);
continue;
}
#ifdef MISSIONPACK
// never link prox mine triggers
if (ent->r.contents == CONTENTS_TRIGGER) {
if (ent->touch == ProximityMine_Trigger) {
trap_BotLibUpdateEntity(i, NULL);
continue;
}
}
#endif
//
memset(&state, 0, sizeof(bot_entitystate_t));
//
VectorCopy(ent->r.currentOrigin, state.origin);
if (i < MAX_CLIENTS) {
VectorCopy(ent->s.apos.trBase, state.angles);
} else {
VectorCopy(ent->r.currentAngles, state.angles);
}
VectorCopy(ent->s.origin2, state.old_origin);
VectorCopy(ent->r.mins, state.mins);
VectorCopy(ent->r.maxs, state.maxs);
state.type = ent->s.eType;
state.flags = ent->s.eFlags;
if (ent->r.bmodel) state.solid = SOLID_BSP;
else state.solid = SOLID_BBOX;
state.groundent = ent->s.groundEntityNum;
state.modelindex = ent->s.modelindex;
state.modelindex2 = ent->s.modelindex2;
state.frame = ent->s.frame;
state.event = ent->s.event;
state.eventParm = ent->s.eventParm;
state.powerups = ent->s.powerups;
state.legsAnim = ent->s.legsAnim;
state.torsoAnim = ent->s.torsoAnim;
state.weapon = ent->s.weapon;
//
trap_BotLibUpdateEntity(i, &state);
}
BotAIRegularUpdate();
}
floattime = trap_AAS_Time();
// execute scheduled bot AI
示例6: CL_GetMessage
/*
====================
CL_GetMessage
Handles recording and playback of demos, on top of NET_ code
====================
*/
int CL_GetMessage (void)
{
int r, i;
float f;
if (cls.demoplayback)
{
// decide if it is time to grab the next message
if (cls.signon == SIGNONS) // allways grab until fully connected
{
if (cls.timedemo)
{
if (host_framecount == cls.td_lastframe)
return 0; // allready read this frame's message
cls.td_lastframe = host_framecount;
// if this is the second frame, grab the real td_starttime
// so the bogus time on the first frame doesn't count
if (host_framecount == cls.td_startframe + 1)
cls.td_starttime = realtime;
}
else if ( /* cl.time > 0 && */ cl.time <= cl.mtime[0])
{
return 0; // don't need another message yet
}
}
// get the next message
fread (&net_message.cursize, 4, 1, cls.demofile);
VectorCopy (cl.mviewangles[0], cl.mviewangles[1]);
for (i=0 ; i<3 ; i++)
{
r = fread (&f, 4, 1, cls.demofile);
cl.mviewangles[0][i] = LittleFloat (f);
}
net_message.cursize = LittleLong (net_message.cursize);
if (net_message.cursize > MAX_MSGLEN)
Sys_Error ("Demo message > MAX_MSGLEN");
r = fread (net_message.data, net_message.cursize, 1, cls.demofile);
if (r != 1)
{
CL_StopPlayback ();
return 0;
}
return 1;
}
while (1)
{
r = NET_GetMessage (cls.netcon);
if (r != 1 && r != 2)
return r;
// discard nop keepalive message
if (net_message.cursize == 1 && net_message.data[0] == svc_nop)
Con_Printf ("<-- server to client keepalive\n");
else
break;
}
if (cls.demorecording)
CL_WriteDemoMessage ();
return r;
}
示例7: Drag_Begin
/*
===========
Drag_Begin
===========
*/
void Drag_Begin (int x, int y, int buttons,
vec3_t xaxis, vec3_t yaxis,
vec3_t origin, vec3_t dir)
{
trace_t t;
drag_ok = false;
VectorCopy (vec3_origin, pressdelta);
VectorCopy (vec3_origin, vPressStart);
drag_first = true;
peLink = NULL;
// shift LBUTTON = select entire brush
if (buttons == (MK_LBUTTON | MK_SHIFT) && g_qeglobals.d_select_mode != sel_curvepoint)
{
int nFlag = (static_cast<bool>(::GetAsyncKeyState(VK_MENU))) ? SF_CYCLE : 0;
if (dir[0] == 0 || dir[1] == 0 || dir[2] == 0) // extremely low chance of this happening from camera
Select_Ray (origin, dir, nFlag | SF_ENTITIES_FIRST); // hack for XY
else
Select_Ray (origin, dir, nFlag);
return;
}
// ctrl-shift LBUTTON = select single face
if (buttons == (MK_LBUTTON | MK_CONTROL | MK_SHIFT) && g_qeglobals.d_select_mode != sel_curvepoint)
{
Select_Deselect ();
Select_Ray (origin, dir, SF_SINGLEFACE);
return;
}
// LBUTTON + all other modifiers = manipulate selection
if (buttons & MK_LBUTTON)
{
Drag_Setup (x, y, buttons, xaxis, yaxis, origin, dir);
return;
}
int nMouseButton = g_PrefsDlg.m_nMouseButtons == 2 ? MK_RBUTTON : MK_MBUTTON;
// middle button = grab texture
if (buttons == nMouseButton)
{
t = Test_Ray (origin, dir, false);
if (t.face)
{
g_qeglobals.d_new_brush_bottom_z = t.brush->mins[2];
g_qeglobals.d_new_brush_top_z = t.brush->maxs[2];
Texture_SetTexture (&t.face->texdef);
UpdateSurfaceDialog();
UpdatePatchInspector();
}
else
Sys_Printf ("Did not select a texture\n");
return;
}
// ctrl-middle button = set entire brush to texture
if (buttons == (nMouseButton|MK_CONTROL) )
{
t = Test_Ray (origin, dir, false);
if (t.brush)
{
if (t.brush->brush_faces->texdef.name[0] == '(')
Sys_Printf ("Can't change an entity texture\n");
else
{
Brush_SetTexture (t.brush, &g_qeglobals.d_texturewin.texdef, false, false);
Sys_UpdateWindows (W_ALL);
}
}
else
Sys_Printf ("Didn't hit a btrush\n");
return;
}
// ctrl-shift-middle button = set single face to texture
if (buttons == (nMouseButton|MK_SHIFT|MK_CONTROL) )
{
t = Test_Ray (origin, dir, false);
if (t.brush)
{
if (t.brush->brush_faces->texdef.name[0] == '(')
Sys_Printf ("Can't change an entity texture\n");
else
{
SetFaceTexdef (t.brush, t.face, &g_qeglobals.d_texturewin.texdef, false, false);
Brush_Build( t.brush );
Sys_UpdateWindows (W_ALL);
}
}
else
Sys_Printf ("Didn't hit a btrush\n");
return;
}
//.........这里部分代码省略.........
示例8: MoveSelection
//.........这里部分代码省略.........
v[2] = 0.9;
}
Select_Scale((g_nScaleHow & SCALE_X) ? v[0] : 1.0,
(g_nScaleHow & SCALE_Y) ? v[1] : 1.0,
(g_nScaleHow & SCALE_Z) ? v[2] : 1.0);
Sys_UpdateWindows (W_ALL);
return;
}
vec3_t vDistance;
VectorSubtract(pressdelta, vPressStart, vDistance);
strStatus.Format("Distance x: %.1f y: %.1f z: %.1f", vDistance[0], vDistance[1], vDistance[2]);
g_pParentWnd->SetStatusText(3, strStatus);
//
// dragging only a part of the selection
//
// this is fairly crappy way to deal with curvepoint and area selection
// but it touches the smallest amount of code this way
//
if (g_qeglobals.d_num_move_points || g_qeglobals.d_select_mode == sel_area)
{
if (g_qeglobals.d_select_mode == sel_area)
{
VectorAdd(g_qeglobals.d_vAreaBR, move, g_qeglobals.d_vAreaBR);
return;
}
if (g_qeglobals.d_select_mode == sel_curvepoint)
{
Patch_UpdateSelected(move);
return;
}
else
{
for (i=0 ; i<g_qeglobals.d_num_move_points ; i++)
VectorAdd (g_qeglobals.d_move_points[i], move, g_qeglobals.d_move_points[i]);
}
//VectorScale(move, .5, move);
//for (i=0 ; i<g_qeglobals.d_num_move_points2 ; i++)
// VectorAdd (g_qeglobals.d_move_points2[i], move, g_qeglobals.d_move_points2[i]);
for (b=selected_brushes.next ; b != &selected_brushes ; b=b->next)
{
VectorCopy(b->maxs, vTemp);
VectorSubtract(vTemp, b->mins, vTemp);
Brush_Build( b );
for (i=0 ; i<3 ; i++)
if (b->mins[i] > b->maxs[i]
|| b->maxs[i] - b->mins[i] > WORLD_SIZE)
break; // dragged backwards or fucked up
if (i != 3)
break;
if (b->patchBrush)
{
VectorCopy(b->maxs, vTemp2);
VectorSubtract(vTemp2, b->mins, vTemp2);
VectorSubtract(vTemp2, vTemp, vTemp2);
if (!Patch_DragScale(b->nPatchID, vTemp2, move))
{
b = NULL;
break;
}
}
}
// if any of the brushes were crushed out of existance
// calcel the entire move
if (b != &selected_brushes)
{
Sys_Printf ("Brush dragged backwards, move canceled\n");
for (i=0 ; i<g_qeglobals.d_num_move_points ; i++)
VectorSubtract (g_qeglobals.d_move_points[i], move, g_qeglobals.d_move_points[i]);
for (b=selected_brushes.next ; b != &selected_brushes ; b=b->next)
Brush_Build( b );
}
}
else
{
//
// if there are lots of brushes selected, just translate instead
// of rebuilding the brushes
//
if (drag_yvec[2] == 0 && selected_brushes.next->next != &selected_brushes)
{
Select_Move (move);
//VectorAdd (g_qeglobals.d_select_translate, move, g_qeglobals.d_select_translate);
}
else
{
Select_Move (move);
}
}
}
示例9: GetWindspeedAtTime
//-----------------------------------------------------------------------------
// Method to sample the windspeed at a particular time
//-----------------------------------------------------------------------------
void GetWindspeedAtTime( float flTime, Vector &vecVelocity )
{
// For now, ignore history and time.. fix later when we use wind to affect
// client-side prediction
VectorCopy( s_vecWindVelocity, vecVelocity );
}
示例10: CLH2_UpdateStreams
void CLH2_UpdateStreams() {
h2stream_t* stream = clh2_Streams;
for ( int streamIndex = 0; streamIndex < MAX_STREAMS_H2; streamIndex++, stream++ ) {
if ( !stream->models[ 0 ] ) {
// Inactive
continue;
}
if ( stream->endTime < cl.serverTime ) {
// Inactive
if ( stream->type != H2TE_STREAM_LIGHTNING && stream->type != H2TE_STREAM_LIGHTNING_SMALL ) {
continue;
} else if ( stream->endTime + 250 < cl.serverTime ) {
continue;
}
}
if ( stream->flags & H2STREAM_ATTACHED && stream->endTime >= cl.serverTime ) {
// Attach the start position to owner
h2entity_state_t* state = CLH2_FindState( stream->entity );
if ( state ) {
VectorAdd( state->origin, stream->offset, stream->source );
}
}
vec3_t dist;
VectorSubtract( stream->dest, stream->source, dist );
vec3_t angles;
VecToAnglesBuggy( dist, angles );
vec3_t org;
VectorCopy( stream->source, org );
float d = VectorNormalize( dist );
vec3_t right, up;
float cosTime, sinTime, lifeTime, cos2Time, sin2Time;
if ( ( GGameType & GAME_HexenWorld ) && stream->type == H2TE_STREAM_SUNSTAFF2 ) {
vec3_t discard;
AngleVectors( angles, discard, right, up );
lifeTime = ( stream->endTime - cl.serverTime ) / 800.0f;
cosTime = cos( cl.serverTime * 0.001 * 5 );
sinTime = sin( cl.serverTime * 0.001 * 5 );
cos2Time = cos( cl.serverTime * 0.001 * 5 + 3.14 );
sin2Time = sin( cl.serverTime * 0.001 * 5 + 3.14 );
}
int segmentCount = 0;
if ( stream->type == H2TE_STREAM_ICECHUNKS ) {
int offset = ( cl.serverTime / 25 ) % 30;
for ( int i = 0; i < 3; i++ ) {
org[ i ] += dist[ i ] * offset;
}
}
while ( d > 0 ) {
refEntity_t ent;
Com_Memset( &ent, 0, sizeof ( ent ) );
ent.reType = RT_MODEL;
VectorCopy( org, ent.origin );
ent.hModel = stream->models[ 0 ];
switch ( stream->type ) {
case H2TE_STREAM_CHAIN:
angles[ 2 ] = 0;
CLH2_SetRefEntAxis( &ent, angles, oldvec3_origin, 0, 128, H2MLS_ABSLIGHT );
R_AddRefEntityToScene( &ent );
break;
case H2TE_STREAM_SUNSTAFF1:
angles[ 2 ] = ( cl.serverTime / 100 ) % 360;
if ( GGameType & GAME_HexenWorld ) {
CLH2_SetRefEntAxis( &ent, angles, oldvec3_origin, 50 + ( stream->endTime - cl.serverTime ) / 3, 128, H2MLS_ABSLIGHT );
} else {
CLH2_SetRefEntAxis( &ent, angles, oldvec3_origin, 0, 128, H2MLS_ABSLIGHT );
}
R_AddRefEntityToScene( &ent );
Com_Memset( &ent, 0, sizeof ( ent ) );
ent.reType = RT_MODEL;
VectorCopy( org, ent.origin );
ent.hModel = stream->models[ 1 ];
angles[ 2 ] = ( cl.serverTime / 20 ) % 360;
if ( GGameType & GAME_HexenWorld ) {
CLH2_SetRefEntAxis( &ent, angles, oldvec3_origin, 50 + ( stream->endTime - cl.serverTime ) * 0.2f, 128, H2MLS_ABSLIGHT | H2DRF_TRANSLUCENT );
} else {
CLH2_SetRefEntAxis( &ent, angles, oldvec3_origin, 0, 128, H2MLS_ABSLIGHT | H2DRF_TRANSLUCENT );
}
R_AddRefEntityToScene( &ent );
break;
case H2TE_STREAM_SUNSTAFF2:
if ( !( GGameType & GAME_HexenWorld ) ) {
angles[ 2 ] = ( cl.serverTime / 100 ) % 360;
ent.frame = ( cl.serverTime / 100 ) % 8;
CLH2_SetRefEntAxis( &ent, angles, oldvec3_origin, 0, 128, H2MLS_ABSLIGHT );
R_AddRefEntityToScene( &ent );
} else {
angles[ 2 ] = ( int )( cl.serverTime * 0.001 * 100 ) % 360;
VectorMA( ent.origin, cosTime * ( 40 * lifeTime ), right, ent.origin );
VectorMA( ent.origin, sinTime * ( 40 * lifeTime ), up, ent.origin );
CLH2_SetRefEntAxis( &ent, angles, oldvec3_origin, 100 + 150 * lifeTime, 128, H2MLS_ABSLIGHT | H2DRF_TRANSLUCENT );
R_AddRefEntityToScene( &ent );
//.........这里部分代码省略.........
示例11: LoadJTRAIL
//.........这里部分代码省略.........
clean_count = 0;
message[0]='\0';
lbuf2 = strlen(buf2);
while (buf2[lbuf2-1] == '\r' || buf2[lbuf2-1] == '\n')
{
buf2[lbuf2-1] = 0;
lbuf2--;
}
start[0] = start[1] = start[2] = color = mass = 0;
if (ltnodes <= traillimit->value)
{
laser = G_Spawn();
// laser->owner = ent;
ltnodes++;
laser->classnum = jtrail_num_lines+1;//ltnodes;
laser->classname = "LaserTrailLink";
laser->s.frame = 4;
VectorSet (laser->mins, -8, -8, -8);
VectorSet (laser->maxs, 8, 8, 8);
//Load Coords
token = strtok( buf2, tok );
start[0] = atoi(token);
token = strtok( NULL, tok );
if ((token == NULL) && pdm)
break;
start[1] = atoi(token);
token = strtok( NULL, tok );
start[2] = atoi(token);
VectorCopy(start,laser->s.origin);
if (pdm)
{
if (colorp == -1)
laser->s.skinnum = NUMtoCOLOR(1); //color (green)
else
laser->s.skinnum = NUMtoCOLOR(colorp);
if (sizep == -1)
laser->s.frame = 4; //size
else
laser->s.frame = sizep;
laser->mass = ltrails; //num (never gonna be multiple paths to load this way)
}
else
{
//Load Color
token = strtok( NULL, tok );
color = atoi(token);
laser->s.skinnum = color;
//Load Size
token = strtok( NULL, tok );
color = atoi(token);
laser->s.frame = color;
//Load Gravity
token = strtok( NULL, tok );
color = atoi(token);
if (lasttrailnum != color)
{
示例12: ClientThink
/*
==============
ClientThink
This will be called once for each client frame, which will
usually be a couple times for each server frame.
==============
*/
void ClientThink (edict_t *ent, usercmd_t *ucmd)
{
gclient_t *client;
edict_t *other;
int i, j;
pmove_t pm;
level.current_entity = ent;
client = ent->client;
if (level.intermissiontime)
{
client->ps.pmove.pm_type = PM_FREEZE;
// can exit intermission after five seconds
if (level.time > level.intermissiontime + 5.0
&& (ucmd->buttons & BUTTON_ANY) )
level.exitintermission = true;
return;
}
pm_passent = ent;
if (ent->client->chase_target) {
client->resp.cmd_angles[0] = SHORT2ANGLE(ucmd->angles[0]);
client->resp.cmd_angles[1] = SHORT2ANGLE(ucmd->angles[1]);
client->resp.cmd_angles[2] = SHORT2ANGLE(ucmd->angles[2]);
} else {
// set up for pmove
memset (&pm, 0, sizeof(pm));
if (ent->movetype == MOVETYPE_NOCLIP)
client->ps.pmove.pm_type = PM_SPECTATOR;
else if (ent->s.modelindex != 255)
client->ps.pmove.pm_type = PM_GIB;
else if (ent->deadflag)
client->ps.pmove.pm_type = PM_DEAD;
else
client->ps.pmove.pm_type = PM_NORMAL;
client->ps.pmove.gravity = sv_gravity->value;
pm.s = client->ps.pmove;
for (i=0 ; i<3 ; i++)
{
pm.s.origin[i] = ent->s.origin[i]*8;
pm.s.velocity[i] = ent->velocity[i]*8;
}
if (memcmp(&client->old_pmove, &pm.s, sizeof(pm.s)))
{
pm.snapinitial = true;
// gi.dprintf ("pmove changed!\n");
}
pm.cmd = *ucmd;
pm.trace = PM_trace; // adds default parms
pm.pointcontents = gi.pointcontents;
// perform a pmove
gi.Pmove (&pm);
// save results of pmove
client->ps.pmove = pm.s;
client->old_pmove = pm.s;
for (i=0 ; i<3 ; i++)
{
ent->s.origin[i] = pm.s.origin[i]*0.125;
ent->velocity[i] = pm.s.velocity[i]*0.125;
}
VectorCopy (pm.mins, ent->mins);
VectorCopy (pm.maxs, ent->maxs);
client->resp.cmd_angles[0] = SHORT2ANGLE(ucmd->angles[0]);
client->resp.cmd_angles[1] = SHORT2ANGLE(ucmd->angles[1]);
client->resp.cmd_angles[2] = SHORT2ANGLE(ucmd->angles[2]);
if (ent->groundentity && !pm.groundentity && (pm.cmd.upmove >= 10) && (pm.waterlevel == 0))
{
gi.sound(ent, CHAN_VOICE, gi.soundindex("*jump1.wav"), 1, ATTN_NORM, 0);
PlayerNoise(ent, ent->s.origin, PNOISE_SELF);
}
ent->viewheight = pm.viewheight;
ent->waterlevel = pm.waterlevel;
ent->watertype = pm.watertype;
//.........这里部分代码省略.........
示例13: PutClientInServer
/*
===========
PutClientInServer
Called when a player connects to a server or respawns in
a deathmatch.
============
*/
void PutClientInServer (edict_t *ent)
{
vec3_t mins = {-16, -16, -24};
vec3_t maxs = {16, 16, 32};
int index;
vec3_t spawn_origin, spawn_angles;
gclient_t *client;
int i;
client_persistant_t saved;
client_respawn_t resp;
// find a spawn point
// do it before setting health back up, so farthest
// ranging doesn't count this client
SelectSpawnPoint (ent, spawn_origin, spawn_angles);
index = ent-g_edicts-1;
client = ent->client;
// deathmatch wipes most client data every spawn
if (deathmatch->value)
{
char userinfo[MAX_INFO_STRING];
resp = client->resp;
memcpy (userinfo, client->pers.userinfo, sizeof(userinfo));
InitClientPersistant (client);
ClientUserinfoChanged (ent, userinfo);
}
else if (coop->value)
{
// int n;
char userinfo[MAX_INFO_STRING];
resp = client->resp;
memcpy (userinfo, client->pers.userinfo, sizeof(userinfo));
// this is kind of ugly, but it's how we want to handle keys in coop
// for (n = 0; n < game.num_items; n++)
// {
// if (itemlist[n].flags & IT_KEY)
// resp.coop_respawn.inventory[n] = client->pers.inventory[n];
// }
resp.coop_respawn.game_helpchanged = client->pers.game_helpchanged;
resp.coop_respawn.helpchanged = client->pers.helpchanged;
client->pers = resp.coop_respawn;
ClientUserinfoChanged (ent, userinfo);
if (resp.score > client->pers.score)
client->pers.score = resp.score;
}
else
{
memset (&resp, 0, sizeof(resp));
}
// clear everything but the persistant data
saved = client->pers;
memset (client, 0, sizeof(*client));
client->pers = saved;
if (client->pers.health <= 0)
InitClientPersistant(client);
client->resp = resp;
// copy some data from the client to the entity
FetchClientEntData (ent);
// clear entity values
ent->groundentity = NULL;
ent->client = &game.clients[index];
ent->takedamage = DAMAGE_AIM;
ent->movetype = MOVETYPE_WALK;
ent->viewheight = 22;
ent->inuse = true;
ent->classname = "player";
ent->mass = 200;
ent->solid = SOLID_BBOX;
ent->deadflag = DEAD_NO;
ent->air_finished = level.time + 12;
ent->clipmask = MASK_PLAYERSOLID;
ent->model = "players/male/tris.md2";
ent->pain = player_pain;
ent->die = player_die;
ent->waterlevel = 0;
ent->watertype = 0;
ent->flags &= ~FL_NO_KNOCKBACK;
ent->svflags &= ~SVF_DEADMONSTER;
VectorCopy (mins, ent->mins);
VectorCopy (maxs, ent->maxs);
VectorClear (ent->velocity);
// clear playerstate values
memset (&ent->client->ps, 0, sizeof(client->ps));
//.........这里部分代码省略.........
示例14: CGCam_Update
void CGCam_Update( void )
{
int i;
qboolean checkFollow = qfalse;
qboolean checkTrack = qfalse;
// Apply new roff data to the camera as needed
if ( client_camera.info_state & CAMERA_ROFFING )
{
CGCam_Roff();
}
//Check for a zoom
if ( client_camera.info_state & CAMERA_ZOOMING )
{
float actualFOV_X;
if ( client_camera.FOV_time + client_camera.FOV_duration < cg.time )
{
actualFOV_X = client_camera.FOV = client_camera.FOV2;
client_camera.info_state &= ~CAMERA_ZOOMING;
}
else
{
actualFOV_X = client_camera.FOV + (( ( client_camera.FOV2 - client_camera.FOV ) ) / client_camera.FOV_duration ) * ( cg.time - client_camera.FOV_time );
}
CG_CalcFOVFromX( actualFOV_X );
}
else
{
CG_CalcFOVFromX( client_camera.FOV );
}
//Check for pan
if ( client_camera.info_state & CAMERA_PANNING )
{
//Note: does not actually change the camera's angles until the pan time is done!
if ( client_camera.pan_time + client_camera.pan_duration < cg.time )
{//finished panning
for ( i = 0; i < 3; i++ )
{
client_camera.angles[i] = AngleNormalize360( ( client_camera.angles[i] + client_camera.angles2[i] ) );
}
client_camera.info_state &= ~CAMERA_PANNING;
VectorCopy(client_camera.angles, cg.refdefViewAngles );
}
else
{//still panning
for ( i = 0; i < 3; i++ )
{
//NOTE: does not store the resultant angle in client_camera.angles until pan is done
cg.refdefViewAngles[i] = client_camera.angles[i] + ( client_camera.angles2[i] / client_camera.pan_duration ) * ( cg.time - client_camera.pan_time );
}
}
}
else
{
checkFollow = qtrue;
}
AnglesToAxis( cg.refdefViewAngles, cg.refdef.viewaxis );
//Check for movement
if ( client_camera.info_state & CAMERA_MOVING )
{
//NOTE: does not actually move the camera until the movement time is done!
if ( client_camera.move_time + client_camera.move_duration < cg.time )
{
VectorCopy( client_camera.origin2, client_camera.origin );
client_camera.info_state &= ~CAMERA_MOVING;
VectorCopy( client_camera.origin, cg.refdef.vieworg );
}
else
{
for ( i = 0; i < 3; i++ )
cg.refdef.vieworg[i] = client_camera.origin[i] + (( ( client_camera.origin2[i] - client_camera.origin[i] ) ) / client_camera.move_duration ) * ( cg.time - client_camera.move_time );
}
}
else
{
checkTrack = qtrue;
}
if ( checkFollow )
{
if ( client_camera.info_state & CAMERA_FOLLOWING )
{//This needs to be done after camera movement
CGCam_FollowUpdate();
}
VectorCopy(client_camera.angles, cg.refdefViewAngles );
}
if ( checkTrack )
{
if ( client_camera.info_state & CAMERA_TRACKING )
{//This has to run AFTER Follow if the camera is following a cameraGroup
CGCam_TrackUpdate();
}
//.........这里部分代码省略.........
示例15: Drag_Setup
/*
===========
Drag_Setup
===========
*/
void Drag_Setup (int x, int y, int buttons,
vec3_t xaxis, vec3_t yaxis,
vec3_t origin, vec3_t dir)
{
trace_t t;
face_t *f;
drag_first = true;
VectorCopy (vec3_origin, pressdelta);
pressx = x;
pressy = y;
VectorCopy (xaxis, drag_xvec);
AxializeVector (drag_xvec);
VectorCopy (yaxis, drag_yvec);
AxializeVector (drag_yvec);
extern void SelectCurvePointByRay (vec3_t org, vec3_t dir, int buttons);
if (g_qeglobals.d_select_mode == sel_curvepoint)
{
//if ((buttons == MK_LBUTTON))
// g_qeglobals.d_num_move_points = 0;
SelectCurvePointByRay (origin, dir, buttons);
if (g_qeglobals.d_num_move_points || g_qeglobals.d_select_mode == sel_area)
{
drag_ok = true;
}
Sys_UpdateWindows(W_ALL);
return;
}
else
{
g_qeglobals.d_num_move_points = 0;
}
if (selected_brushes.next == &selected_brushes)
{
Sys_Status("No selection to drag\n", 0);
return;
}
if (g_qeglobals.d_select_mode == sel_vertex)
{
SelectVertexByRay (origin, dir);
if (g_qeglobals.d_num_move_points)
{
drag_ok = true;
return;
}
}
if (g_qeglobals.d_select_mode == sel_edge)
{
SelectEdgeByRay (origin, dir);
if (g_qeglobals.d_num_move_points)
{
drag_ok = true;
return;
}
}
//
// check for direct hit first
//
t = Test_Ray (origin, dir, true);
if (t.selected)
{
drag_ok = true;
if (buttons == (MK_LBUTTON|MK_CONTROL) )
{
Sys_Printf ("Shear dragging face\n");
Brush_SelectFaceForDragging (t.brush, t.face, true);
}
else if (buttons == (MK_LBUTTON|MK_CONTROL|MK_SHIFT) )
{
Sys_Printf ("Sticky dragging brush\n");
for (f=t.brush->brush_faces ; f ; f=f->next)
Brush_SelectFaceForDragging (t.brush, f, false);
}
else
Sys_Printf ("Dragging entire selection\n");
return;
}
if (g_qeglobals.d_select_mode == sel_vertex || g_qeglobals.d_select_mode == sel_edge)
//.........这里部分代码省略.........