Engine
Class DebugHUD

source: c:\runehov\Engine\Classes\DebugHUD.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.HUD
         |
         +--Engine.DebugHUD
Direct Known Subclasses:None

class DebugHUD
extends Engine.HUD

//============================================================================= // DebugHUD. //=============================================================================
Variables
 int DebugHudMode
           Cycled by ChangeHUD
 int DebugMode
           Cycled by ChangeCrosshair
 Name ModeTable[11]
 Actor watch
           Used by all single-selection modes

States
TriggerMode, NavPointMode, LightMode, ZoneMode, LevelMode, VisibleMode, PlayerMode, AIMode, ConstantMode, ActorMode, BlankMode, Startup, name
State TriggerMode Function Summary
 name GetRoleName(ENetRole theRole)
 void HSV_to_RGB(int H, int S, int V, out int, out int, out int)
 bool RelevantActor(Actor A)


State NavPointMode Function Summary


State LightMode Function Summary


State ZoneMode Function Summary


State LevelMode Function Summary


State VisibleMode Function Summary


State PlayerMode Function Summary


State AIMode Function Summary


State ConstantMode Function Summary


State ActorMode Function Summary


State BlankMode Function Summary
 bool RelevantActor(Actor A)


State Startup Function Summary
 bool RelevantActor(Actor A)


State name Function Summary
 void Command(string text)
     
// ==================================================================
// Debugger interface
// ==================================================================



Source Code


00001	//=============================================================================
00002	// DebugHUD.
00003	//=============================================================================
00004	class DebugHUD extends HUD
00005		native;
00006	
00007	/* Description:
00008		HUD used for debug
00009	
00010		ChangeCrosshair (BACKSPACE):
00011			Changes the selection criteria (none, target, player, visible, navpoints, all)
00012		ChangeHUD (\)
00013			Changes the debug mode (Actor, Skel, LOD, POV)
00014	
00015		To Add a new mode:
00016			Define a new state (see BlankMode)
00017			Bump ModeTable size
00018			Add the mode state name to the mode table in PostBegin()
00019	
00020	*/
00021	
00022	var Name ModeTable[11];
00023	
00024	var actor watch;					// Used by all single-selection modes
00025	var globalconfig int DebugMode;		// Cycled by ChangeCrosshair
00026	var globalconfig int DebugHudMode;	// Cycled by ChangeHUD
00027	
00028	
00029	
00030	/*	These are defined in ACTOR.UC for access in the Debug() functions
00031		
00032	const DEBUG_NONE		=	0;	// No Debugging
00033	const DEBUG_TARGET		=	1;	// Debug the target actor
00034	const DEBUG_CONSTANT	=	2;	// Debug an actor and don't change
00035	const DEBUG_AI			=	3;	// Debug AI (navpoints,constantTarget,POV)
00036	const DEBUG_PLAYER		=	4;	// Debug the player
00037	const DEBUG_LEVEL		=	5;	// Debug the level info actor
00038	const DEBUG_ZONE		=	6;	// Debug current Zoneinfo
00039	const DEBUG_MULTIPLE	=	7;	// ** this is the lowest multiple selection mode
00040	const DEBUG_VISIBLE		=	7;	// Debug all visible actors
00041	const DEBUG_LIGHTS		=	8;	// Debug lights
00042	const DEBUG_NAVPOINTS	=	9;	// Debug all navigation points
00043	const DEBUG_TRIGGERS	=	10;
00044	const DEBUG_MAX			=	10;
00045	
00046	const HUD_ACTOR			=	0;	// Call the actors debug function
00047	const HUD_SKELETON		=	1;	// Draw skeleton
00048	const HUD_SKELNAMES		=	2;	// Draw skeleton with joint names
00049	const HUD_SKELJOINTS	=	3;	// Draw skeleton with collision joints
00050	const HUD_SKELAXES		=	4;	// Draw skeleton with rotation axes
00051	const HUD_LOD			=	5;	// Draw LOD
00052	const HUD_POV			=	6;	// Draw POV of actor
00053	ocnst HUD_SCRIPT		=	7;
00054	const HUD_NETWORK		=	8;
00055	const HUD_MAX			=   8;
00056	const HUD_NONE			=   9;
00057	
00058	*/
00059	
00060	// ==================================================================
00061	// Debugger interface
00062	// ==================================================================
00063	
00064	function Command( string text )
00065	{
00066		local string verb, object;
00067		local int space;
00068		local Class<actor> NewClass;
00069		local actor A;
00070		local bool nextone;
00071		
00072		// Parse text into commands
00073		space = InStr(text, " ");
00074		if (space == -1)
00075		{
00076			verb = text;
00077			object = "";
00078		}
00079		else
00080		{
00081			verb = left(text, space);
00082			object = mid(text, space+1);
00083		}
00084		
00085	//	slog("received command <"$verb$"> <"$object$">");
00086		
00087		if (verb ~= "watch")
00088		{
00089			if (InStr(object, ".")==-1)
00090				object = "RuneI."$object;
00091			NewClass = class<actor>( DynamicLoadObject( Object, class'Class' ) );
00092			if (NewClass == None)
00093			{
00094				object = "Engine."$object;
00095				NewClass = class<actor>( DynamicLoadObject( Object, class'Class' ) );
00096			}
00097			if (NewClass != None)
00098			{
00099				if (Watch != None)
00100				{
00101					foreach AllActors(NewClass, A)
00102					{
00103						if (Watch == A)
00104						{
00105							nextone = true;
00106							break;
00107						}
00108					}
00109				}
00110				if (!nextone)
00111					SetWatch(None);
00112	
00113				nextone = false;
00114				foreach AllActors(NewClass, A)
00115				{
00116					if (Watch != None)
00117					{	// Cycle to next of this type
00118						if (nextone)
00119						{
00120							SetWatch(A);
00121							return;
00122						}
00123						else if (Watch == A)
00124						{
00125							nextone = true;
00126						}
00127					}
00128					else
00129					{
00130						SetWatch(A);
00131						return;
00132					}
00133				}
00134				SetWatch(None);
00135			}
00136		}
00137	}
00138	
00139	// ==================================================================
00140	// Hud interface functions
00141	// ==================================================================
00142	
00143	simulated function PostBeginPlay()
00144	{
00145		SetTimer(0.5, true);
00146	
00147		ModeTable[0]  = 'BlankMode';
00148		ModeTable[1]  = 'ActorMode';
00149		ModeTable[2]  = 'ConstantMode';
00150		ModeTable[3]  = 'AIMode';
00151		ModeTable[4]  = 'PlayerMode';
00152		ModeTable[5]  = 'LevelMode';
00153		ModeTable[6]  = 'ZoneMode';
00154		ModeTable[7]  = 'VisibleMode';
00155		ModeTable[8]  = 'LightMode';
00156		ModeTable[9]  = 'NavPointMode';
00157		ModeTable[10] = 'TriggerMode';
00158	}
00159	
00160	
00161	auto State Startup
00162	{
00163	Begin:
00164		GotoState( ModeTable[DebugMode] );
00165	}
00166	
00167	
00168	simulated function CreateMenu()
00169	{
00170		if ( PlayerPawn(Owner).bSpecialMenu && (PlayerPawn(Owner).SpecialMenu != None) )
00171		{
00172			MainMenu = Spawn(PlayerPawn(Owner).SpecialMenu, self);
00173			PlayerPawn(Owner).bSpecialMenu = false;
00174		}
00175		
00176		if ( MainMenu == None )
00177			MainMenu = Spawn(MainMenuType, self);
00178			
00179		if ( MainMenu == None )
00180		{
00181			PlayerPawn(Owner).bShowMenu = false;
00182			Level.bPlayersOnly = false;
00183			return;
00184		}
00185		else
00186		{
00187			MainMenu.PlayerOwner = PlayerPawn(Owner);
00188			MainMenu.PlayEnterSound();
00189		}
00190	}
00191	
00192	simulated function DefaultCanvas( canvas Canvas )
00193	{
00194		Canvas.Reset();
00195		Canvas.SpaceX=0;
00196		Canvas.SpaceY=0;
00197		Canvas.bNoSmooth = True;
00198		Canvas.DrawColor.r = 255;
00199		Canvas.DrawColor.g = 255;
00200		Canvas.DrawColor.b = 255;	
00201			
00202		Canvas.Font = Canvas.SmallFont;
00203		/*			//DebugHUD does not support non-latin character sets..
00204		if(MyFonts != None)
00205			Canvas.Font = MyFonts.GetStaticSmallFont();
00206		else
00207			Canvas.Font = Canvas.SmallFont;
00208		*/
00209	}
00210	
00211	simulated function InputNumber(byte F)
00212	{
00213	}
00214	
00215	simulated function ChangeHud(int d)
00216	{
00217		local int newmode;
00218			
00219		newmode = DebugHudMode + d;
00220		if ( newmode > HUD_MAX )
00221			newmode = 0;
00222		else if ( newmode < 0 )
00223			newmode = HUD_MAX;
00224	
00225		SetHudMode(newmode);
00226	}
00227	
00228	simulated function ChangeCrosshair(int d)
00229	{
00230		local int newmode;
00231		
00232		newmode = DebugMode + d;
00233		if (newmode > DEBUG_MAX)
00234			newmode = 0;
00235		else if (newmode < 0)
00236			newmode = DEBUG_MAX;
00237	
00238		SetMode(newmode);
00239	}
00240	
00241	simulated function SetMode(int mode)
00242	{
00243		DebugMode = mode;
00244		GotoState(ModeTable[DebugMode]);
00245	}
00246	
00247	simulated function SetHudMode(int mode)
00248	{
00249		local int oldmode;
00250		oldmode = DebugHudMode;
00251		DebugHudMode = mode;
00252		ChangeHudMode(oldmode, DebugHudMode);
00253	}
00254	
00255	simulated function DrawCrossHair( canvas Canvas, int StartX, int StartY)
00256	{
00257		local PlayerPawn P;
00258		local vector X,Y,Z;
00259	
00260		P = PlayerPawn(Owner);
00261		if ( !P.bShowMenu )
00262		{
00263			GetAxes(PlayerPawn(Owner).ViewRotation,X,Y,Z);
00264			Canvas.DrawLine3D(Owner.Location, Owner.Location+X*5000, 255, 255, 255);
00265		}
00266	}
00267	
00268	// ===================================================================
00269	// NEW DEBUGHUD INFRASTRUCTURE
00270	// ===================================================================
00271	
00272	
00273	// This is the pure virtual interface
00274	simulated function ChooseTarget(){}
00275	simulated function DrawTitle(canvas Canvas){}
00276	simulated function Render(canvas Canvas, int mode){}
00277	simulated function ChangeHudMode(int from, int to){}
00278	simulated function bool RelevantActor(Actor A){}
00279	
00280	
00281	simulated function SetWatch(actor A)
00282	{
00283		if (Watch != None)
00284		{
00285			HudModeShutdown(DebugHudMode, Watch);
00286		}
00287		Watch = A;
00288		if (Watch != None)
00289		{
00290			HudModeInitialize(DebugHudMode, Watch);
00291		}
00292	}
00293	
00294	simulated function PostRender( canvas Canvas )
00295	{
00296		DefaultCanvas(Canvas);
00297	
00298		// Handle ancestor menus
00299		if ( PlayerPawn(Owner) != None )
00300		{
00301			if ( PlayerPawn(Owner).bShowMenu )
00302			{
00303				if ( MainMenu == None )
00304					CreateMenu();
00305				if ( MainMenu != None )
00306					MainMenu.DrawMenu(Canvas);
00307				return;
00308			}
00309		}
00310	
00311		// Draw the title
00312		if (DebugMode != DEBUG_NONE)
00313		{
00314			Canvas.SetPos(Canvas.ClipX-135, Canvas.ClipY-20);
00315			DrawTitle(Canvas);
00316			Canvas.SetPos(Canvas.ClipX-135, Canvas.ClipY-10);
00317			switch(DebugHudMode)
00318			{
00319				case HUD_ACTOR:
00320					Canvas.DrawText(" Mode: Actor Info");
00321					break;
00322				case HUD_SKELETON:
00323					Canvas.DrawText(" Mode: Skeleton");
00324					break;
00325				case HUD_SKELNAMES:
00326					Canvas.DrawText(" Mode: Joint Names");
00327					break;
00328				case HUD_SKELJOINTS:
00329					Canvas.DrawText(" Mode: Collision Joints");
00330					break;
00331				case HUD_SKELAXES:
00332					Canvas.DrawText(" Mode: Joint Axes");
00333					break;
00334				case HUD_LOD:
00335					Canvas.DrawText(" Mode: LOD Polys");
00336					break;
00337				case HUD_POV:
00338					Canvas.DrawText(" Mode: POV");
00339					break;
00340			}
00341		}
00342	
00343		Render(Canvas, HudMode);
00344	}
00345	
00346	simulated function Timer()
00347	{
00348		ChooseTarget();
00349	}
00350	
00351	
00352	
00353	
00354	
00355	
00356	// ==================================================================
00357	// ==================================================================
00358	// Debug Mode States
00359	// ==================================================================
00360	// ==================================================================
00361	
00362	
00363	
00364	// ------------------------------------------------------------------
00365	//
00366	// BlankMode
00367	//
00368	// ------------------------------------------------------------------
00369	State BlankMode
00370	{
00371		simulated function BeginState()
00372		{	// Do one time initialization
00373		}
00374		
00375		simulated function EndState()
00376		{	// Do cleanup
00377		}
00378	
00379		simulated function DrawTitle(canvas Canvas)
00380		{	// Draw the mode title
00381		}
00382	
00383		simulated function ChangeHudMode(int from, int to)
00384		{	// Call ChangeHudModeForActor() on all this mode's actors
00385		}
00386	
00387		simulated function ChooseTarget()
00388		{	// Called at 2 Hz
00389		}
00390	
00391		simulated function Render(canvas Canvas, int mode)
00392		{	// Render the HUD
00393		}
00394	
00395		simulated function bool RelevantActor(Actor A)
00396		{	// Decide if actor is relevant to this set
00397		}
00398	}
00399	
00400	
00401	// ------------------------------------------------------------------
00402	//
00403	// ActorMode
00404	//
00405	// ------------------------------------------------------------------
00406	State ActorMode
00407	{
00408		simulated function BeginState()
00409		{
00410			SetWatch(None);
00411		}
00412		
00413		simulated function EndState()
00414		{
00415		}
00416	
00417		simulated function DrawTitle(canvas Canvas)
00418		{
00419			Canvas.DrawText("Debug Target Actor");
00420		}
00421	
00422		simulated function ChangeHudMode(int from, int to)
00423		{
00424			HudModeShutdown(from, Watch);
00425			HudModeInitialize(to, Watch);
00426		}
00427	
00428		simulated function ChooseTarget()
00429		{
00430			local vector HL,HN,X,Y,Z;
00431			local actor A;
00432			
00433			GetAxes(PlayerPawn(Owner).ViewRotation,X,Y,Z);
00434			foreach TraceActors(class'actor', A, HL, HN, Owner.Location+X*5000, Owner.Location)
00435			{
00436				if ((A != Level) && (A != None))
00437				{
00438					SetWatch(A);
00439				}
00440				break;
00441			}
00442		}
00443		
00444		simulated function Render(canvas Canvas, int mode)
00445		{
00446			DrawCrossHair(Canvas, 0.5 * Canvas.ClipX - 8, 0.5 * Canvas.ClipY - 8);
00447			DrawHUD(Canvas, Watch);
00448		}
00449	}
00450	
00451	
00452	// ------------------------------------------------------------------
00453	//
00454	// ConstantMode
00455	//
00456	// ------------------------------------------------------------------
00457	State ConstantMode
00458	{
00459		simulated function BeginState()
00460		{
00461			SetWatch(None);
00462		}
00463		
00464		simulated function EndState()
00465		{
00466		}
00467	
00468		simulated function DrawTitle(canvas Canvas)
00469		{
00470			Canvas.DrawText("Debug Constant Target");
00471		}
00472	
00473		simulated function ChangeHudMode(int from, int to)
00474		{
00475			HudModeShutdown(from, Watch);
00476			HudModeInitialize(to, Watch);
00477		}
00478	
00479		simulated function ChooseTarget()
00480		{
00481			local vector HL,HN,X,Y,Z;
00482			local actor A;
00483			
00484			if (Owner==None)
00485				return;
00486	
00487			if (Watch == None)
00488			{
00489				GetAxes(PlayerPawn(Owner).ViewRotation,X,Y,Z);
00490				foreach TraceActors(class'actor', A, HL, HN, Owner.Location+X*5000, Owner.Location)
00491				{
00492					if ((A != Level) && (A != None))
00493					{
00494						SetWatch(A);
00495					}
00496					break;
00497				}
00498			}
00499		}
00500		
00501		simulated function Render(canvas Canvas, int mode)
00502		{
00503			if (Watch == None)
00504				DrawCrossHair(Canvas, 0.5 * Canvas.ClipX - 8, 0.5 * Canvas.ClipY - 8);
00505			else
00506			{
00507				// The pawn currently disappears if you switch mode while he's in wireframe
00508				/*
00509				if (Pawn(Owner).LineOfSightTo(Watch))
00510				{
00511					Canvas.DrawActor(Watch, false, false);
00512				}
00513				else
00514				{
00515					Canvas.DrawActor(Watch, true, true);
00516				}
00517				*/
00518				DrawHUD(Canvas, Watch);
00519			}
00520		}
00521	}
00522	
00523	
00524	// ------------------------------------------------------------------
00525	//
00526	// AIMode
00527	//
00528	// ------------------------------------------------------------------
00529	State AIMode
00530	{
00531		simulated function BeginState()
00532		{	// Do one time initialization
00533			local NavigationPoint N;
00534			
00535			SetWatch(None);
00536	//		PlayerPawn(Owner)->bOverheadCamera = true; (must move bOverhead... to PlayerPawn)
00537			foreach AllActors(class'NavigationPoint', N)
00538				N.bHidden = false;
00539		}
00540		
00541		simulated function EndState()
00542		{	// Do cleanup
00543			local NavigationPoint N;
00544			
00545	//		PlayerPawn(Owner)->bOverheadCamera = false; (must move bOverhead... to PlayerPawn)
00546			foreach AllActors(class'NavigationPoint', N)
00547				N.bHidden = true;
00548		}
00549	
00550		simulated function DrawTitle(canvas Canvas)
00551		{	// Draw the mode title
00552			Canvas.DrawText("Debug AI");
00553		}
00554	
00555		simulated function ChangeHudMode(int from, int to)
00556		{	// Call ChangeHudModeForActor() on all this mode's actors
00557			HudModeShutdown(from, Watch);
00558			HudModeInitialize(to, Watch);
00559		}
00560	
00561		simulated function ChooseTarget()
00562		{	// Called at 2 Hz
00563			local vector HL,HN,X,Y,Z;
00564			local actor A;
00565			
00566			if (Watch == None)
00567			{
00568				GetAxes(PlayerPawn(Owner).ViewRotation,X,Y,Z);
00569				foreach TraceActors(class'actor', A, HL, HN, Owner.Location+X*5000, Owner.Location)
00570				{
00571					if ((A != Level) && (A != None))
00572					{
00573						SetWatch(A);
00574					}
00575					break;
00576				}
00577			}
00578		}
00579	
00580		simulated function Render(canvas Canvas, int mode)
00581		{	// Render the HUD
00582			DrawNavPoints(Canvas);
00583			Canvas.SetOrigin(0,0);
00584			if (Watch == None)
00585				DrawCrossHair(Canvas, 0.5 * Canvas.ClipX - 8, 0.5 * Canvas.ClipY - 8);
00586			else
00587			{
00588				// The pawn currently disappears if you switch mode while he's in wireframe
00589				/*
00590				if (Pawn(Owner).LineOfSightTo(Watch))
00591				{
00592					Canvas.DrawActor(Watch, false, false);
00593				}
00594				else
00595				{
00596					Canvas.DrawActor(Watch, true, true);
00597				}
00598				*/
00599				DrawHUD(Canvas, Watch);
00600				if (DebugHudMode != HUD_POV && DebugHudMode != HUD_ACTOR)
00601					DrawViewFrom(Canvas, Watch);
00602			}
00603		}
00604	}
00605	
00606	
00607	// ------------------------------------------------------------------
00608	//
00609	// PlayerMode
00610	//
00611	// ------------------------------------------------------------------
00612	State PlayerMode
00613	{
00614		simulated function BeginState()
00615		{	// Do one time initialization
00616		}
00617		
00618		simulated function EndState()
00619		{	// Do cleanup
00620		}
00621	
00622		simulated function DrawTitle(canvas Canvas)
00623		{	// Draw the mode title
00624			Canvas.DrawText("Debug Player");
00625		}
00626	
00627		simulated function ChangeHudMode(int from, int to)
00628		{
00629			HudModeShutdown(from, Watch);
00630			HudModeInitialize(to, Watch);
00631		}
00632	
00633		simulated function ChooseTarget()
00634		{	// Called at 2 Hz
00635			SetWatch(Owner);
00636		}
00637	
00638		simulated function Render(canvas Canvas, int mode)
00639		{	// Render the HUD
00640			DrawHUD(Canvas, Watch);
00641		}
00642	}
00643	
00644	
00645	// ------------------------------------------------------------------
00646	//
00647	// VisibleMode
00648	//
00649	// ------------------------------------------------------------------
00650	State VisibleMode
00651	{
00652		simulated function BeginState()
00653		{	// Do one time initialization
00654			local actor A;
00655			foreach AllActors(class'actor', A)
00656			{
00657				HudModeInitialize(DebugHudMode, A);
00658			}
00659		}
00660		
00661		simulated function EndState()
00662		{	// Do cleanup
00663			local actor A;
00664			foreach AllActors(class'actor', A)
00665			{
00666				HudModeShutdown(DebugHudMode, A);
00667			}
00668		}
00669	
00670		simulated function DrawTitle(canvas Canvas)
00671		{	// Draw the mode title
00672			Canvas.DrawText("Debug Visible Actors");
00673		}
00674	
00675		simulated function ChangeHudMode(int from, int to)
00676		{
00677			local actor A;
00678			foreach AllActors(class'actor', A)
00679			{
00680				HudModeShutdown(from, A);
00681				HudModeInitialize(to, A);
00682			}
00683		}
00684	
00685		simulated function ChooseTarget()
00686		{	// Called at 2 Hz
00687		}
00688	
00689		simulated function Render(canvas Canvas, int mode)
00690		{	// Render the HUD
00691			local actor A;
00692			local int sx,sy;
00693			
00694			foreach Owner.VisibleActors(class'actor', A)
00695			{
00696				Canvas.TransformPoint(A.Location, sx, sy);
00697				Canvas.SetOrigin(sx,sy);
00698				DrawHUD(Canvas, A);
00699			}
00700		}
00701	}
00702	
00703	
00704	// ------------------------------------------------------------------
00705	//
00706	// LevelMode
00707	//
00708	// ------------------------------------------------------------------
00709	State LevelMode
00710	{
00711		simulated function BeginState()
00712		{	// Do one time initialization
00713			local LevelInfo L;
00714			Owner.ConsoleCommand("rmode 3");
00715			foreach AllActors(class'LevelInfo', L)
00716				L.bHidden = false;
00717		}
00718		
00719		simulated function EndState()
00720		{	// Do cleanup
00721			local LevelInfo L;
00722			Owner.ConsoleCommand("rmode 5");
00723			foreach AllActors(class'LevelInfo', L)
00724				L.bHidden = true;
00725		}
00726	
00727		simulated function DrawTitle(canvas Canvas)
00728		{	// Draw the mode title
00729			Canvas.DrawText("Debug Level");
00730		}
00731	
00732		simulated function ChangeHudMode(int from, int to)
00733		{
00734			HudModeShutdown(from, Watch);
00735			HudModeInitialize(to, Watch);
00736		}
00737	
00738		simulated function ChooseTarget()
00739		{	// Called at 2 Hz
00740			SetWatch(Owner.Level);
00741		}
00742	
00743		simulated function Render(canvas Canvas, int mode)
00744		{	// Render the HUD
00745	//		DrawHUD(Canvas, Watch);
00746			DrawDebugActor(Canvas, Watch);
00747		}
00748	}
00749	
00750	
00751	// ------------------------------------------------------------------
00752	//
00753	// ZoneMode
00754	//
00755	// ------------------------------------------------------------------
00756	State ZoneMode
00757	{
00758		simulated function BeginState()
00759		{	// Do one time initialization
00760			local ZoneInfo A;
00761			Owner.ConsoleCommand("rmode 2");
00762			foreach AllActors(class'ZoneInfo', A)
00763				A.bHidden = false;
00764		}
00765		
00766		simulated function EndState()
00767		{	// Do cleanup
00768			local ZoneInfo A;
00769			Owner.ConsoleCommand("rmode 5");
00770			foreach AllActors(class'ZoneInfo', A)
00771				A.bHidden = true;
00772		}
00773	
00774		simulated function DrawTitle(canvas Canvas)
00775		{	// Draw the mode title
00776			Canvas.DrawText("Debug Zone");
00777		}
00778	
00779		simulated function ChangeHudMode(int from, int to)
00780		{
00781			HudModeShutdown(from, Watch);
00782			HudModeInitialize(to, Watch);
00783		}
00784	
00785		simulated function ChooseTarget()
00786		{	// Called at 2 Hz
00787			SetWatch(Owner.Region.Zone);
00788		}
00789	
00790		simulated function Render(canvas Canvas, int mode)
00791		{	// Render the HUD
00792			DrawHUD(Canvas, Watch);
00793		}
00794	}
00795	
00796	
00797	// ------------------------------------------------------------------
00798	//
00799	// LightMode
00800	//
00801	// ------------------------------------------------------------------
00802	State LightMode
00803	{
00804		simulated function BeginState()
00805		{	// Do one time initialization
00806			local Light A;
00807			foreach AllActors(class'Light', A)
00808				A.bHidden = false;
00809		}
00810		
00811		simulated function EndState()
00812		{	// Do cleanup
00813			local Light A;
00814			foreach AllActors(class'Light', A)
00815				A.bHidden = true;
00816		}
00817	
00818		simulated function DrawTitle(canvas Canvas)
00819		{	// Draw the mode title
00820			Canvas.DrawText("Debug Lights");
00821		}
00822	
00823		simulated function ChangeHudMode(int from, int to)
00824		{
00825		}
00826	
00827		simulated function ChooseTarget()
00828		{	// Called at 2 Hz
00829		}
00830	
00831		simulated function Render(canvas Canvas, int mode)
00832		{	// Render the HUD
00833			local Light L;
00834			local int sx,sy;
00835			
00836			foreach Owner.VisibleActors(class'light', L)
00837			{
00838				DrawLightActor(Canvas, L);
00839				Canvas.TransformPoint(L.Location, sx, sy);
00840				Canvas.SetOrigin(sx,sy);
00841				DrawHUD(Canvas, L);
00842			}
00843		}
00844	}
00845	
00846	
00847	// ------------------------------------------------------------------
00848	//
00849	// NavPointMode
00850	//
00851	// ------------------------------------------------------------------
00852	State NavPointMode
00853	{
00854		simulated function BeginState()
00855		{	// Do one time initialization
00856			local NavigationPoint N;
00857			foreach AllActors(class'NavigationPoint', N)
00858				N.bHidden = false;
00859		}
00860		
00861		simulated function EndState()
00862		{	// Do cleanup
00863			local NavigationPoint N;
00864			foreach AllActors(class'NavigationPoint', N)
00865				N.bHidden = true;
00866		}
00867	
00868		simulated function DrawTitle(canvas Canvas)
00869		{
00870			Canvas.DrawText("Debug NavPoints");
00871		}
00872	
00873		simulated function ChangeHudMode(int from, int to)
00874		{
00875		}
00876	
00877		simulated function ChooseTarget()
00878		{
00879		}
00880	
00881		simulated function Render(canvas Canvas, int mode)
00882		{
00883			DrawNavPoints(Canvas);
00884		}
00885	}
00886	
00887	
00888	// ------------------------------------------------------------------
00889	//
00890	// TriggerMode
00891	//
00892	// ------------------------------------------------------------------
00893	State TriggerMode
00894	{
00895		simulated function bool RelevantActor(Actor A)
00896		{
00897			return
00898			(
00899				A.Event != '' ||
00900				(ZoneInfo(A) != None && (ZoneInfo(A).ZonePlayerEvent != '' || ZoneInfo(A).ZonePlayerExitEvent != '')) ||
00901				PolyObj(A) != None ||
00902				Mover(A) != None ||
00903				Triggers(A) != None
00904			);
00905		}
00906	
00907		simulated function BeginState()
00908		{	// Do one time initialization
00909			local Actor A;
00910			foreach AllActors(class'Actor', A)
00911				if (RelevantActor(A))
00912					A.bHidden = false;
00913		}
00914		
00915		simulated function EndState()
00916		{	// Do cleanup
00917			local Actor A;
00918			foreach AllActors(class'Actor', A)
00919				if (RelevantActor(A))
00920					A.bHidden = A.Default.bHidden;
00921		}
00922	
00923		simulated function DrawTitle(canvas Canvas)
00924		{
00925			Canvas.DrawText("Debug Triggers");
00926		}
00927	
00928		simulated function ChangeHudMode(int from, int to)
00929		{
00930		}
00931	
00932		simulated function ChooseTarget()
00933		{
00934		}
00935	
00936		simulated function Render(canvas Canvas, int mode)
00937		{
00938			DrawTriggers(Canvas);
00939		}
00940	}
00941	
00942	
00943	
00944	// ==================================================================
00945	// ==================================================================
00946	// Hud Mode functions (sub-modes)
00947	// ==================================================================
00948	// ==================================================================
00949	
00950	simulated function HudModeInitialize(int mode, actor A)
00951	{
00952		if (A==None)
00953			return;
00954	
00955		// Entering this mode
00956		switch(mode)
00957		{
00958			case HUD_ACTOR:
00959			case HUD_LOD:
00960			case HUD_NETWORK:
00961				break;
00962			case HUD_POV:
00963				break;
00964			case HUD_SKELETON:
00965				if (A.Skeletal != None)
00966				{
00967					A.Style = STY_TRANSLUCENT;
00968					A.bDrawSkel = true;
00969				}
00970				break;
00971			case HUD_SKELNAMES:
00972				if (A.Skeletal != None)
00973				{
00974					A.Style = STY_TRANSLUCENT;
00975					A.bDrawSkel = true;
00976				}
00977				break;
00978			case HUD_SKELJOINTS:
00979				if (A.Skeletal != None)
00980				{
00981					A.Style = STY_TRANSLUCENT;
00982					A.bDrawSkel = true;
00983					A.bDrawJoints = true;
00984				}
00985				break;
00986			case HUD_SKELAXES:
00987				if (A.Skeletal != None)
00988				{
00989					A.Style = STY_TRANSLUCENT;
00990					A.bDrawSkel = true;
00991					A.bDrawAxes = true;
00992				}
00993				break;
00994	
00995		}
00996	}
00997	
00998	simulated function HudModeShutdown(int mode, actor A)
00999	{
01000		if (A==None)
01001			return;
01002	
01003		// Leaving this mode
01004		switch(mode)
01005		{
01006			case HUD_ACTOR:
01007			case HUD_LOD:
01008			case HUD_POV:
01009			case HUD_NETWORK:
01010				break;
01011	
01012			case HUD_SKELETON:
01013				A.Style = A.default.Style;
01014				A.bDrawSkel = false;
01015				break;
01016			case HUD_SKELNAMES:
01017				A.Style = A.default.Style;
01018				A.bDrawSkel = false;
01019				break;
01020			case HUD_SKELJOINTS:
01021				A.Style = A.default.Style;
01022				A.bDrawSkel = false;
01023				A.bDrawJoints = false;
01024				break;
01025			case HUD_SKELAXES:
01026				A.Style = A.default.Style;
01027				A.bDrawSkel = false;
01028				A.bDrawAxes = false;
01029				break;
01030		}
01031	}
01032	
01033	simulated function DrawHUD(canvas Canvas, actor A)
01034	{
01035		local int actorX, actorY;
01036		
01037		if (A==None)
01038			return;
01039	
01040		actorX = Canvas.OrgX;
01041		actorY = Canvas.OrgY;
01042		
01043		Canvas.SetPos(0,0);
01044	
01045		switch(DebugHudMode)
01046		{
01047			case HUD_ACTOR:
01048				Canvas.SetOrigin(Canvas.default.OrgX, Canvas.default.OrgY);
01049				DrawActorCylinder(Canvas, A);
01050				DrawActorVectors(Canvas, A);
01051		
01052				Canvas.SetOrigin(actorX, actorY);
01053				DrawDebugActor(Canvas, A);
01054				break;
01055	
01056			case HUD_NETWORK:
01057				Canvas.SetOrigin(Canvas.default.OrgX, Canvas.default.OrgY);
01058				DrawActorCylinder(Canvas, A);
01059				Canvas.SetOrigin(actorX, actorY);
01060				DrawDebugActorNet(Canvas, A);
01061				break;
01062	
01063			case HUD_SKELETON:
01064				DrawDebugActor(Canvas, A);
01065				break;
01066	
01067			case HUD_SKELNAMES:
01068				Canvas.SetOrigin(Canvas.default.OrgX, Canvas.default.OrgY);
01069				DrawActorJointNames(Canvas, A);
01070				Canvas.SetOrigin(actorX, actorY);
01071				DrawDebugActor(Canvas, A);
01072				break;
01073				
01074			case HUD_SKELJOINTS:
01075				DrawDebugActor(Canvas, A);
01076				break;
01077				
01078			case HUD_SKELAXES:
01079				DrawDebugActor(Canvas, A);
01080				break;
01081				
01082			case HUD_LOD:
01083				Canvas.SetOrigin(Canvas.default.OrgX, Canvas.default.OrgY);
01084				DrawPolyCount(Canvas, A);
01085				break;
01086				
01087			case HUD_POV:
01088				if (DebugMode < DEBUG_MULTIPLE)
01089				{
01090					DrawViewFrom(Canvas, A);
01091				}
01092				break;
01093		}
01094		
01095		Canvas.SetColor(255, 255, 255);
01096	}
01097	
01098	// ==================================================================
01099	// Debug info drawing routines
01100	// ==================================================================
01101	
01102	simulated function DrawActorVectors(canvas Canvas, actor A)
01103	{
01104		local vector X,Y,Z;
01105	
01106		// Draw orientation coordinate frame
01107		GetAxes(A.Rotation,X,Y,Z);
01108		X *= 10;
01109		Y *= 10;
01110		Z *= 10;
01111		Canvas.DrawLine3D(A.Location, A.Location+X, 10,  0,  0);
01112		Canvas.DrawLine3D(A.Location, A.Location+Y,  0, 10,  0);
01113		Canvas.DrawLine3D(A.Location, A.Location+Z,  0,  0, 10);
01114	
01115		// Draw these vectors from top of cyllinder
01116		X = A.Location;
01117		X.Z += A.CollisionHeight;
01118			
01119		// Draw Velocity vector
01120		Canvas.DrawLine3D(X, X+A.Velocity, 0, 150, 200);
01121		
01122		// Draw Acceleration vector
01123		Canvas.DrawLine3D(X, X+A.Acceleration, 30, 0, 20);
01124	}
01125	
01126	simulated function DrawActorCylinder(canvas Canvas, actor A)
01127	{
01128		local vector Extents;
01129		
01130		Canvas.SetColor(255,0,0);
01131		Extents.X = A.CollisionRadius;
01132		Extents.Y = A.CollisionRadius;
01133		Extents.Z = A.CollisionHeight;
01134		Canvas.DrawBox3D(A.Location, Extents, 10, 10, 10);
01135	}
01136	
01137	simulated function DrawActorJointNames(canvas Canvas, actor A)
01138	{
01139		local int i, sx, sy;
01140		local vector jointpos;
01141		local string flags;
01142		
01143		if (A.Skeletal != None)
01144		{
01145			if (PlayerPawn(A)!=None && !Pawn(A).bBehindView)
01146				return;
01147			
01148			for (i=0; i<A.NumJoints(); i++)
01149			{
01150				jointpos = A.GetJointPos(i);
01151				flags = "";
01152				if (A.JointFlags[i] != 0)
01153				{
01154					flags = "(";
01155					if ((A.JointFlags[i] & JOINT_FLAG_SPRINGPOINT)!=0)
01156						flags = flags $ "S";
01157					if ((A.JointFlags[i] & JOINT_FLAG_ACCELERATIVE)!=0)
01158						flags = flags $ "A";
01159					if ((A.JointFlags[i] & JOINT_FLAG_GRAVJOINT)!=0)
01160						flags = flags $ "G";
01161					if ((A.JointFlags[i] & JOINT_FLAG_BLENDJOINT)!=0)
01162						flags = flags $ "B";
01163					if ((A.JointFlags[i] & JOINT_FLAG_IKCHAIN)!=0)
01164						flags = flags $ "I";
01165					if ((A.JointFlags[i] & JOINT_FLAG_COLLISION)!=0)
01166						flags = flags $ "C";
01167					if ((A.JointFlags[i] & JOINT_FLAG_ABSPOSITION)!=0)
01168						flags = flags $ "P";
01169					if ((A.JointFlags[i] & JOINT_FLAG_ABSROTATION)!=0)
01170						flags = flags $ "R";
01171					flags = flags$")";
01172				}
01173				Canvas.TransformPoint(jointpos, sx, sy);
01174				Canvas.SetPos(sx,sy);
01175				Canvas.SetColor(255,255,255);
01176				Canvas.DrawText(A.GetJointName(i)@flags);
01177			}
01178		}
01179	}
01180	
01181	simulated function DrawPolyCount(canvas Canvas, actor A)
01182	{
01183		local int sx, sy;
01184	
01185		if(A.Skeletal != None)
01186		{
01187			Canvas.TransformPoint(A.Location, sx, sy);
01188			Canvas.SetPos(sx,sy);
01189			Canvas.SetColor(255,255,0);
01190			Canvas.DrawText("" $A.LODPolyCount);
01191		}
01192	}
01193	
01194	
01195	simulated function DrawNavPoints(canvas Canvas)
01196	{
01197		local NavigationPoint A;
01198		local int sx, sy;
01199	
01200		Canvas.SetPos(Canvas.ClipX-135, Canvas.ClipY-30);
01201		switch(DebugHudMode)
01202		{
01203			case HUD_ACTOR:			// Normal paths
01204				Canvas.DrawText("Paths");
01205				break;
01206			case HUD_SKELETON:		// VisNoReach paths
01207				Canvas.DrawText("VisNoReach Paths");
01208				break;
01209			case HUD_SKELNAMES:		// Pruned paths
01210				Canvas.DrawText("Pruned Paths");
01211				break;
01212			case HUD_SKELJOINTS:	// Radii/Height Tubes
01213				Canvas.DrawText("Collision Thresholds");
01214				break;
01215			case HUD_SKELAXES:		// End point info
01216				Canvas.DrawText("End Point Info");
01217				break;
01218			case HUD_LOD:
01219				Canvas.DrawText("Misc info");
01220				break;
01221			case HUD_POV:
01222				Canvas.DrawText("None");
01223				break;
01224		}		
01225		
01226		foreach Owner.VisibleActors(class'NavigationPoint', A)
01227		{
01228			Canvas.TransformPoint(A.Location, sx, sy);
01229			Canvas.SetOrigin(sx, sy);
01230			Canvas.SetPos(0, 0);
01231			Canvas.SetColor(255,255,255);
01232			Canvas.DrawText(A.Name);
01233			Canvas.CurY -= 8;
01234	
01235			Canvas.SetOrigin(0, 0);
01236			A.Debug(Canvas, DebugHudMode);
01237		}
01238	}
01239	
01240	
01241	simulated function DrawTriggers(canvas Canvas)
01242	{
01243		local Actor A;
01244		local int sx, sy;
01245	
01246		Canvas.SetPos(Canvas.ClipX-135, Canvas.ClipY-30);
01247	/*	switch(DebugHudMode)
01248		{
01249			case HUD_ACTOR:			// Normal paths
01250				Canvas.DrawText("Paths");
01251				break;
01252			case HUD_SKELETON:		// VisNoReach paths
01253				Canvas.DrawText("VisNoReach Paths");
01254				break;
01255			case HUD_SKELNAMES:		// Pruned paths
01256				Canvas.DrawText("Pruned Paths");
01257				break;
01258			case HUD_SKELJOINTS:	// Radii/Height Tubes
01259				Canvas.DrawText("Collision Thresholds");
01260				break;
01261			case HUD_SKELAXES:		// End point info
01262				Canvas.DrawText("End Point Info");
01263				break;
01264			case HUD_LOD:
01265				Canvas.DrawText("Misc info");
01266				break;
01267			case HUD_POV:
01268				Canvas.DrawText("None");
01269				break;
01270		}		
01271	*/
01272	
01273		foreach Owner.VisibleActors(class'Actor', A)
01274		{
01275			if (RelevantActor(A))
01276			{
01277				Canvas.SetOrigin(Canvas.default.OrgX, Canvas.default.OrgY);
01278	
01279				DrawActorCylinder(Canvas, A);
01280	
01281				Canvas.TransformPoint(A.Location, sx, sy);
01282				Canvas.SetOrigin(sx, sy);
01283				Canvas.SetPos(0, 0);
01284				Canvas.SetColor(255,255,0);
01285	
01286				A.Debug(Canvas, HUD_SCRIPT);
01287			}
01288		}
01289	}
01290	
01291	
01292	
01293	function HSV_to_RGB(int H, int S, int V, out int R, out int G, out int B)
01294	{
01295		local float brightness;
01296		local vector hue,rgb;
01297		
01298		Brightness = V * 1.4 / 255.0;
01299		Brightness *= 0.70 / (0.01 + Sqrt(Brightness));
01300		Brightness  = Clamp(Brightness, 0.0, 1.0);
01301		if (H<86)
01302		{
01303			hue.X = (85-H)/85.0;
01304			hue.Y = H/85.0;
01305			hue.Z = 0;
01306		}
01307		else if (H<171)
01308		{
01309			hue.X = 0;
01310			hue.Y = (170-H)/85.0;
01311			hue.Z = (H-85)/85.0;
01312		}
01313		else
01314		{
01315			hue.X = (H-170)/85.0;
01316			hue.Y = 0;
01317			hue.Z = (255-H)/84.0;
01318		}
01319	
01320		rgb = (hue + (S/255.0) * (vect(1,1,1) - hue)) * Brightness;
01321		R = rgb.X;
01322		G = rgb.Y;
01323		B = rgb.Z;
01324	}
01325	
01326	simulated function DrawLightActor(canvas Canvas, actor A)
01327	{
01328		local int R,G,B;
01329		local vector extents;
01330		
01331		HSV_to_RGB(A.LightHue,A.LightSaturation,A.LightBrightness,R,G,B);
01332		Canvas.SetColor(R,G,B);
01333		extents.X = A.LightRadius;
01334		extents.Y = A.LightRadius;
01335		extents.Z = A.LightRadius;
01336		Canvas.DrawBox3D(A.Location, extents, R, G, B);
01337	}
01338	
01339	simulated function DrawViewFrom(canvas Canvas, actor A)
01340	{
01341		local rotator rot;
01342		local vector loc;
01343		
01344		A.bHidden = true;
01345		rot = A.Rotation;
01346		if (Pawn(A) != None)
01347			rot = rot + Pawn(A).LookAngle;
01348		loc = A.Location;
01349	//When GetJointPos() is decoupled from render, this can be put back in
01350	/*	if (A.Skeletal != None && A.JointNamed('head') != 0)
01351			loc = A.GetJointPos(A.JointNamed('head'));*/
01352		Canvas.DrawPortal(Canvas.ClipX-160, 0, 160, 120, A, loc, rot, 90, true );
01353		A.bHidden = A.default.bHidden;
01354		
01355		Canvas.SetPos(600, 470);
01356	//	Canvas.SetPos(Canvas.ClipX-150, 110);
01357		Canvas.DrawText(A.Name@"CAM");
01358	}
01359	
01360	simulated function DrawDebugActor(canvas Canvas, actor A)
01361	{
01362		Canvas.SetColor(255, 0, 0);
01363		A.Debug(Canvas, DebugMode);
01364	}
01365	
01366	simulated function name GetRoleName(ENetRole theRole)
01367	{
01368		switch(theRole)
01369		{
01370		case ROLE_None:				return 'ROLE_None';
01371		case ROLE_DumbProxy:		return 'ROLE_DumbProxy';
01372		case ROLE_SimulatedProxy:	return 'ROLE_SimulatedProxy';
01373		case ROLE_AutonomousProxy:	return 'ROLE_AutonomousProxy';
01374		case ROLE_Authority:		return 'ROLE_Authority';
01375		}
01376	}
01377	
01378	simulated function DrawDebugActorNet(canvas Canvas, actor A)
01379	{
01380		Canvas.SetColor(255, 0, 0);
01381	//	A.Debug(Canvas, DebugMode);
01382	
01383		Canvas.DrawText("Name: "@A.name);
01384		Canvas.CurY -= 8;
01385		Canvas.DrawText("Class:"@A.class);
01386		Canvas.CurY -= 8;
01387		Canvas.DrawText("State:"@A.GetStateName());
01388		Canvas.CurY -= 8;
01389		Canvas.DrawText("Owner:"@A.Owner);
01390		Canvas.CurY -= 8;
01391		Canvas.DrawText("Role:       "@GetRoleName(A.Role));
01392		Canvas.CurY -= 8;
01393		Canvas.DrawText("RemoteRole: "@GetRoleName(A.RemoteRole));
01394		Canvas.CurY -= 8;
01395		Canvas.DrawText("bNetOwner:     "@A.bNetOwner);
01396		Canvas.CurY -= 8;
01397		Canvas.DrawText("bNetInitial:   "@A.bNetInitial);
01398		Canvas.CurY -= 8;
01399		Canvas.DrawText("bSimulatedPawn:"@A.bSimulatedPawn);
01400		Canvas.CurY -= 8;
01401		Canvas.DrawText("bIsPawn:       "@A.bIsPawn);
01402		Canvas.CurY -= 8;
01403		Canvas.DrawText("bClientAnim:   "@A.bClientAnim);
01404		Canvas.CurY -= 8;
01405		Canvas.DrawText("SimAnimFrame:  "@A.SimAnim.X*0.0001$"/"$A.AnimFrame);
01406		Canvas.CurY -= 8;
01407		Canvas.DrawText("SimAnimRate:   "@A.SimAnim.Y*0.0002$"/"$A.AnimRate);
01408		Canvas.CurY -= 8;
01409		Canvas.DrawText("SimTweenRate:  "@A.SimAnim.Z*0.001$"/"$A.TweenRate);
01410		Canvas.CurY -= 8;
01411		Canvas.DrawText("SimAnimLast:   "@A.SimAnim.w*0.0001$"/"$A.AnimLast);
01412		Canvas.CurY -= 8;
01413		Canvas.DrawText("bSimFall:      "@A.bSimFall);
01414		Canvas.CurY -= 8;
01415		Canvas.DrawText("bNetOptional:  "@A.bNetOptional);
01416		Canvas.CurY -= 8;
01417		Canvas.DrawText("bNetTemporary: "@A.bNetTemporary);
01418		Canvas.CurY -= 8;
01419	}
01420	
01421	defaultproperties
01422	{
01423	}

End Source Code