Announcement

Collapse
No announcement yet.

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

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [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!

    #2
    look at this

    http://www.youtube.com/watch?v=J21zw...layer_embedded

    and this:

    http://www.moug-portfolio.info/index...-basics-canvas

    Does that help you?

    Comment


      #3
      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);
      }

      Comment


        #4
        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.

        Comment


          #5
          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!

          Comment


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

            Comment


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

              Comment


                #8
                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?

                Comment

                Working...
                X