Announcement

Collapse
No announcement yet.

Scaleform 4 not acting the same as Scaleform 3. (AS2 project)

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

    Scaleform 4 not acting the same as Scaleform 3. (AS2 project)

    Hi,

    I had a working HUD in scaleform 3 with June 2011's UDK. I've just tried to move it to scaleform 4, leaving it as an actionscript 2 project.

    Has something changed with local2global, or hitTest with regards to the z rotation?

    Don
    have a great day

    #2
    Can you be more specific, as with examples of code and screens or logs showing the issues you are having?

    Comment


      #3
      Sure.

      The code that isn't working is a replacement for the local2Global flash function, that incorporates the scaleform rotation on x- and y-axis.

      The function is as follows:

      function SClocal2global(pt1) {
      this.zz = 0; //hold a z-co-ordinate on the object's plane.

      if(group._xrotation!=0 or group._yrotation!=0) { //(group is this._parent effectively)
      // rotation around x axis (a.k.a. pitch) //http://www.kirupa.com/developer/actionscript/trig_multiple_axis.htm
      ty = pt1.y;
      tz = this.zz;
      pt1.y = Math.cos(group._xrotation*Math.PI/180)*ty - Math.sin(group._xrotation*Math.PI/180)*tz;
      this.zz = Math.sin(group._xrotation*Math.PI/180)*ty + Math.cos(group._xrotation*Math.PI/180)*tz;

      // rotation around y axis (a.k.a. yaw)
      tz = this.zz;
      tx = pt1.x;
      this.zz = Math.cos(group._yrotation*Math.PI/180)*tz - Math.sin(group._yrotation*Math.PI/180)*tx;
      pt1.x = Math.sin(group._yrotation*Math.PI/180)*tz + Math.cos(group._yrotation*Math.PI/180)*tx;

      // rotation around z axis (a.k.a. roll)
      // tx = pt1.x;
      // ty = pt1.y;
      // pt1.x = Math.cos(_parent._rotation)*tx - Math.sin(_parent._rotation)*ty;
      // pt1.y = Math.sin(_parent._rotation)*tx + Math.cos(_parent._rotation)*ty;
      }

      //adjust for screen mid-point:
      pt1.x -= Stage["visibleRect"].width/2 - group._x;
      pt1.y -= Stage["visibleRect"].height/2 - group._y;

      //scale for perspective: aka cameraPlane.z / (zz + cameraPlane.z)
      pt1.x *= _root.nearZ / (_root.nearZ + this.zz); //_root.nearZ = Stage["visibleRect"].width/2 / Math.tan(55/2/180*Math.PI); (defined outside this function)
      pt1.y *= _root.nearZ / (_root.nearZ + this.zz);

      //re-adjust to screen mid:
      pt1.x += Stage["visibleRect"].width/2 - group._x;
      pt1.y += Stage["visibleRect"].height/2 - group._y;

      //scale for group scale:
      pt1.x /= this._xscale/100;
      pt1.y/= this._yscale/100;

      this.localToGlobal(pt1);
      return(pt1);
      }
      It worked in as2/scaleform3, but now returns a increasing then decreasing value, rather than constantly increasing as expected. It throws out my stored screen-coordinates on small grid movieclips, that exist on multiple planes rotated on x- and y- axis.

      If you can point me at what would have changed, I'd much appreciate it.

      Don
      have a great day

      Comment


        #4
        I have confirmed its the local2global function that isn't working the same way. Unfortunately, it isn't returning the same result as my code which was supposed to make up for l2g not taking scaleform transform into account. If it is possible, can a scaleform expert please advise what changed in local2global?

        Don
        have a great day

        Comment


          #5
          I will be spending my time on IRC today, why dont you join me and we can work this through quicker than on the forums.

          #unrealscript on irc.enterthegame.com
          #udkc on irc.gamesurge.net

          Comment


            #6
            Cheers Bob,

            Sorry but I think I've missed you on IRC given my timezone difference (Australia).

            I'll be on those irc for the next hour if you catch me, otherwise I'll try to catch you after New Years.

            -edit: caught you - thanks for taking the time to have a look.

            I solved my issue by doing a manual calculation instead of localToGlobal, but I'm still not sure why its returning differences. My feeling now is that the different versions are applying different context to this.localToGlobal(pt), so the "this" is different.

            Don
            have a great day

            Comment

            Working...
            X