• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • ✅ Time to vote for the top 3 models! The POLL for Hive's 6th HD Modeling Contest: Mechanical is now open! 📅 Poll close on July 16, 2024! 🔗 Cast your vote now!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

Special effect orientation with offset

Status
Not open for further replies.
Level 12
Joined
Mar 29, 2012
Messages
530
How to make an effect face an angle with offset to its roll and pitch?

For example, an effect's 3D orientation is facing a unit's head, but I want to make it face a little up and a little left of it's current orientation (pitch and roll).

And what is the formula to set an effect facing (the pitch is straight) angle towards a unit? I know I can use roll angle only, but I think I can't make offset facing later.

facing.png


pitch.png
 
Last edited:
Jesus, this is complicated. These Yaw, Pitch, Roll angles are defined so awkwardly and have nothing to do with how they're normally defined.

I made a test here and tried to align this Starfall effect to the unit in the way you described. Hope I interpreted it correctly.

It doesn't work 100% yet. The prefactors "Cos(Phi)" and "Sin(Phi)" in the Set Yaw/Pitch functions are wrong. They were just guesses. I'd have to look into the trigonometry formulas for that situation to get the correct ones. I tried rotating the effect to horizontal orientation, then rotating it around the Z-axis so it faces the Paladin + offset, then rotating it back towards the Z-axis to account for the vertical offset, but that didn't work.

Maybe this is still a good starting point or maybe someone smarter can pick it up from here. Also, maybe there is a function someone wrote that converts to these yaw, pitch, roll angles from something more intuitive.
 

Attachments

  • SpecialEffectYawPitchTest.w3m
    17.6 KB · Views: 49
Last edited:
Level 12
Joined
Mar 29, 2012
Messages
530
Sorry I might not being too straightforward.
I used this to find the pitch angle of an effect towards a target unit:
JASS:
function GetDistance2D takes real x, real y returns real
    return SquareRoot(x * x + y * y)
endfunction

function AnglePointsZ takes real distance2D, real z returns real
    return Atan2(z, distance2D)
endfunction

// find pitch angle towards target.
// [posX, posY, posZ] is the effect's position.
// [targetX, targetY, targetZ] is the target unit's position.
set anglePointsZ = AnglePointsZ(GetDistance2D(.targetX - .posX, .targetY - .posY), .targetZ - .posZ)
Then I use a unit (caster)'s facing angle to be used as the facing angle of the effect (because the caster should always be facing the target unit):
set cFacing = GetUnitFacing(.node.caster) * bj_DEGTORAD

At this point, I'm not sure if this is the right way to make the effect face the direction I mentioned above (still the same concept).
JASS:
set .pitch = GetRandomReal(anglePointsZ + rPitchLimit[2], anglePointsZ + rPitchLimit[1])
set .roll = GetRandomReal(cFacing - rFacingWidth, cFacing + rFacingWidth)
call BlzSetSpecialEffectOrientation(.rocket, 0, .pitch, .roll)
// I don't use the 'yaw' (0), cuz I don't fully understand how these 3 values work.

// these variables below are initialized earlier.
set rFacingWidth = ROCKETS_FACING_WIDTH / 2. * bj_DEGTORAD
set rPitchLimit[1] = ROCKETS_PITCH_LIMIT_UP * bj_DEGTORAD
set rPitchLimit[2] = ROCKETS_PITCH_LIMIT_DOWN * bj_DEGTORAD
 
Last edited:
Level 12
Joined
Mar 29, 2012
Messages
530
Blizz messes yaw and pitch afair.
Yup, this math stuff is blowing my mind.
You've done a lot of work on this already. Might have been good to include that in the OP :(.
Basically, I only try to understand what some of those lines of formula does from various resources. Then I try to solve them to be the formula I wanted. I never fully understand those trigonometry functions. :)

What's OP?
 
Status
Not open for further replies.
Top