/* ============== Chase_UpdateForDrawing -- johnfitz -- orient camera based on client. called before drawing TODO: stay at least 8 units away from all walls in this leaf ============== */ void Chase_UpdateForDrawing (void) { int i; vec3_t forward, up, right; vec3_t ideal, crosshair, temp; AngleVectors (cl.viewangles, forward, right, up); // calc ideal camera location before checking for walls for (i=0 ; i<3 ; i++) ideal[i] = cl.viewent.origin[i] - forward[i]*chase_back.value + right[i]*chase_right.value; //+ up[i]*chase_up.value; ideal[2] = cl.viewent.origin[2] + chase_up.value; // make sure camera is not in or behind a wall TraceLine(r_refdef.vieworg, ideal, temp); if (VectorLength(temp) != 0) VectorCopy(temp, ideal); // place camera VectorCopy (ideal, r_refdef.vieworg); // find the spot the player is looking at VectorMA (cl.viewent.origin, 4096, forward, temp); TraceLine (cl.viewent.origin, temp, crosshair); // calculate camera angles to look at the same spot VectorSubtract (crosshair, r_refdef.vieworg, temp); VectorAngles (temp, r_refdef.viewangles); if (r_refdef.viewangles[PITCH] == 90 || r_refdef.viewangles[PITCH] == -90) r_refdef.viewangles[YAW] = cl.viewangles[YAW]; }
void cmdHelp(unsigned int argc,char * argv [ ],int * result) { Trace("Hi, what can I do for you?"); TraceLine(); listCommands(argc, argv, result); TraceLine(); *result = true; }
// SyPB Pro P.21 - New Shootable Thru Obstacle bool Bot::IsShootableThruObstacle (Vector dest) { if (m_skill < 70) return false; int currentWeaponPenetrationPower = CorrectGun (m_currentWeapon); if (currentWeaponPenetrationPower == 0) return false; TraceResult tr; Vector source = EyePosition (); float obstacleDistance = 0.0f; TraceLine (source, dest, true, GetEntity (), &tr); if (tr.fStartSolid) { source = tr.vecEndPos; TraceLine (dest, source, true, GetEntity (), &tr); if (tr.flFraction != 1.0f) { if (((tr.vecEndPos - dest).GetLength ()) > 800) return false; // SyPB Pro P.22 - Strengthen Shootable Thru Obstacle if (tr.vecEndPos.z >= dest.z + 200) return false; obstacleDistance = (tr.vecEndPos - source).GetLength (); } } if (obstacleDistance > 0.0) { while (currentWeaponPenetrationPower > 0) { if (obstacleDistance > 75.0) { obstacleDistance -= 75.0f; currentWeaponPenetrationPower--; continue; } return true; } } return false; }
bool CGame::MouseInput(int iButton, tinker_mouse_state_t iState) { if (iButton == TINKER_KEY_MOUSE_LEFT && iState == TINKER_MOUSE_PRESSED) { Vector v0 = m_hPlayer->GetGlobalOrigin() + Vector(0, 1, 0); Vector v1 = m_hPlayer->GetGlobalOrigin() + Vector(0, 1, 0) + m_hPlayer->GetGlobalView() * 100; Vector vecIntersection; CCharacter* pHit = nullptr; if (TraceLine(v0, v1, vecIntersection, pHit)) { MakePuff(vecIntersection); MakeBulletTracer(v0, vecIntersection); if (pHit) { pHit->m_flShotTime = Game()->GetTime(); pHit->TakeDamage(1); } } else MakeBulletTracer(v0, v1); return true; } return false; }
void Chase_Update (void) { int i; float dist; vec3_t forward, up, right; vec3_t dest, stop; // if can't see player, reset AngleVectors (cl.viewangles, forward, right, up); // calc exact destination for (i=0 ; i<3 ; i++) chase_dest[i] = r_refdef.vieworg[i] - forward[i]*chase_back.value - right[i]*chase_right.value; chase_dest[2] = r_refdef.vieworg[2] + chase_up.value; // find the spot the player is looking at VectorMA (r_refdef.vieworg, 4096, forward, dest); TraceLine (r_refdef.vieworg, dest, stop); // calculate pitch to look at the same spot from camera VectorSubtract (stop, r_refdef.vieworg, stop); dist = DotProduct (stop, forward); if (dist < 1) dist = 1; r_refdef.viewangles[PITCH] = -atan(stop[2] / dist) / M_PI * 180; // move towards destination VectorCopy (chase_dest, r_refdef.vieworg); }
int GetNearCam(vec3_t org) { int i; vec3_t vec,stop; int min_num = 0; // = no near cam int min_dist = 9999999; for (i = 0; i < MAXCAMS; i++) { if(cams[i].used) { VectorSubtract (org, cams[i].org, vec); if (Length(vec) < min_dist) { //TODO: avoid that? if (TraceLine(org,cams[i].org,stop,stop)==1) { min_num = i; min_dist = Length(vec); } } } } return min_num; }
static void TraceScene(void) { VECTOR PixColor, Col, LinD, Scale; VECTOR LinD2, D; int sx, sy, i; Scale.y = 1.0; for( sy = 0; sy < HEIGHT; sy++ ) { Scale.z = ((double)(HEIGHT/2-sy))/(double)HEIGHT; for( sx = 0; sx < WIDTH; sx++ ) { Scale.x = ((double)(sx-WIDTH/2))/(double)WIDTH; /* Calculate line-direction (from camera-center through a pixel) */ LinD.x = Cameraright.x*Scale.x + Cameradir.x*Scale.y + Cameraup.x*Scale.z; LinD.y = Cameraright.y*Scale.x + Cameradir.y*Scale.y + Cameraup.y*Scale.z; LinD.z = Cameraright.z*Scale.x + Cameradir.z*Scale.y + Cameraup.z*Scale.z; /* Get color for pixel */ #if (DISTLEVELS > 0) PixColor.x = PixColor.y = PixColor.z = 0.0; for( i = 0; i < DISTRIB; i++ ) { DistribVector( &D, &LinD, 0.5/(double)WIDTH, 0.5/(double)HEIGHT ); LinD2 = LinD; LinD2.x += D.x; LinD2.y += D.y; LinD2.z += D.z; TraceLine( &Camerapos, &LinD2, &Col, MAXREC ); PixColor.x += Col.x; PixColor.y += Col.y; PixColor.z += Col.z; } ScaleVector( &PixColor, 1.0/DISTRIB ); #else TraceLine( &Camerapos, &LinD, &PixColor, MAXREC ); #endif memory[3*(sx+sy*WIDTH)]=(UBYTE)(PixColor.x*255.0); memory[3*(sx+sy*WIDTH)+1]=(UBYTE)(PixColor.y*255.0); memory[3*(sx+sy*WIDTH)+2]=(UBYTE)(PixColor.z*255.0); } } }
bool IsVisible (const Vector &origin, edict_t *ent) { if (FNullEnt (ent)) return false; TraceResult tr; TraceLine (GetEntityOrigin (ent) + ent->v.view_ofs, origin, true, true, ent, &tr); if (tr.flFraction != 1.0f) return false; // line of sight is not established return true; // line of sight is valid. }
void DrawFlares (void) { vec3_t stop,normal;//, start ; flares_t * flare; int i; float depth; // dlight_t * dl; if (r_coronas.value <= 0) return; glEnable( GL_DITHER );// Suggest by user, does not work, make particles green. for (i=1;i<MAX_FLARES;i++) { flare = &flares[i]; if ( flare->active ) { flare->active = false; switch( flare->mode) { case 1://forever (very rare) flare->active = true; default://Default wallhide // if(TTraceLine (r_refdef.vieworg, flare->origin, stop, normal)!=1) if (r_coronas_mode.value == 1) { depth = TraceLine(r_refdef.vieworg, flare->origin, stop, normal); if (depth != 1) break; } else if (r_coronas_mode.value == 2) { vec3_t out; ML_Project(flare->origin, out, r_refdef.viewangles, r_refdef.vieworg, ((float)vid.width/vid.height), r_refdef.fov_y); glReadPixels(out[0], out[1], 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth); if (depth < out[2]) break; } case 2://trough walls R_DrawCoronaColor(flare); break; } } } }
bool Bot::IsShootableThruObstacle (Vector dest) { // This function returns true if enemy can be shoot through some obstacle, false otherwise. if (m_skill <= 70u) return false; int currentWeaponPenetrationPower = CorrectGun (m_currentWeapon); if (currentWeaponPenetrationPower == 0) return false; // set conditions.... Vector source (EyePosition ()); const Vector &direction ((dest - source).Normalize () * 8.0f); // 8 units long TraceResult tr; do { // trace from the bot's eyes to destination... TraceLine (source, dest, true, GetEntity (), &tr); if (tr.fStartSolid) { if (tr.fAllSolid) return false; // move 8 units closer to the destination.... source += direction; } else { // check if line hit anything if (tr.flFraction == 1.0f) return true; --currentWeaponPenetrationPower; // move 8 units closer to the destination.... source = tr.vecEndPos + direction; } } while (currentWeaponPenetrationPower > 0); return false; }
// -------------------------------------------------------------------------- void CToolTipWnd::Show( int x, int y, int timerDelayToHide, int timerDelayToShow ) // force apparition of the tooltip { #ifdef DEBUG_ALL TraceLine( "CToolTipWnd::Show %s", cpcOverrideText ); #endif // Check to see if the tooltip has a portion outside the // screen, if so, adjust. if ( x < 0 ) x = 0; if ( y < 0 ) y = 0; RECT r; r.left = x; r.right = r.left + m_iWidth; r.top = y; r.bottom = r.top + m_iHeight; // Compare to screen coordinates ( don't take in account the desktop toolbar ) int screenHeight = GetSystemMetrics( SM_CYSCREEN ); if ( r.bottom > screenHeight ) r.top = screenHeight - ( m_iHeight ); int screenWidth = GetSystemMetrics( SM_CXSCREEN ); if ( r.right > screenWidth ) r.left = screenWidth - m_iWidth; // Move the window SetWindowPos( &wndTop, r.left, r.top, m_iWidth, m_iHeight, SWP_NOACTIVATE ); // Only show after show delay has passed // ShowWindow( SW_SHOWNOACTIVATE ); // Start the hide delay timer SetTimer( timerDelayToHide ); // Start the show delay timer SetShowTimer( timerDelayToShow ); }
void CToolTipWnd::Show( HWND hWnd, zCPCHAR cpcOverrideText, int timerDelayHide, int timerDelayShow ) { #ifdef DEBUG_ALL TraceLine( "CToolTipWnd::Show %s", cpcOverrideText ); #endif // Make sure the window is active. CWnd *pFocusWnd = AfxGetApp( )->m_pMainWnd->GetFocus( ); if ( pFocusWnd == 0 ) return; // If another one was present, hide it. Hide( ); // take the 'hWnd' coordinates and compute where the tooltip should appear RECT rect; ::GetWindowRect( hWnd, &rect ); POINT pt; pt.x = rect.left + ( ( rect.right - rect.left ) / 2 ); pt.y = rect.bottom; // Determine the text to dislay: 'cpcOverrideText' or original tooltip text if ( cpcOverrideText ) m_csText = cpcOverrideText; else { // Reset 'm_csText' to original from tooltip BTOOLINFO *stToolInfo; if ( m_toolPtr.Lookup( hWnd, ( void *& )stToolInfo ) ) m_csText = stToolInfo->strToolText; } // Make it appear at 'pt' if ( timerDelayHide <= 0 ) // don't permit a tooltip to stay forever timerDelayHide = m_iDelay; Show( pt.x, pt.y, timerDelayHide, timerDelayShow ); m_bSkipNextMove = true; // it seems we receive a WM_MOUSEMOVE whenever a window is displayed... m_pCurrwnd = hWnd; }
bool Bot::IsFriendInLineOfFire (float distance) { // bot can't hurt teammates, if friendly fire is not enabled... if (!engine->IsFriendlyFireOn ()) return false; MakeVectors (pev->v_angle); TraceResult tr; TraceLine (EyePosition (), EyePosition () + pev->v_angle.Normalize () * distance, false, false, GetEntity (), &tr); // check if we hit something if (!FNullEnt (tr.pHit)) { int playerIndex = ENTINDEX (tr.pHit) - 1; // check valid range if (playerIndex >= 0 && playerIndex < engine->GetMaxClients () && g_clients[playerIndex].team == GetTeam (GetEntity ()) && (g_clients[playerIndex].flags & CFLAG_ALIVE)) return true; } // search the world for players for (int i = 0; i < engine->GetMaxClients (); i++) { if (!(g_clients[i].flags & CFLAG_USED) || !(g_clients[i].flags & CFLAG_ALIVE) || g_clients[i].team != GetTeam (GetEntity ()) || g_clients[i].ent == GetEntity ()) continue; edict_t *ent = g_clients[i].ent; float friendDistance = (GetEntityOrigin (ent) - pev->origin).GetLength (); float squareDistance = sqrtf (1089.0f + (friendDistance * friendDistance)); if ((GetShootingConeDeviation (GetEntity (), &GetEntityOrigin (ent))) > ((friendDistance * friendDistance) / (squareDistance * squareDistance)) && friendDistance <= distance) return true; } return false; }
///////////////////////////////////////////////////////////////////////////// // // bSubcontrol - TRUE - add controls to existing pZSubtask->m_pZMIXCtrl // FALSE - delete existing pZSubtask->m_pZMIXCtrl and start // a new list // ///////////////////////////////////////////////////////////////////////////// void OPERATION CreateZeidonCtrls( zVIEW vSubobject, ZSubtask *pZSubtask, CWnd *pWndParent, ZMapAct *pzmaComposite, zSHORT nOffsetX, zSHORT nOffsetY, zBOOL bSubcontrol ) { zKZWDLGXO_Ctrl_DEF CtrlDef; zFARPROC_CONTROL lpfnCtrlProc; LPLIBRARY hCCtlLibrary; zPCHAR pchDLL_Name; zPCHAR pchCOP; zSHORT nRC; #ifdef DEBUG_ALL TraceLineX( "CreateZeidonCtrls parent - ", (zLONG) pZSubtask ); #endif nRC = CheckExistenceOfEntity( vSubobject, szlCtrl ); if ( bSubcontrol == FALSE ) { mDeleteInit( pZSubtask->m_pZMIXCtrl ); if ( nRC > zCURSOR_UNCHANGED ) { zLONG lTempCtrlCnt; // just to get the long temporarily GetIntegerFromAttribute( &lTempCtrlCnt, pZSubtask->m_vDialog, szlWnd, "CtrlCnt" ); // TraceLineI( "CreateZeidonCtrls count ", lTempCtrlCnt ); pZSubtask->m_pZMIXCtrl = new ZMultiIdxSet( (fnCOMPARE) fnCompareCtrlNodes, (fnCOMPARE) fnSeekCtrlNode, lTempCtrlCnt ); // Instead of having ZMultiIdxSet delete the nodes itself, we call // a recursive routine (fnDeleteCtrls) to guarantee the child // controls are deleted before their parents. } else pZSubtask->m_pZMIXCtrl = 0; CreateViewFromViewForTask( &(pZSubtask->m_vPE), pZSubtask->m_pZTask->m_vPE, pZSubtask->m_vDialog ); } #ifdef DEBUG_LODSTRUCT zmemset( CtrlDef.Tag, 0xFE, sizeof( CtrlDef ) ); // CtrlDef.CheckByte = 0xFE; #endif while ( nRC > zCURSOR_UNCHANGED ) { // Get the structure of attributes for this control. zPCHAR pch = 0; // for derived Text attribute GetStructFromEntityAttrs( (zPCHAR) CtrlDef.Tag, vSubobject, szlCtrl ); #ifdef DEBUG_LODSTRUCT if ( CtrlDef.CheckByte != 0xFE ) MessageBox( 0, "CtrlDef Structure Length Error", "GetStructFromEntityAttrs", MB_OK ); // zPCHAR pchCheckByte = (zPCHAR) &(CtrlDef.CheckByte); // pchCheckByte--; // if ( *pchCheckByte == (char) 0xFE ) // TraceLineS( "zdrctl CtrlDef CheckByte error??", "" ); #endif GetAddrForAttribute( (zPCHAR *) &pch, vSubobject, szlCtrl, szlD_Text ); if ( *pch ) zstrcpy( CtrlDef.Text, pch ); #ifdef DEBUG_ALL TraceLineS( "Tag ", CtrlDef.Tag ); TraceLineI( "Type ", CtrlDef.Type ); TraceLineI( "IdNbr ", CtrlDef.IdNbr ); TraceLineI( "PSDLG_X ", CtrlDef.PSDLG_X ); TraceLineI( "PSDLG_Y ", CtrlDef.PSDLG_Y ); TraceLineI( "SZDLG_X ", CtrlDef.SZDLG_X ); TraceLineI( "SZDLG_Y ", CtrlDef.SZDLG_Y ); #endif // The token is validated by the painter and/or conversion to // the executable object, but we check here anyway. nRC = SetCursorFirstEntityByInteger( pZSubtask->m_pZTask->m_vPE, szlCtrl, szlKey, CtrlDef.Type, 0 ); if ( nRC != zCURSOR_SET ) { TraceLine( "(drvr) ID (%d) not found (%d) in PPE for Ctrl: %s.%s.%s", CtrlDef.Type, nRC, pZSubtask->m_pzsDlgTag ? *(pZSubtask->m_pzsDlgTag) : "?", pZSubtask->m_pzsWndTag ? *(pZSubtask->m_pzsWndTag) : "?", CtrlDef.Tag ); DisplayEntityInstance( pZSubtask->m_pZTask->m_vPE, szlCtrl ); DisplayObjectInstance( pZSubtask->m_pZTask->m_vPE, 0, 0 ); // Skip this one and try the next. nRC = SetCursorNextEntity( vSubobject, szlCtrl, 0 ); continue; } GetAddrForAttribute( (zPCHAR *) &pchDLL_Name, pZSubtask->m_pZTask->m_vPE, szlCtrl, szlDLL ); GetAddrForAttribute( (zPCHAR *) &pchCOP, pZSubtask->m_pZTask->m_vPE, szlCtrl, szlCOP ); // If the DLL name is added to the list, this is the first time it // has been encountered ... so call its initialization routine. pZSubtask->m_pZTask->AddApplicationDLL( pZSubtask, pchDLL_Name ); hCCtlLibrary = 0; // set to zero for GetOperationDynamicCallAddress lpfnCtrlProc = (zFARPROC_CONTROL) GetOperationDynamicCallAddress( pZSubtask->m_vDialog, (LPLPLIBRARY) &hCCtlLibrary, pchDLL_Name, pchCOP, "(drvr) Ctrl" ); try { if ( lpfnCtrlProc ) // && (k % 2) == 0 ) { // TraceLineS( "Create Control: ", pchCOP ); (*lpfnCtrlProc)( pZSubtask, pWndParent, pzmaComposite, vSubobject, nOffsetX, nOffsetY, &CtrlDef ); } } #if 0 catch( CResourceException *e ) { zCHAR szMsg[ 256 ]; e->GetErrorMessage( szMsg, sizeof( szMsg ) ); zstrcat( szMsg, } #endif catch( CException *e ) { zCHAR szMsg[ 256 ]; e->GetErrorMessage( szMsg, sizeof( szMsg ) ); MessageSend( pZSubtask->m_vDialog, 0, "Zeidon Control", szMsg, zMSGQ_MODAL_ERROR, FALSE ); break; } nRC = SetCursorNextEntity( vSubobject, szlCtrl, 0 ); } // end of: while ( nRC == zCURSOR_UNCHANGED ) looping thru controls if ( bSubcontrol == FALSE ) { DropView( pZSubtask->m_vPE ); pZSubtask->m_vPE = 0; // using this to determine Ctrls have been created // Ctrl creation is complete ... notify each ctrl. if ( pZSubtask->m_pZMIXCtrl ) { pZSubtask->m_pZMIXCtrl->VisitInorder( (fnVISIT_INORDER) fnPostCreateCtrls, 0, 0, 0 ); } } }
void Chase_Update (void) { //TODO: reformulation int i, camavail; float dist; vec3_t forward, up, right, normal, out, bak; vec3_t dest, stop; camavail =0; // this need to be set to zero to all // if can't see player, reset if (chase_active.value == 1) AngleVectors (cl.viewangles, forward, right, up); //Tei chase zenit else if (chase_active.value == 2) { VectorClear(dest); dest[2] = -1; AngleVectors (dest, forward, right, up); } else { camavail = 0; //Backup vieworg VectorCopy(r_refdef.vieworg, bak); if (camavail = GetAliasCam(r_refdef.vieworg, out)) { VectorCopy(out, r_refdef.vieworg); AngleVectors (cams[camavail].angle, forward, right, up); } else { //Normal chase AngleVectors (cl.viewangles, forward, right, up); } } //Tei chase zenit if (chase_active.value == 4) // absolute values { chase_dest[0] = chase_right.value; chase_dest[1] = chase_back.value; chase_dest[2] = chase_up.value; } else { for (i=0 ; i<3 ; i++) // calc exact destination chase_dest[i] = r_refdef.vieworg[i] - forward[i]*chase_back.value - right[i]*chase_right.value; chase_dest[2] = r_refdef.vieworg[2] + chase_up.value; } // find the spot the player is looking at if (chase_active.value == 1 ) { VectorMA (r_refdef.vieworg, 4096, forward, dest); TraceLine (r_refdef.vieworg, dest, stop, normal); // calculate pitch to look at the same spot from camera VectorSubtract (stop, r_refdef.vieworg, stop); dist = DotProduct (stop, forward); if (dist < 1) dist = 1; //r_refdef.viewangles[PITCH] = -atan(stop[2] / dist) / M_PI * 180; r_refdef.viewangles[PITCH] = -stop[2] / dist / M_PI * 180; } //Tei chase zenit else if (chase_active.value == 2 || chase_active.value == 4) { r_refdef.viewangles[PITCH] = chase_pitch.value; r_refdef.viewangles[ROLL] = chase_roll.value; r_refdef.viewangles[YAW] = chase_yaw.value; } else if (chase_active.value == 3) { r_refdef.viewangles[PITCH] += chase_pitch.value; r_refdef.viewangles[ROLL] += chase_roll.value; r_refdef.viewangles[YAW] += chase_yaw.value; } else { if (camavail) { VectorSubtract( bak, r_refdef.vieworg ,normal); vectoangles(normal, r_refdef.viewangles);//out); r_refdef.viewangles[PITCH] = - r_refdef.viewangles[PITCH]; //VectorCopy(out, r_refdef.viewangles); } else { VectorMA (r_refdef.vieworg, 4096, forward, dest); TraceLine (r_refdef.vieworg, dest, stop, normal); // calculate pitch to look at the same spot from camera VectorSubtract (stop, r_refdef.vieworg, stop); dist = DotProduct (stop, forward); if (dist < 1) dist = 1; r_refdef.viewangles[PITCH] = -atan(stop[2] / dist) / M_PI * 180; } } //Tei chase zenit if ( !camavail) { // Tomaz - Chase Cam Fix Begin TraceLine(r_refdef.vieworg, chase_dest, stop, normal); if (stop[0] != 0 || stop[1] != 0 || stop[2] != 0) { // Entar : move the camera away from the wall it's hitting, so we don't see behind it VectorAdd(normal, stop, stop); VectorCopy(stop, chase_dest); } // Tomaz - Chase Cam Fix End TraceLine(r_refdef.vieworg, chase_dest, stop, normal); if (Length(stop) != 0) VectorCopy(stop, chase_dest); // move towards destination VectorCopy (chase_dest, r_refdef.vieworg); } }
// Show - Show the titletip if needed. // rectTitle - The rectangle within which the original title // is constrained - in client coordinates. // cpcTitleText - The text to be displayed. // nOffsetX - Number of pixels that the text is offset from // the left border of the cell. void ZTitleTip::Show( CRect rectTitle, zCPCHAR cpcTitleText, int nOffsetX /* = 0 */, LPRECT pHoverRect /* = 0 */, const LOGFONT *pLogFont /* = 0 */, COLORREF clrText /* = CLR_DEFAULT */, COLORREF clrBack /* = CLR_DEFAULT */ ) { #ifdef DEBUG_ALL TraceLine( "ZTitleTip::Show %s Delay: %d", cpcTitleText, m_lHoverDelay ); #endif CString csTitle = _T( " " ); csTitle += cpcTitleText; csTitle += _T( " " ); if ( rectTitle == m_rectTitle && m_csTitle == csTitle ) return; // TraceLine( "ZTitleTip::Show csTitle: %s m_csTitle: %s", csTitle, m_csTitle ); // TraceRect( "ZTitleTip::Show rectTitle: ", rectTitle ); // TraceRect( "ZTitleTip::Show m_rectTitle: ", m_rectTitle ); m_csTitle = csTitle; if ( mIs_hWnd( m_hWnd ) == 0 ) Create( m_pParentWnd ); ASSERT( ::IsWindow( GetSafeHwnd( ) ) ); if ( mIs_hWnd( m_hWnd ) == 0 ) return; m_rectHover = pHoverRect ? pHoverRect : rectTitle; m_rectHover.right++; m_rectHover.bottom++; // TraceRect( "ZTitleTip::Show Hover1", m_rectHover ); m_pParentWnd->ClientToScreen( m_rectHover ); // TraceRect( "ZTitleTip::Show Hover2", m_rectHover ); m_nOffsetX = nOffsetX; m_clrText = clrText; m_clrBack = clrBack; #if 0 // Define the rectangle outside which the titletip will be hidden. // We add a buffer of one pixel around the rectangle. m_rectTitle.top = -1; m_rectTitle.left = -m_nOffsetX - 1; m_rectTitle.right = rectTitle.Width( ) - m_nOffsetX; m_rectTitle.bottom = rectTitle.Height( ) + 1; #else m_rectTitle = rectTitle; #endif // TraceRect( "ZTitleTip::Show rectTitle: ", m_rectTitle ); // If window is not valid, display rect is empty, text is empty, // title tip is already displayed, or app does not have focus ... // don't do anything. if ( mIs_hWnd( m_hWnd ) == 0 || rectTitle.IsRectEmpty( ) || cpcTitleText == 0 || *cpcTitleText == 0 || mIs_hWndVisible( m_hWnd ) || GetFocus( ) == 0 ) { return; } if ( m_lHoverDelay > 0 ) { if ( m_uToolTipTimerId ) KillTimer( m_uToolTipTimerId ); m_uToolTipTimerId = SetTimer( g_nIdShowTitleTipEvt, m_lHoverDelay, 0 ); } else { DrawTipText( 1 ); } SetCapture( ); }
void VR_ShowCrosshair () { vec3_t forward, up, right; vec3_t start, end, impact; float size; if( (sv_player && (int)(sv_player->v.weapon) == IT_AXE) ) return; // setup gl glDisable (GL_DEPTH_TEST); glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); GL_PolygonOffset (OFFSET_SHOWTRIS); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDisable (GL_TEXTURE_2D); glDisable (GL_CULL_FACE); // calc the line and draw VectorCopy (cl.viewent.origin, start); start[2] -= cl.viewheight - 10; AngleVectors (cl.aimangles, forward, right, up); size = CLAMP (1.0, vr_crosshair_size.value, 5.0); switch((int) vr_crosshair.value) { default: case VR_CROSSHAIR_POINT: if (vr_crosshair_depth.value <= 0) { // trace to first wall VectorMA (start, 4096, forward, end); TraceLine (start, end, impact); } else { // fix crosshair to specific depth VectorMA (start, vr_crosshair_depth.value * meters_to_units, forward, impact); } glEnable(GL_POINT_SMOOTH); glColor4f (1, 0, 0, 0.5); glPointSize( size * glwidth / 1280.0f ); glBegin(GL_POINTS); glVertex3f (impact[0], impact[1], impact[2]); glEnd(); glDisable(GL_POINT_SMOOTH); break; case VR_CROSSHAIR_LINE: // trace to first entity VectorMA (start, 4096, forward, end); TraceLineToEntity (start, end, impact, sv_player); glColor4f (1, 0, 0, 0.4); glLineWidth( size * glwidth / (1280.0f) ); glBegin (GL_LINES); glVertex3f (start[0], start[1], start[2]); glVertex3f (impact[0], impact[1], impact[2]); glEnd (); break; } // cleanup gl glColor3f (1,1,1); glEnable (GL_TEXTURE_2D); glEnable (GL_CULL_FACE); glDisable(GL_BLEND); glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); GL_PolygonOffset (OFFSET_NONE); glEnable (GL_DEPTH_TEST); }
void Shell::process(void const *argument) { char ch; static char line[SHELL_MAX_LINE_LEN]; bool ret; char *cmd, *argPos, *tok; int i; static char *args[SHELL_MAX_ARGUMENTS + 1]; const Command *exec; int result; TraceLine(); Trace("welcome to gBike"); TraceLine(); m_pthread = (Thread*)argument; memset(line, 0, SHELL_MAX_LINE_LEN); while(m_exit == false) { osEvent evt = m_serialQ.get(); if (evt.status != osEventMessage) { Trace("queue->get() return %02x status", evt.status); continue; } ch = (char)evt.value.v; ret = getLine(ch, line, SHELL_MAX_LINE_LEN); if (false == ret) continue; cmd = _strtok(line, " \t", &tok); i = 0; while((argPos = _strtok(NULL," \t", &tok)) != NULL) { if (i >= SHELL_MAX_ARGUMENTS) { Trace("too many arguments!"); cmd = NULL; break; } args[i++] = argPos; } args[i] = NULL; if (cmd == NULL) { goto loop; } exec = findCommand(cmd); if (exec) { exec->function(i, args, &result); } else { Trace("unknow command:%s", cmd); } loop: memset(line, 0, SHELL_MAX_LINE_LEN); } }
static void TraceLine( VECTOR *LinP, VECTOR *LinD, VECTOR *Color, int reccount ) { VECTOR Pnt, Norm, LDir, NewDir, NewDir2, TmpCol, TmpCol2; VECTOR TmpPnt, TmpNorm, D; double t, A, cosfi; TEXTURE *txt, *tmptxt; int i, shadowcount, usedist; Color->x = Color->y = Color->z = 0.0; if( reccount > 0 ) { /* Only use distributed tracing in higher nodes of the recursion tree */ usedist = ( (MAXREC-reccount) < DISTLEVELS ) ? 1 : 0; /* Try intersection with objects */ t = IntersectObjs( LinP, LinD, &Pnt, &Norm, &txt ); /* Get light-intensity in intersection-point (store in cosfi) */ if( t > EPSILON ) { LDir.x = Lightpos.x-Pnt.x; /* Get line to light from surface */ LDir.y = Lightpos.y-Pnt.y; LDir.z = Lightpos.z-Pnt.z; cosfi = LDir.x*Norm.x + LDir.y*Norm.y + LDir.z*Norm.z; if(cosfi > 0.0) { /* If angle between lightline and normal < PI/2 */ shadowcount = 0; if( usedist ) { A = Lightr / VectorLength( &LDir ); for( i = 0; i < DISTRIB; i++ ) { DistribVector( &D, &LDir, A, A ); NewDir = LDir; NewDir.x += D.x; NewDir.y += D.y; NewDir.z += D.z; /* Check for shadows (ignore hit info, may be used though) */ t = IntersectObjs( &Pnt, &NewDir, &TmpPnt, &TmpNorm, &tmptxt ); if( ( t < EPSILON ) || ( t > 1.0 ) ) shadowcount++; } } else { t = IntersectObjs( &Pnt, &LDir, &TmpPnt, &TmpNorm, &tmptxt ); if( ( t < EPSILON ) || ( t > 1.0 ) ) shadowcount = DISTRIB; } if( shadowcount > 0 ) { A = Norm.x*Norm.x + Norm.y*Norm.y + Norm.z*Norm.z; A *= LDir.x*LDir.x + LDir.y*LDir.y + LDir.z*LDir.z; cosfi = (cosfi/sqrt(A))*txt->diffuse*(double)shadowcount/DISTRIB; } else { cosfi = 0.0; } } else { cosfi = 0.0; } Color->x = txt->color.x*(Ambient+cosfi); Color->y = txt->color.y*(Ambient+cosfi); Color->z = txt->color.z*(Ambient+cosfi); if( txt->reflect > EPSILON ) { ReflectVector( &NewDir, LinD, &Norm ); TmpCol.x = TmpCol.y = TmpCol.z = 0.0; if( usedist && ( txt->roughness > EPSILON ) ) { for( i = 0; i < DISTRIB; i++ ) { DistribVector( &D, &NewDir, txt->roughness, txt->roughness ); NewDir2 = NewDir; NewDir2.x += D.x; NewDir2.y += D.y; NewDir2.z += D.z; TraceLine( &Pnt, &NewDir2, &TmpCol2, reccount-1 ); TmpCol.x += TmpCol2.x; TmpCol.y += TmpCol2.y; TmpCol.z += TmpCol2.z; } ScaleVector( &TmpCol, 1.0/DISTRIB ); } else { TraceLine( &Pnt, &NewDir, &TmpCol, reccount-1 ); } Color->x += TmpCol.x * txt->reflect; Color->y += TmpCol.y * txt->reflect; Color->z += TmpCol.z * txt->reflect; } } else { /* Get sky-color (interpolate between horizon and zenit) */ A = sqrt( LinD->x*LinD->x + LinD->y*LinD->y ); if( A > 0.0 ) A = atan( fabs( LinD->z ) / A )*0.63661977; else A = 1.0; Color->x = Skycolor[1].x*A + Skycolor[0].x*(1.0-A); Color->y = Skycolor[1].y*A + Skycolor[0].y*(1.0-A); Color->z = Skycolor[1].z*A + Skycolor[0].z*(1.0-A); } /* Make sure that the color does not exceed the maximum level */ if(Color->x > 1.0) Color->x = 1.0; if(Color->y > 1.0) Color->y = 1.0; if(Color->z > 1.0) Color->z = 1.0; } }
//----------------------------------------------------------------------------- // Purpose: Simulate movement, with collision // Input : &origin - position of the particle // &velocity - velocity of the particle // &rollDelta - roll delta of the particle // timeDelta - time step //----------------------------------------------------------------------------- bool CParticleCollision::MoveParticle(Vector &origin, Vector &velocity, float *rollDelta, float timeDelta, trace_t *pTrace) { //Don't bother with non-moving particles if (velocity == vec3_origin) return false; //Factor in gravity velocity[2] -= m_flGravity * timeDelta; //Move Vector testPosition = (origin + (velocity * timeDelta)); //Only collide if we have active planes if (m_nActivePlanes > 0) { //Collide TraceLine(origin, testPosition, pTrace); //See if we hit something if (pTrace->fraction != 1.0f) { #if __DEBUG_PARTICLE_COLLISION_RETEST //Retest the collision with a true trace line to avoid errant collisions UTIL_TraceLine(origin, testPosition, MASK_SOLID_BRUSHONLY, NULL, COLLISION_GROUP_NONE, pTrace); #endif //__DEBUG_RETEST_COLLISION //Did we hit anything? if (pTrace->fraction != 1.0f) { //See if we've settled if ((pTrace->plane.normal[2] >= 0.5f) && (fabs(velocity[2]) <= 48.0f)) { //Leave the particle at the collision point origin += velocity * ((pTrace->fraction - COLLISION_EPSILON) * timeDelta); //Stop the particle velocity = vec3_origin; if (rollDelta != NULL) { *rollDelta = 0.0f; } return false; } else { //Move the particle to the collision point origin += velocity * ((pTrace->fraction - COLLISION_EPSILON) * timeDelta); //Find the reflection vector float proj = velocity.Dot(pTrace->plane.normal); velocity += pTrace->plane.normal * (-proj*2.0f); //Apply dampening velocity *= random->RandomFloat((m_flCollisionDampen - 0.1f), (m_flCollisionDampen + 0.1f)); //Dampen the roll of the particles if (rollDelta != NULL) { (*rollDelta) *= -0.25f; } return true; } } else { #if __DEBUG_PARTICLE_COLLISION_OVERLAY //Display a false hit debugoverlay->AddBoxOverlay( pTrace->endpos, Vector(-1,-1,-1), Vector(1,1,1), QAngle(0,0,0), 255, 0, 0, 16, __DEBUG_PARTICLE_COLLISION_OVERLAY_LIFETIME ); #endif //__DEBUG_PARTICLE_COLLISION_OVERLAY } } } //Simple move, no collision origin = testPosition; return false; }
zOPER_EXPORT zSHORT OPERATION MapPointSetPushPin( zCPCHAR cpcStreet, zCPCHAR cpcCity, zCPCHAR cpcOtherCity, zCPCHAR cpcRegion, zCPCHAR cpcPostalCode, zCPCHAR cpcMsg, zSHORT nPushPin, zLONG lFlag ) { AFX_MANAGE_STATE( AfxGetStaticModuleState( ) ); SHORT nRC = 0; ZMapPointApp *pApp = (ZMapPointApp *) ::AfxGetApp( ); if ( pApp ) { TRY { if ( pApp->GetMapPointState( ) == 0 ) // not active return( zCALL_ERROR ); _Application *pMP = pApp->GetMapPointApplication( ); if ( pMP == 0 ) { nRC = zCALL_ERROR; } else { _Map Map = pMP->GetActiveMap( ); // if ( pMap == 0 ) // nRC = zCALL_ERROR; // else { // Item item; zLONG lCnt; VARIANT a; a.vt = VT_I4; a.lVal = 244; // geoMapNorthAmerica! // a.lVal = 1; // geoMapNorthAmerica! // a.lVal = 2; // geoMapEurope! FindResults FR = Map.FindAddressResults( cpcStreet, cpcCity, cpcOtherCity, cpcRegion, cpcPostalCode, a ); TraceLineI( "FindAddressResults Quality: ", FR.GetResultsQuality( ) ); lCnt = FR.GetCount( ); TraceLineI( "FindAddressResults Count: ", lCnt ); for ( int k = 1; k <= lCnt; k++ ) { a.lVal = k; Location L = FR.GetItem( &a ); long lType = L.GetType( ); long lX = Map.LocationToX( L ); long lY = Map.LocationToY( L ); TraceLine( "Location Name: %s Type: %d X: %d Y: %d", L.GetName( ), lType, lX, lY ); Pushpin pin; if ( cpcMsg && &cpcMsg ) pin = Map.AddPushpin( L, cpcMsg ); else pin = Map.AddPushpin( L, L.GetName( ) ); pin.SetSymbol( nPushPin ); if ( lFlag & 0x00000001 ) L.GoTo( ); PlaceCategory PC = L.GetPlaceCategory( ); TraceLineS( "The Place Category is: ", PC.GetName( ) ); } } } } CATCH_ALL( e ) { nRC = zCALL_ERROR; } END_CATCH_ALL } return( nRC ); }
bool Aiming::getValidTarget(Vector &outTarget) { cl_entity_t *them = NULL; bool bLowerPriority, bFirstEntity = true; float vis; int msg; // we track net status in order to make sure we do not kill ents to fast: static net_status_s nssNetStatus; static double dOldLatency=0; pEngfuncs->pNetAPI->Status(&nssNetStatus); // Some booleans bool bOneWay = !(aim_oneway->value == 0); bool bViewOnly = !(aim_onlyvisible->value == 0); bool bNetActive = (dOldLatency != nssNetStatus.latency); // not perfect yet // The time we linger before we move on! int iLingerTime = (int) aim_lingertime->value; // Now this is code to get the right entity to aim at! std::list<int>::iterator iter = m_AimLayers.begin(); int slot_position = 0; // Loop through all entities in the list for (std::list<int>::iterator iter = m_AimLayers.begin(); iter != m_AimLayers.end(); iter++) { // What we need // If the entity meets our targetting criteria (vis/active) we store the // coords for it, which is what gets returned. // When the entity starts failing, we keep returning the last updated // coords until the linger time runs out, after which we just return false // and the cameraman can do whatever int i = (*iter); // Point to the right entity them = pEngfuncs->GetEntityByIndex(i); // If they exist them take the actual values if (them) { vis = TraceLine(them); msg = them->curstate.messagenum; } // Otherwise use their last known message and assume they're not visible else { vis = 0; msg = m_LastMsgNums[i]; } // And is this up or down the list? bLowerPriority = (slot_position > m_iHighestSlot); // This entity was active within the last few frames // m_EntityStates[i] == ES_DEAD means that the entity has died since it has been tracked if (m_EntityStates[i] != ES_DEAD && (m_LastMsgNums[i] != msg || m_ActiveTimes[i] > 0)) { if (m_LastMsgNums[i] != msg) m_ActiveTimes[i] = 5; //WARNING note: actuall this might have to be s.th. like c*(FPS/updaterate) // We don't care about whether it is visible, so assume it is if (!bViewOnly) { _RetriveTargetFromEnt(them,m_LastPositions[i]); m_VisibleTimes[i] = iLingerTime; } // Actually we only look at visible entities else if (bViewOnly && (vis == 1.0f || m_VisibleTimes[i] > 0)) { if (vis == 1.0f) m_VisibleTimes[i] = iLingerTime; _RetriveTargetFromEnt(them,m_LastPositions[i]); } } // This entity is not active else { // If a previously targetted entity has died then don't retarget it if (m_EntityStates[i] == ES_TARGET) m_EntityStates[i] = ES_DEAD; } // By now if m_VisibleTimes[i] > 0 then we will have a location which we want to // aim at, calculated from either this frame or a previous one if (m_VisibleTimes[i] > 0) { // It's the first entity we've searched for and we're allowed to pick it if (bFirstEntity && (!bOneWay || !bLowerPriority)) { outTarget = m_LastPositions[i]; bFirstEntity = false; m_EntityStates[i] = ES_TARGET; } m_VisibleTimes[i]--; } // We just need to decrement this however // BUT DO NOT KILL WHEN NET IS NOT ACTIVE (i.e. Demo Paused)s if ((m_ActiveTimes[i] > 0) && bNetActive) m_ActiveTimes[i]--; // Now we just update their values m_LastMsgNums[i] = msg; slot_position++; } // save new connection time dOldLatency = nssNetStatus.latency; // Return whether we found an entity return !bFirstEntity; }
void CWeaponGravityGun::EffectUpdate( void ) { Vector start, forward, right; trace_t tr; CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); if ( !pOwner ) return; pOwner->EyeVectors( &forward, &right, NULL ); start = pOwner->Weapon_ShootPosition(); TraceLine( &tr ); Vector end = tr.endpos; float distance = tr.fraction * 4096; if ( tr.fraction != 1 ) { // too close to the player, drop the object if ( distance < 36 ) { DetachObject(); return; } } if ( m_hObject == NULL && tr.DidHitNonWorldEntity() ) { CBaseEntity *pEntity = tr.m_pEnt; AttachObject( pEntity, start, tr.endpos, distance ); m_lastYaw = pOwner->EyeAngles().y; } // Add the incremental player yaw to the target transform matrix3x4_t curMatrix, incMatrix, nextMatrix; AngleMatrix( m_gravCallback.m_targetRotation, curMatrix ); AngleMatrix( QAngle(0,pOwner->EyeAngles().y - m_lastYaw,0), incMatrix ); ConcatTransforms( incMatrix, curMatrix, nextMatrix ); MatrixAngles( nextMatrix, m_gravCallback.m_targetRotation ); m_lastYaw = pOwner->EyeAngles().y; CBaseEntity *pObject = m_hObject; if ( pObject ) { if ( m_useDown ) { if ( pOwner->m_afButtonPressed & IN_USE ) { m_useDown = false; } } else { if ( pOwner->m_afButtonPressed & IN_USE ) { m_useDown = true; } } if ( m_useDown ) { #ifndef CLIENT_DLL pOwner->SetPhysicsFlag( PFLAG_DIROVERRIDE, true ); #endif if ( pOwner->m_nButtons & IN_FORWARD ) { m_distance = Approach( 1024, m_distance, gpGlobals->frametime * 100 ); } if ( pOwner->m_nButtons & IN_BACK ) { m_distance = Approach( 40, m_distance, gpGlobals->frametime * 100 ); } } if ( pOwner->m_nButtons & IN_WEAPON1 ) { m_distance = Approach( 1024, m_distance, m_distance * 0.1 ); #ifdef CLIENT_DLL if ( gpGlobals->maxClients > 1 ) { gHUD.m_bSkipClear = false; } #endif } if ( pOwner->m_nButtons & IN_WEAPON2 ) { m_distance = Approach( 40, m_distance, m_distance * 0.1 ); #ifdef CLIENT_DLL if ( gpGlobals->maxClients > 1 ) { gHUD.m_bSkipClear = false; } #endif } IPhysicsObject *pPhys = pObject->VPhysicsGetObject(); if ( pPhys && pPhys->IsAsleep() ) { // on the odd chance that it's gone to sleep while under anti-gravity pPhys->Wake(); } Vector newPosition = start + forward * m_distance; Vector offset; pObject->EntityToWorldSpace( m_worldPosition, &offset ); m_gravCallback.SetTargetPosition( newPosition + (pObject->GetAbsOrigin() - offset), m_gravCallback.m_targetRotation ); Vector dir = (newPosition - pObject->GetLocalOrigin()); m_movementLength = dir.Length(); } else { m_targetPosition = end; //m_gravCallback.SetTargetPosition( end, m_gravCallback.m_targetRotation ); } }
void SCR_SetupAutoID (void) { int i, view[4]; float model[16], project[16], winz, *origin; entity_t *state; autoid_player_t *id; vec3_t OurViewPoint; vec3_t ThisClientPoint; vec3_t stop; vec3_t edist; void TraceLine (vec3_t start, vec3_t end, vec3_t impact); autoid_count = 0; if (!scr_autoid.value || cls.state != ca_connected || !cls.demoplayback) return; glGetFloatv (GL_MODELVIEW_MATRIX, model); glGetFloatv (GL_PROJECTION_MATRIX, project); glGetIntegerv (GL_VIEWPORT, view); for (i = 0 ; i < cl.maxclients ; i++) { state = &cl_entities[1+i]; if (!state->model->name) // NULL model continue; if (!(state->modelindex == cl_modelindex[mi_player])) // Not a player model continue; if (ISDEAD(state->frame)) // Dead continue; // if (strcmp(state->model->name, "progs/player.mdl")) // continue; if (R_CullSphere(state->origin, 0)) continue; // Logic // Fill in one value with our viewpoint and the next value with target // Do traceline VectorCopy (r_refdef.vieworg, OurViewPoint); VectorCopy (state->origin, ThisClientPoint); TraceLine (OurViewPoint, ThisClientPoint, stop); if (stop[0] != 0 || stop[1] != 0 || stop[2] != 0) // Quick and dirty traceline continue; #if 1 if (!CL_Visible_To_Client(OurViewPoint, ThisClientPoint)) { // We can't see it //Con_Printf("Cannot see it\n"); continue; } #endif id = &autoids[autoid_count]; id->player = &cl.scores[i]; #if 0 Con_Printf("Player %s\n", id->player->name); // Print name of seen player Con_Printf("Client num %i\n", i); Con_Printf("modelname is %s\n", state->model->name); Con_Printf("modelindex is %i\n", state->modelindex); //Con_Printf("modelname char one is %i\n", state->model->name[0]); Con_Printf("playermodel index is %i\n", cl_modelindex[mi_player]); #endif origin = state->origin; if (qglProject(origin[0], origin[1], origin[2] + 28, model, project, view, &id->x, &id->y, &winz)) autoid_count++; } }
// geoCountryCanada 39 Canada // geoCountryUnitedStates 244 United States zOPER_EXPORT zSHORT OPERATION MapPointValidateAddress( zPCHAR pchStreet, zPCHAR pchCity, zPCHAR pchOtherCity, zPCHAR pchRegion, zPCHAR pchPostalCode, zCPCHAR cpcStreetAddress, zLONG lFlag ) { AFX_MANAGE_STATE( AfxGetStaticModuleState( ) ); SHORT nRC = 0; ZMapPointApp *pApp = (ZMapPointApp *) ::AfxGetApp( ); *pchStreet = 0; *pchCity = 0; *pchOtherCity = 0; *pchRegion = 0; *pchPostalCode = 0; if ( pApp ) { TRY { if ( pApp->GetMapPointState( ) == 0 ) // not active return( zCALL_ERROR ); _Application *pMP = pApp->GetMapPointApplication( ); if ( pMP == 0 ) { nRC = zCALL_ERROR; } else { _Map Map = pMP->GetActiveMap( ); // if ( pMap == 0 ) // nRC = zCALL_ERROR; // else { // Item item; zLONG lCnt; VARIANT a; a.vt = VT_I4; a.lVal = 244; // geoMapNorthAmerica! // a.lVal = 1; // geoMapNorthAmerica! // a.lVal = 2; // geoMapEurope! StreetAddress SA = Map.ParseStreetAddress( cpcStreetAddress ); zstrcpy( pchStreet, SA.GetStreet( ) ); zstrcpy( pchCity, SA.GetCity( ) ); zstrcpy( pchOtherCity, SA.GetOtherCity( ) ); zstrcpy( pchRegion, SA.GetRegion( ) ); zstrcpy( pchPostalCode, SA.GetPostalCode( ) ); FindResults FR = Map.FindAddressResults( pchStreet, pchCity, pchOtherCity, pchRegion, pchPostalCode, a ); TraceLineI( "FindAddressResults Quality: ", FR.GetResultsQuality( ) ); lCnt = FR.GetCount( ); TraceLineI( "FindAddressResults Count: ", lCnt ); #if 0 for ( int k = 1; k <= lCnt; k++ ) { a.lVal = k; Location L = FR.GetItem( &a ); long lType = L.GetType( ); long lX = Map.LocationToX( L ); long lY = Map.LocationToY( L ); TraceLine( "Location Name: %s Type: %d X: %d Y: %d", L.GetName( ), lType, lX, lY ); Map.AddPushpin( L, L.GetName( ) ); PlaceCategory PC = L.GetPlaceCategory( ); TraceLineS( "The Place Category is: ", PC.GetName( ) ); } #endif } } } CATCH_ALL( e ) { nRC = zCALL_ERROR; } END_CATCH_ALL } return( nRC ); }
//----------------------------------------------------------------------------- // Purpose: Third-person function call to render world model //----------------------------------------------------------------------------- int CWeaponGravityGun::DrawModel( int flags ) { // Only render these on the transparent pass if ( flags & STUDIO_TRANSPARENCY ) { if ( !m_active ) return 0; C_BasePlayer *pOwner = ToBasePlayer( GetOwner() ); if ( !pOwner ) return 0; Vector points[3]; QAngle tmpAngle; C_BaseEntity *pObject = m_hObject; //if ( pObject == NULL ) // return 0; GetAttachment( 1, points[0], tmpAngle ); // a little noise 11t & 13t should be somewhat non-periodic looking //points[1].z += 4*sin( gpGlobals->curtime*11 ) + 5*cos( gpGlobals->curtime*13 ); if ( pObject == NULL ) { //points[2] = m_targetPosition; trace_t tr; TraceLine( &tr ); points[2] = tr.endpos; } else { pObject->EntityToWorldSpace( m_worldPosition, &points[2] ); } Vector forward, right, up; QAngle playerAngles = pOwner->EyeAngles(); AngleVectors( playerAngles, &forward, &right, &up ); if ( pObject == NULL ) { Vector vecDir = points[2] - points[0]; VectorNormalize( vecDir ); points[1] = points[0] + 0.5f * (vecDir * points[2].DistTo(points[0])); } else { Vector vecSrc = pOwner->Weapon_ShootPosition( ); points[1] = vecSrc + 0.5f * (forward * points[2].DistTo(points[0])); } IMaterial *pMat = materials->FindMaterial( "sprites/physbeam1", TEXTURE_GROUP_CLIENT_EFFECTS ); if ( pObject ) pMat = materials->FindMaterial( "sprites/physbeam", TEXTURE_GROUP_CLIENT_EFFECTS ); Vector color; color.Init(1,1,1); float scrollOffset = gpGlobals->curtime - (int)gpGlobals->curtime; CMatRenderContextPtr pRenderContext( materials ); pRenderContext->Bind( pMat ); DrawBeamQuadratic( points[0], points[1], points[2], pObject ? 13/3.0f : 13/5.0f, color, scrollOffset ); DrawBeamQuadratic( points[0], points[1], points[2], pObject ? 13/3.0f : 13/5.0f, color, -scrollOffset ); IMaterial *pMaterial = materials->FindMaterial( "sprites/physglow", TEXTURE_GROUP_CLIENT_EFFECTS ); color32 clr={0,64,255,255}; if ( pObject ) { clr.r = 186; clr.g = 253; clr.b = 247; clr.a = 255; } float scale = random->RandomFloat( 3, 5 ) * ( pObject ? 3 : 2 ); // Draw the sprite pRenderContext->Bind( pMaterial ); for ( int i = 0; i < 3; i++ ) { DrawSprite( points[2], scale, scale, clr ); } return 1; } // Only do this on the opaque pass return BaseClass::DrawModel( flags ); }
void CriticalPoint::FindCriticalPoints() { p_MaxPointID->clear(); p_MinPointID->clear(); p_SadPointID->clear(); PolyIndexArray& adjVerticesArray = *(Global::p_adjVtxArray); CoordArray& vCoord = *(Global::p_coord); size_t nVertex = vCoord.size(); m_vtx.clear(); m_vtx.resize(Global::vtxNum); vector<bool> adjFlag; for (size_t i = 0; i < nVertex; ++i) { // set the adj vertex flag array. double value = (*p_EigenValue)[i]; IndexArray& adjVertices = adjVerticesArray[i]; adjFlag.clear(); adjFlag.resize(adjVertices.size()); fill(adjFlag.begin(), adjFlag.end(), false); for (size_t j = 0; j < adjVertices.size(); j++) { if (value > (*p_EigenValue)[adjVertices[j]]) adjFlag[j] = true; } if (Global::mesh->m_BasicOp.IsBoundaryVertex((int)i)) { vector<bool> tmpadjFlag(adjFlag); for (int k = (int)tmpadjFlag.size() - 1; k >=0; k--) { adjFlag.push_back(tmpadjFlag[k]); } } // check the point type. Global::POINTTYPE type= CheckVertexType(adjFlag); // set the point's type if(type == Global::MAXPOINT) { m_vtx[i] = new MaxPoint(i); p_MaxPointID->insert(i); }else if(type == Global::MINPOINT) { m_vtx[i] = new MinPoint(i); p_MinPointID->insert(i); }else if(type == Global::SADDLEPOINT) { m_vtx[i] = new SadPoint(i); p_SadPointID->insert(i); }else{ m_vtx[i] = new M_Point(i); } } // SetCPVertexFlag(); // fill(m_cp_vtx_mapping.begin(), m_cp_vtx_mapping.end(), -1); // set_dual_max_min_vertex_mapping(); printf("FindCriticalPoint ok\n"); TraceLine(); printf("max: %d, min: %d, saddle: %d\n", p_MaxPointID->size(), p_MinPointID->size(), p_SadPointID->size()); }
//----------------------------------------------------------------------------- // Purpose: First-person function call after viewmodel has been drawn //----------------------------------------------------------------------------- void CWeaponGravityGun::ViewModelDrawn( C_BaseViewModel *pBaseViewModel ) { if ( !m_active ) return; // Render our effects C_BasePlayer *pOwner = ToBasePlayer( GetOwner() ); if ( !pOwner ) return; Vector points[3]; QAngle tmpAngle; C_BaseEntity *pObject = m_hObject; //if ( pObject == NULL ) // return; pBaseViewModel->GetAttachment( 1, points[0], tmpAngle ); // a little noise 11t & 13t should be somewhat non-periodic looking //points[1].z += 4*sin( gpGlobals->curtime*11 ) + 5*cos( gpGlobals->curtime*13 ); if ( pObject == NULL ) { //points[2] = m_targetPosition; trace_t tr; TraceLine( &tr ); points[2] = tr.endpos; } else { pObject->EntityToWorldSpace(m_worldPosition, &points[2]); } Vector forward, right, up; QAngle playerAngles = pOwner->EyeAngles(); AngleVectors( playerAngles, &forward, &right, &up ); Vector vecSrc = pOwner->Weapon_ShootPosition( ); points[1] = vecSrc + 0.5f * (forward * points[2].DistTo(points[0])); IMaterial *pMat = materials->FindMaterial( "sprites/physbeam1", TEXTURE_GROUP_CLIENT_EFFECTS ); if ( pObject ) pMat = materials->FindMaterial( "sprites/physbeam", TEXTURE_GROUP_CLIENT_EFFECTS ); Vector color; color.Init(1,1,1); // Now draw it. CViewSetup beamView = *view->GetPlayerViewSetup(); Frustum dummyFrustum; render->Push3DView( beamView, 0, NULL, dummyFrustum ); float scrollOffset = gpGlobals->curtime - (int)gpGlobals->curtime; CMatRenderContextPtr pRenderContext( materials ); pRenderContext->Bind( pMat ); #if 1 // HACK HACK: Munge the depth range to prevent view model from poking into walls, etc. // Force clipped down range pRenderContext->DepthRange( 0.1f, 0.2f ); #endif DrawBeamQuadratic( points[0], points[1], points[2], pObject ? 13/3.0f : 13/5.0f, color, scrollOffset ); DrawBeamQuadratic( points[0], points[1], points[2], pObject ? 13/3.0f : 13/5.0f, color, -scrollOffset ); IMaterial *pMaterial = materials->FindMaterial( "sprites/physglow", TEXTURE_GROUP_CLIENT_EFFECTS ); color32 clr={0,64,255,255}; if ( pObject ) { clr.r = 186; clr.g = 253; clr.b = 247; clr.a = 255; } float scale = random->RandomFloat( 3, 5 ) * ( pObject ? 3 : 2 ); // Draw the sprite pRenderContext->Bind( pMaterial ); for ( int i = 0; i < 3; i++ ) { DrawSprite( points[2], scale, scale, clr ); } #if 1 pRenderContext->DepthRange( 0.0f, 1.0f ); #endif render->PopView( dummyFrustum ); // Pass this back up BaseClass::ViewModelDrawn( pBaseViewModel ); }
void CWeaponGravityGun::EffectUpdate( void ) { Vector start, forward, right; trace_t tr; CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); if ( !pOwner ) return; pOwner->EyeVectors( &forward, &right, NULL ); start = pOwner->Weapon_ShootPosition(); TraceLine( &tr ); Vector end = tr.endpos; float distance = tr.fraction * 4096; if ( m_hObject == NULL && tr.DidHitNonWorldEntity() ) { CBaseEntity *pEntity = tr.m_pEnt; AttachObject( pEntity, GetPhysObjFromPhysicsBone( pEntity, tr.physicsbone ), tr.physicsbone, start, tr.endpos, distance ); } // Add the incremental player yaw to the target transform QAngle angles = m_gravCallback.TransformAnglesFromPlayerSpace( m_gravCallback.m_targetRotation, pOwner ); CBaseEntity *pObject = m_hObject; if ( pObject ) { if ( m_useDown ) { if ( pOwner->m_afButtonPressed & IN_USE ) { m_useDown = false; } } else { if ( pOwner->m_afButtonPressed & IN_USE ) { m_useDown = true; } } if ( m_useDown ) { #ifndef CLIENT_DLL pOwner->SetPhysicsFlag( PFLAG_DIROVERRIDE, true ); #endif if ( pOwner->m_nButtons & IN_FORWARD ) { m_distance = Approach( 1024, m_distance, gpGlobals->frametime * 100 ); } if ( pOwner->m_nButtons & IN_BACK ) { m_distance = Approach( 40, m_distance, gpGlobals->frametime * 100 ); } } if ( pOwner->m_nButtons & IN_WEAPON1 ) { m_distance = Approach( 1024, m_distance, m_distance * 0.1 ); } if ( pOwner->m_nButtons & IN_WEAPON2 ) { m_distance = Approach( 40, m_distance, m_distance * 0.1 ); } IPhysicsObject *pPhys = GetPhysObjFromPhysicsBone( pObject, m_physicsBone ); if ( pPhys ) { if ( pPhys->IsAsleep() ) { // on the odd chance that it's gone to sleep while under anti-gravity pPhys->Wake(); } Vector newPosition = start + forward * m_distance; Vector offset; pPhys->LocalToWorld( &offset, m_worldPosition ); Vector vecOrigin; pPhys->GetPosition( &vecOrigin, NULL ); m_gravCallback.SetTargetPosition( newPosition + (vecOrigin - offset), angles ); Vector dir = (newPosition - pObject->GetLocalOrigin()); m_movementLength = dir.Length(); } } else { m_targetPosition = end; //m_gravCallback.SetTargetPosition( end, m_gravCallback.m_targetRotation ); } }
// Show - Show the titletip if needed. // rectTitle - The rectangle within which the original title // is constrained - in client coordinates. // cpcTitleText - The text to be displayed. // nOffsetX - Number of pixels that the text is offset from // the left border of the cell. void ZListTip::Show( CRect rectTitle, zCPCHAR cpcTitleText, int nOffsetX /* = 0 */, LPRECT pHoverRect /* = 0 */, const LOGFONT *pLogFont /* = 0 */, COLORREF clrText /* = CLR_DEFAULT */, COLORREF clrBack /* = CLR_DEFAULT */ ) { #ifdef DEBUG_ALL TraceLine( "ZListTip::Show %s Delay: %d", cpcTitleText, m_lHoverDelay ); #endif m_csTitle = cpcTitleText; // If window is not valid, display rect is empty, text is empty, // title tip is already displayed, or app does not have focus ... // don't do anything. if ( mIs_hWnd( m_hWnd ) == 0 || rectTitle.IsRectEmpty( ) || cpcTitleText == 0 || *cpcTitleText == 0 || mIs_hWndVisible( m_hWnd ) || GetFocus( ) == 0 ) { return; } // Define the rectangle outside which the titletip will be hidden. // We add a buffer of one pixel around the rectangle. m_rectTitle.top = -1; m_rectTitle.left = -1; m_rectTitle.right = rectTitle.Width( ); m_rectTitle.bottom = rectTitle.Height( ) + 1; // Determine the width of the text. m_pParentWnd->ClientToScreen( rectTitle ); CClientDC dc( this ); CFont *pFontDC; // if ( pLogFont ) // { // CFont font; // font.CreateFontIndirect( pLogFont ); // pFontDC = dc.SelectObject( &font ); // } // else { // Use same font as ctrl. pFontDC = dc.SelectObject( m_pParentWnd->GetFont( ) ); } m_nOffsetX = nOffsetX - 1; CRect rectDisplay = rectTitle; CSize size = dc.GetTextExtent( m_csTitle ); rectDisplay.top--; rectDisplay.left--; rectDisplay.right = rectDisplay.left + size.cx + 2 * m_nOffsetX; dc.SelectObject( pFontDC ); if ( rectDisplay.right > rectTitle.right + 1 ) { UINT uFlags = SWP_NOACTIVATE; if ( m_lHoverDelay == 0 ) { uFlags |= SWP_SHOWWINDOW; } else if ( m_lHoverDelay > 0 ) { if ( m_uToolTipTimerId ) KillTimer( m_uToolTipTimerId ); m_uToolTipTimerId = SetTimer( g_nIdShowToolTipEvt, m_lHoverDelay, 0 ); // TraceLine( "ZListTip::Show Timer Id: %d", m_uToolTipTimerId ); } SetWindowPos( &wndTop, rectDisplay.left, rectDisplay.top, rectDisplay.Width( ), rectDisplay.Height( ), uFlags ); DrawTipText( ); SetCapture( ); } }