Results 1 to 13 of 13
  1. #1
    MSgt. Shooter Person
    Join Date
    Aug 2010
    Location
    Australia
    Posts
    150

    Default Drawing overlays with PostRenderFor

    I'm having trouble getting my pawns to draw on the hud. I've read various threads about it but I'm still having problems. Related threads:

    http://forums.epicgames.com/threads/...ing?p=28923356
    http://forums.epicgames.com/threads/...=PostRenderFor

    I've attached my code below. Basically I can see in the log that the enemypawn is indeed in the PostRenderedActors array, but for some reason its PostRenderFor() never gets called. I can see in the above code that they have PlayerReplicationInfo = Spawn(class'PlayerReplicationInfo'); in their postBeginPlay() - but why is that relevant?

    Am I better off just looping through the actors myself and calling PostRenderedActors[i].PostRenderFor(...) ?


    Code:
    class MPHUD extends HUD;
    
    ...
    
    
    function DrawHUD() {
    	local vector ViewPoint;
    	local rotator ViewRotation;
    
    	// *** From HUD *****
    	if ( bShowOverlays && (PlayerOwner != None) )
    	{
    		Canvas.Font = GetFontSizeIndex(0);
    		PlayerOwner.GetPlayerViewPoint(ViewPoint, ViewRotation);
    		`log("Drawing actor overlays! num registered = "$ PostRenderedActors.length);
    		`log("actor 0  = " $ PostRenderedActors[0]);
    		
    		DrawActorOverlays(Viewpoint, ViewRotation);
    	}
    	PlayerOwner.DrawHud( Self );	
    }
    
    DefaultProperties
    {
    	bShowOverlays=true;
    }
    Code:
    class MPPawnEnemy extends UTPawn ;
    
    ...
    
    simulated event PostBeginPlay() 
    {
    
    	...
    	MPGameInfo(WorldInfo.Game).mphud.AddPostRenderedActor(self);
    	
    }
    
    simulated event PostRenderFor(PlayerController PC, Canvas Canvas, Object.Vector CameraPosition, Object.Vector CameraDir) 
    {
    	`log("post render called!");
    	canvas.setPos(200,200);
    	canvas.DrawText("TEST POST RENDER!");
    }

  2. #2
    Palace Guard

    Join Date
    Jun 2007
    Location
    Christchurch
    Posts
    3,781

    Default

    Your game info should not have a reference to the HUD? How are you doing that?

  3. #3
    MSgt. Shooter Person
    Join Date
    Aug 2010
    Location
    Australia
    Posts
    150

    Default

    Ah yes when I started hacking things together I had my Hud class register itself with my gameinfo class so that it could be accessed by other components. My hud class is created in the usual way in the PostBeginPlay of my gameinfo class

  4. #4
    Boomshot
    Join Date
    Aug 2011
    Posts
    2,920

    Default

    Try adding these to your pawn.

    Code:
    DefaultProperties
    {
        bPostRenderOtherTeam = true
        bPostRenderIfNotVisible = true
    }

  5. #5
    MSgt. Shooter Person
    Join Date
    Aug 2010
    Location
    Australia
    Posts
    150

    Default

    Thanks Spoof, I tried that and it didn't work.

    I've ended up just looping through the registered actors and calling their PostRenderFor() functions manually - seems to work fine. Not sure how much I lose by doing that vs the native function.

  6. #6

    Default

    Quote Originally Posted by paco View Post
    Thanks Spoof, I tried that and it didn't work.

    I've ended up just looping through the registered actors and calling their PostRenderFor() functions manually - seems to work fine. Not sure how much I lose by doing that vs the native function.
    I'm having the same problem, and I'm interested in finding a better answer. As I understand it, calling the function manually won't work due to replication issues. Replication is still a scary word for me, but (I think) it means in a multiplayer environment the canvas drawings won't occur to each player.

    The code I'm using is (almost) identical to that shown here : http://forums.epicgames.com/threads/...ing?p=28923356

    DebugGame.uc
    Code:
    class DebugGame extends SimpleGame;
    
    defaultproperties
    {
        DefaultPawnClass=class'Sand.DebugPawn'    
        HUDType=class'DebugHUD'
    }
    DebugHUD.uc
    Code:
    class DebugHUD extends HUD;
    
    function PostRender()
    {	
        local DebugPawn DebugPawn;
        local Vector CameraLocation;
        local Rotator CameraRotation;
    
        Super.PostRender();
    
        ForEach DynamicActors(class'DebugPawn', DebugPawn)
        {
            AddPostRenderedActor(DebugPawn);
        }
    
        if (PlayerOwner != None)
        {
            PlayerOwner.GetPlayerViewpoint(CameraLocation, CameraRotation);
            LogInternal("Calling DrawActorOverlays. PostRenderActors size : "$PostRenderedActors.Length$" CameraLocation "$CameraLocation);
            DrawActorOverlays(CameraLocation, CameraRotation);
        }
    }
    
    defaultproperties
    {
    }
    DebugPawn.uc
    Code:
    class DebugPawn extends UDKPawn
    placeable;
    
    var DynamicLightEnvironmentComponent LightEnvironment;
    
    simulated function PostBeginPlay()
    {
        LogInternal("Hello From DebugPawn : "$Name);
        Super.PostBeginPlay();
        PlayerReplicationInfo = Spawn(class'PlayerReplicationInfo');
    }
    
    simulated function PostRenderFor(PlayerController PC, Canvas Canvas, vector CameraPosition, vector CameraDir)
    {
        `Log("PostRenderFor("$PC$","$Canvas$","$CameraPosition$","$CameraDir$")");
        ScriptTrace();
        Super.PostRenderFor(PC, Canvas, CameraPosition, CameraDir);	
    }
    
    defaultproperties
    {
        Begin Object Class=DynamicLightEnvironmentComponent Name=MyLightEnvironment
            bSynthesizeSHLight=TRUE
            bIsCharacterLightEnvironment=TRUE
            bUseBooleanEnvironmentShadowing=FALSE
        End Object
    
        Components.Add(MyLightEnvironment)
        LightEnvironment=MyLightEnvironment
    
        Begin Object Class=SkeletalMeshComponent Name=WPawnSkeletalMeshComponent
            bCacheAnimSequenceNodes=FALSE
            AlwaysLoadOnClient=true
            AlwaysLoadOnServer=true
            bOwnerNoSee=true
            CastShadow=true
            BlockRigidBody=TRUE
            bUpdateSkelWhenNotRendered=false
            bIgnoreControllersWhenNotRendered=TRUE
            bUpdateKinematicBonesFromAnimation=true
            bCastDynamicShadow=true
            Translation=(Z=8.0)
            RBChannel=RBCC_Untitled3
            RBCollideWithChannels=(Untitled3=true)
            LightEnvironment=MyLightEnvironment
            bOverrideAttachmentOwnerVisibility=true
            bAcceptsDynamicDecals=FALSE
            AnimTreeTemplate=AnimTree'CH_AnimHuman_Tree.AT_CH_Human'
            bHasPhysicsAssetInstance=true
            TickGroup=TG_PreAsyncWork
            MinDistFactorForKinematicUpdate=0.2
            bChartDistanceFactor=true
            RBDominanceGroup=20
            Scale=1.075
            bUseOnePassLightingOnTranslucency=TRUE
            bPerBoneMotionBlur=true
        End Object
        Mesh=WPawnSkeletalMeshComponent
        Components.Add(WPawnSkeletalMeshComponent)
    
        TeamBeaconMaxDist=16384.f
        bPostRenderOtherTeam=true
        bPostRenderIfNotVisible=true
    }
    Here is a snippet from the log when I run : > UDK.exe DevMap_Indoor_01?game=Sand.DebugGame -log

    Code:
    
    [0003.88] Log: LoadMap: DevMap_Indoor_01?Name=Player?Team=255?game=Sand.DebugGame
    [0003.95] Log:
    [0003.95] DevMemory: Memory allocations reported by the OS: 301.92 MB (with 0.00 MB waste)
    [0003.96] DevMemory: Virtual memory tracked in the allocators: 122.57 MB (with 111.85 MB used, 3.01 MB slack and 7.72 MB waste)
    [0004.66] Log: Game class is 'DebugGame'
    [0004.70] Log: Primary PhysX scene will be in software.
    [0004.70] Log: Creating Primary PhysX Scene.
    [0004.70] Log: Bringing World DevMap_Indoor_01.TheWorld up for play (0) at 2012.04.08-19.10.26
    [0004.72] Log: Bringing up level for play took: 0.048020
    [0004.73] ScriptLog: Hello From DebugPawn : DebugPawn_0
    [0004.74] Error: Can't start an online game that hasn't been created
    [0004.74] Error: StartLocalVoiceProcessing(): Device is currently owned by another user
    [0004.74] Log: ########### Finished loading level: 0.867289 seconds
    [0004.75] Init: Game engine initialized
    [0004.75] Log: Initializing Engine Completed
    [0005.24] Log: >>>>>>>>>>>>>> Initial startup: 5.24s <<<<<<<<<<<<<<<
    [0005.29] ScriptLog: Calling DrawActorOverlays. PostRenderActors size : 1 CameraLocation -352.00,0.00,-110.85
    [0005.29] ScriptLog: Calling DrawActorOverlays. PostRenderActors size : 1 CameraLocation -352.00,0.00,-110.85
    [0005.29] ScriptLog: Calling DrawActorOverlays. PostRenderActors size : 1 CameraLocation -352.00,0.00,-110.85
    So, I'm pretty sure my Pawn is registered in the array, and I'm calling DrawActorOverlays regardles of bShowOverlays or other bools that may need to be set. Does anyone know what the problem might be?
    Last edited by Mooser; 04-09-2012 at 10:55 PM.

  7. #7

    Default

    I had a similar problem, I fixed it with the PostRender() function in the HUD class. you could also try add "bShowOverlays = true" to defaultproperties in the HUDclass

  8. #8
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    @paco:
    1. From YourHUD you can remove function DrawHUD because in super HUD this function is exactly the same...
    2. You don't need call MPGameInfo(WorldInfo.Game).mphud.AddPostRenderedAc tor(self); in YourPawn because super UTPawn.PostBeginPlay will do the job (with your call AddPostRenderedActor will be called twice...) - put only bPostRenderOtherTeam=True in default properties if you want to everyone see that post render not only same team.

    @Mooser:
    1. Remove AddPostRenderedActor from PostRender in YourHUD, because it will be called in each tick - instead add this function to YourPawn.PostBeginPlay after calling Super. Look in to UTPawn.PostBeginPlay for example...

  9. #9

    Default

    Quote Originally Posted by VendorX View Post
    @Mooser:
    1. Remove AddPostRenderedActor from PostRender in YourHUD, because it will be called in each tick - instead add this function to YourPawn.PostBeginPlay after calling Super. Look in to UTPawn.PostBeginPlay for example...
    Hi VendorX, thanks for the reply. AddPostRenderedActor seems to already check if the actor exists in the array before adding a duplicate. So I think calling it once is def an optimization. but I don't see how it will fix the problem of PostRenderActors not being called.

  10. #10

    Default

    Quote Originally Posted by Audiolog View Post
    I had a similar problem, I fixed it with the PostRender() function in the HUD class. you could also try add "bShowOverlays = true" to defaultproperties in the HUDclass
    As I understand, DrawActorOverlays is the native function that calls PostRenderActor on registered actors. In HUD.uc, bShowOverlays controls whether DrawActorOverlays is called, which explains why a lot of people have trouble with it. However, the code I'm using bypasses the check entirely and calls DrawActorOverlays no matter the state, so I'm lost on why the callback never fires.

  11. #11

    Default

    I think I figured it out, and it seems like a facepalm in hindsight. PostRenderedFor only gets called on actors that are actually rendered. I've been trying 2 different things, and neither leads to an actual rendering :

    1.) Spawning an actor that isn't rendered, but who's location is on screen and the location is used to print text on-screen ( see here : http://forums.epicgames.com/threads/...in-Borderlands). I'm still working out how to do this (get an actor to be considered rendered, but only use it for canvas text on screen from postrender)

    2.) Registering my own player pawn to PostRenderFor, which wasn't rendered anyway because I'm using a first-person camera

    Happy to finally have this behind me.

  12. #12
    Boomshot
    Join Date
    Aug 2011
    Posts
    2,920

    Default

    Quote Originally Posted by Mooser View Post
    ... neither leads to an actual rendering :

    1.) Spawning an actor that isn't rendered, but who's location is on screen and the location is used to print text on-screen...
    This works fine for me when bPostRenderIfNotVisible is set.

  13. #13

    Default

    Thanks, bPostRenderIfNotVisible did the trick.


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.