• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Having troubles with BlzSetSpecialEffectOrientation

Status
Not open for further replies.
Level 3
Joined
Nov 21, 2016
Messages
18
Hello everyone! I'm writing a projectile system for my map using new effect natives. And I was testing this BlzSetSpecialEffectOrientation function as well as the others (BlzSetSpecialEffectYaw, etc). And here's the issue: I cannot get the orientation i need. In other projectile systems there were dummy units with facing set by SetUnitFacing and angle of attack set by animations of dummy model. But this effect natives behave weird. Most of the time I need the effect to face a point, or set it orientation using 2 angles: facing (like unit facing) and angle of attack. So I'd like to have a function that takes this values and converts them into corresponding "yaw", "pitch" and "roll". I tried to do it myself for a while but still have not figured out how do i get this conversion. Here is the test map.
 

Attachments

  • effect rotation test.w3x
    20.6 KB · Views: 46

AGD

AGD

Level 16
Joined
Mar 29, 2016
Messages
688
Are you aware that yaw, pitch, and roll are rotations about the global axes (x, y, z) and not 'local axes' (which is also dependent on the current orientation) of the unit?
EDIT: Yaw is rotation about the effect's facing axis, Pitch is rotation about the transverse axis, and Roll is the rotation about the effect's local z-axis.
 
Last edited:
Level 3
Joined
Nov 21, 2016
Messages
18
Are you aware that yaw, pitch, and roll are rotations about the global axes (x, y, z) and not 'local axes' (which is also dependent on the current orientation) of the unit?
If so, the angles I need are found by formula:
JASS:
set yaw = angleOfAttack * Sin(facing)
set pitch = angleOfAttack * Cos(facing)
set roll = facing
But it gives wrong values.


Updated:
So, with this in mind, the real question would be: how do I convert global angles to local ones?
 
Last edited:

AGD

AGD

Level 16
Joined
Mar 29, 2016
Messages
688
According to @Wareditor, it uses global axes. That's what I initially thought too according to my tests last night, but after further testing it seems more likely to be using local axes, because some results don't coincide with the expected results if it were using the global axes (and it coincides with the expected results if local axes are used instead). Btw, here are all the things I found out while fiddling with the effect orientation natives last night:
  • Yaw, pitch, and roll values are only updated once per thread execution and the values that are used are the values used in the latest call to the BlzSetSpecialEffect(Yaw/Pitch/Roll/Orientation) functions
  • BlzSetSpecialEffectRoll() rotates the effect about its local z-axis
  • BlzSetSpecialEffectYaw() rotates the effect about its longitudinal axis
  • BlzSetSpecialEffectPitch() rotates the effect about its transverse axis
  • The orientations are updated only after the current thread execution in the following order: yaw -> pitch -> roll
Ofcourse I could be mistaken, so further test results are welcome.
 
Level 3
Joined
Nov 21, 2016
Messages
18
This not giving me same effect for all possible facings, It only works right on some (like -180 and 0 degrees). Here is example. When facing is -135 degrees, an unwanted roll effect appears. In this test I use GetCameraEyePosition. I think this happen because of order of Euler angles that SetEffectOrientation uses. It's XYZ, but all we want is a proper euler angles which is ZYZ (Most common is ZXZ but in Warcraft it would be ZYZ).
Euler2a.gif

With this Euler angles sequence the needed rotation require simple and intuitive angles, Z represents facing, Y' - angle of attack and Z'' is roll which most of the time will be equal to 0 (unless you want to flip your effect upside down or whatever).
 

Attachments

  • 03.jpg
    03.jpg
    349.9 KB · Views: 117
  • 04.jpg
    04.jpg
    364 KB · Views: 101
Level 14
Joined
Jan 16, 2009
Messages
716
It's working perfectly fine for (though I removed the negation part that @IcemanBo added - it was causing issues). Your problem must be that the camera position coordinates are not what you think they are.
Here is a map with a sphere made out of peasants.
 

Attachments

  • test effect orientation.w3x
    17.9 KB · Views: 130
Level 3
Joined
Nov 21, 2016
Messages
18
It's working perfectly fine for (though I removed the negation part that @IcemanBo added - it was causing issues). Your problem must be that the camera position coordinates are not what you think they are.
Here is a map with a sphere made out of peasants.
Yes! The camera position was the issue. Thank you.
 
@Wareditor
But a same facing can have different axis rotations. Maybe an extra param can be used, not sure. Have a look, at demo, one could expect the pig to turn around differenly (without the visual cut)
The facing is correct, but yaw/pitch appear not same when dx in this example is smaller or bigger 0. So only with faxing xyz some information of the extra pitch or yaw is missing (?).

edit: moment

edit: attached

btw, a check for 0 divide can be here:

JASS:
set py = (1-(ix/(ix+iy)))

set px = (1-(iy/(ix+iy)))
 

Attachments

  • Orbit demo.w3x
    44.5 KB · Views: 42
Level 3
Joined
Nov 21, 2016
Messages
18
@Wareditor
But a same facing can have different axis rotations. Maybe an extra param can be used, not sure. Have a look, at demo, one could expect the pig to turn around differenly (without the visual cut)
The facing is correct, but yaw/pitch appear not same when dx in this example is smaller or bigger 0. So only with faxing xyz some information of the extra pitch or yaw is missing (?).

edit: moment
If you want to set direct angles I wrote this function. What it does is converts ZYX angles to rotation matrix and then back to XYZ. Z is facing and Y is angle of attack, and an extra param "rotation" is X.

edit: test map added, type angles in degrees to change facing

JASS:
    function SetEffectOrientation takes effect e, real z, real y, real x returns nothing
  
        local real c1 = Cos(x)
        local real s1 = Sin(x)
      
        local real c2 = Cos(-y)
        local real s2 = Sin(-y)
      
        local real c3 = Cos(z)
        local real s3 = Sin(z)
              
        local real sy = SquareRoot(Pow(c2*c3, 2.) + Pow(c1*s3 + c3*s1*s2, 2.))
    
        if not (sy == 0) then // do not change this to !=
      
            set x = Atan2(c3*s1 + c1*s2*s3 , c1*c2)
            set y = Atan2(-s1*s3 + c1*c3*s2, sy)
            set z = Atan2(c1*s3 + c3*s1*s2, c2*c3)
      
        else
      
            set x = Atan2(c2*s1, c1*c3 - s1*s2*s3)
            set y = Atan2(-s1*s3 + c1*c3*s2, sy)
            set z = 0
          
        endif
      
        call BlzSetSpecialEffectOrientation(e, -x, y, z)
              
    endfunction
 

Attachments

  • effect rotation test.w3x
    22.1 KB · Views: 75
Last edited:
I'm not at home next days, but I surely will look at your map at some time, thanks.

When you say Y is angleOfAttack, you mean the function takes its yaw, so rotation around its local x-axis, and x is its pitch, so rotation around local y-axis?

May I ask what does Wareditor's function give you, if you could calculate the respective axis rotations in before?

I would still be confused I guess how to determine the correct x param, as.. in 2 quandrants 1PI would need to added to make the roll not reset (?), but in which?

Maybe I'm just also not too much into it, and it should be anyways defined then by user what kind of facing is needed.
 
Level 3
Joined
Nov 21, 2016
Messages
18
This is Euler angles so the "z" argument is rotation around global Z axis, then "y" argument is rotation around local Y' axis which is formed after the first rotation (Z axis) and therefore affected by it, and finally x is rotation around local X'' axis which affected both by "z" and "y" rotations. Like I said before usually you want the last "x" parameter to be zero unless you want something special, for example passing 90 degrees to this paramereter will turn effect sideways and 180 will flip it upside down.
I think Wareditor's function is good for facing 3d point for example make projectile face target. You also can do this with function I posted, but you need calculate the angles between effect and facing target. And therefore It will be slower. (I think when you call this kind of function thousands time per seconds speed actually matters)
 
Last edited:
Status
Not open for further replies.
Top