Results 1 to 8 of 8
  1. #1

    Default [Solved] Scaleform version of Canvas.Project()?

    Hi all,

    Attempting to draw combat damage numbers over an enemy as the player damages them. However the only problem i am running into is changing 3d coordinates to 2d screen coordinates. Is there any easy way to do this with scaleform? I know with Canvas you can use Project, so i am looking for an equivalent, or some way to use Canvas's project function with scaleform.

    Any help or comments will be appreciated!
    Last edited by Dozer1170; 09-08-2011 at 05:17 PM.

  2. #2

  3. #3

    Default

    I don't have the exact answer for you, but this code was used to create something similar....

    This code sets the position of a Scaleform movie attached to an object in the world in the correct location on the screen using Canvas.Project.

    Code:
    event PostRender()
    {	
        local SomeObjectClass myObject;
    
        foreach WorldInfo.AllActors(class'SomeObjectClass',myObject)
        {	
            if (myObject.myObjectMovie != none)
            {
                myObject.myObjectMovie.UpdatePosition(myObject,Canvas.Project(myObject.Location));
            }
        }
    }
    The object (SomeObjectClass) class creates a Scaleform movie:

    Code:
    var MyMovieClass 		myObjectMovie;
    
    function CreateMovie()
    {
        myObjectMovie = new class'MyMovieClass';
        myObjectMovie.MovieInfo = SwfMovie'packagename.moviename';
    	
        myObjectMovie.SetTimingMode(TM_Real); 
        myObjectMovie.Start();
    }
    And in the Scaleform movie class (MyMovieClass) that extends GFxMoviePlayer:

    Code:
    var int Width, Height;
    
    function bool Start(optional bool StartPaused = false)
    {	
        local float x0, y0, x1, y1;
    
        super.Start();
        Advance(0);
    
        // Get width & height of Movie
        GetVisibleFrameRect(x0, y0, x1, y1);
        Width = x1-x0;
        Height = y1-y0;
    	
        return true;	
    }
    
    function UpdatePosition(SomeObjectClass o, Vector ScreenPos)
    {
        self.SetViewPort(ScreenPos.X,ScreenPos.Y,Width,Height);
    }
    Last edited by Matt Doyle; 09-07-2011 at 03:25 PM.

  4. #4

    Default

    Thanks for the help guys, figured out a way to get it done.

    I will post my code here after I get out of class.

  5. #5

    Default

    I pretty much keep a vector in my GFxMoviePlayer class for the location of the player's target.

    And update that location everytime PostRender is called in the wrapper class.

    I pretty much copied the logging assets from the UThud flash file and modified them to work how i wanted them.

    Only pasted relevant code to this issue.

    YourHUD.uc which extends GFxMoviePlayer:
    Code:
    var Vector TargetScreenLoc;
    
    function AddMessage(string type, string msg, Pawn target)
    {
    	local MessageRow mrow;
    	local GFxObject.ASDisplayInfo DI;
    
    	if (Len(msg) == 0)
    		return;
    
    	if (FreeMessages.Length > 0)
    	{
    		mrow = FreeMessages[FreeMessages.Length-1];
    		FreeMessages.Remove(FreeMessages.Length-1,1);
    	}
    	else
    	{
    		mrow = Messages[Messages.Length-1];
    		Messages.Remove(Messages.Length-1,1);
    	}
    	if(target != None)
    	{
    		`log("X: " $TargetScreenLoc.X $" Y: " $TargetScreenLoc.Y);
    		DI.hasX = true;
    		DI.hasY = true;
    		DI.X = TargetScreenLoc.X;
    		DI.Y = TargetScreenLoc.Y;
    		mrow.MC.SetDisplayInfo(DI);
    	}
    	mrow.TF.SetString(type, msg);
    	mrow.MC.GotoAndPlay("show");
    	Messages.InsertItem(0,mrow);
    }
    
    function SetTargetLoc(vector loc)
    {
    	TargetScreenLoc = loc;
    }
    Customize your controller and its target how you want. The target is just pawn for me and is changed if the player looks at another pawn or hits another pawn.

    Wrapper class that extends UTHudBase:
    Code:
    event PostRender()
    {
    	if(FantasyPlayerController(PlayerOwner).LookAtTarget != None)
    		HudMovie.SetTargetLoc(Canvas.Project(FantasyPlayerController(PlayerOwner).LookAtTarget.Location));
    	HudMovie.TickHud();
    };
    Hopefully this helps others with the same problem!
    Last edited by Dozer1170; 09-08-2011 at 03:37 PM.

  6. #6

    Default

    Looks good. Can you please include the SetTargetLoc() function as well?

  7. #7

    Default

    Added, forgot about that one. Just a simple setter.

  8. #8
    MSgt. Shooter Person
    Join Date
    Nov 2011
    Posts
    122

    Default

    Quote Originally Posted by Matt Doyle View Post
    I don't have the exact answer for you, but this code was used to create something similar....

    This code sets the position of a Scaleform movie attached to an object in the world in the correct location on the screen using Canvas.Project.

    Code:
    event PostRender()
    {	
        local SomeObjectClass myObject;
    
        foreach WorldInfo.AllActors(class'SomeObjectClass',myObject)
        {	
            if (myObject.myObjectMovie != none)
            {
                myObject.myObjectMovie.UpdatePosition(myObject,Canvas.Project(myObject.Location));
            }
        }
    }
    The object (SomeObjectClass) class creates a Scaleform movie:

    Code:
    var MyMovieClass 		myObjectMovie;
    
    function CreateMovie()
    {
        myObjectMovie = new class'MyMovieClass';
        myObjectMovie.MovieInfo = SwfMovie'packagename.moviename';
    	
        myObjectMovie.SetTimingMode(TM_Real); 
        myObjectMovie.Start();
    }
    And in the Scaleform movie class (MyMovieClass) that extends GFxMoviePlayer:

    Code:
    var int Width, Height;
    
    function bool Start(optional bool StartPaused = false)
    {	
        local float x0, y0, x1, y1;
    
        super.Start();
        Advance(0);
    
        // Get width & height of Movie
        GetVisibleFrameRect(x0, y0, x1, y1);
        Width = x1-x0;
        Height = y1-y0;
    	
        return true;	
    }
    
    function UpdatePosition(SomeObjectClass o, Vector ScreenPos)
    {
        self.SetViewPort(ScreenPos.X,ScreenPos.Y,Width,Height);
    }
    Hi Math.

    I am trying this code and It is not working right. The movie is occuping the entire screen. And it is centered.
    Is that code still right?


 

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.