• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Using Vexorian's model to change pitch

Status
Not open for further replies.
Level 14
Joined
Aug 30, 2004
Messages
909
I want to be able to move special effects and change their pitch. As I understand it, Vexorian made a dummy model (which I downloaded) that has many animations. I looked at the animations and they are in the form of "a" "b" "c" and so on. I need to know how to translate those into angles so that I can make the dummy unit, say face straight up (90-degrees) or straight down (270 degrees, or -90 degrees).

Is there a translation of his animations into degrees?

EDIT:

I should point out that I use GUI and do not know JASS.
 
Last edited:
Level 24
Joined
Aug 1, 2013
Messages
4,657
You should have taken a look inside the XE map of Vexorian which is the only official way to download the dummy... I just realized that that DUMMY.mdx that I gave you was also from Vexorian :D

Anyway, Vexorian did not implement full pitch rotation.
Because he made if for a missile system.
(However I can see that a missile could be moving backwards.)

Anyway this is how Vexorian made it:
JASS:
method operator zangle= takes real value returns nothing
    local integer i=R2I(value*bj_RADTODEG+90.5)
    set this.zang=value
    if(i>=180) then
        set i=179
    elseif(i<0) then
        set i=0
    endif
    
    call SetUnitAnimationByIndex(this.dummy, i  )
endmethod
Translated into a simple function it would be this:
JASS:
function SetUnitZAngle takes unit whichUnit, real angle returns nothing
    local integer i=R2I(value*bj_RADTODEG + 90.5)
    
    if i >= 180 then
        set i = 179
    elseif i < 0 then
        set i = 0
    endif
    
    call SetUnitAnimationByIndex(whichUnit, i)
endfunction

But as you could notice, if you set the angle to a point where the model would face backwards, this would not work.
That is why you can use this one instead to enable that.
JASS:
function SetUnitZAngle takes unit whichUnit, real angle returns nothing
    local integer i=R2I(value*bj_RADTODEG + 90.5)
    
    loop
        if i >= 180 then
            set i = 180 - (i-180)
            call SetUnitFacing(whichnit, 180 + GetUnitFacing(whichUnit))
        elseif i < 0 then
            set i = -i
            call SetUnitFacing(whichnit, 180 + GetUnitFacing(whichUnit))
        else
            exitwhen true
        endif
    endloop
    
    call SetUnitAnimationByIndex(whichUnit, i)
endfunction
 
Level 14
Joined
Aug 30, 2004
Messages
909
I hate to do this to you since you've been so helpful, but could you put some of that into GUI, or even spell out the logic and I can put it into code.

For example, what is: integer i=R2I(value*bj_RADTODEG + 90.5)

It looks like I convert the angle from degrees to radians, which I can do...but then what?
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
That is actually the exact opposite way.
That makes a rounded integer of the arc...

That code sets the animation to a certain index. The animations are ordered so the first(0) will be 0 degrees and the 179th will be 179 degrees.
So you have very precise turn rate.

To call this you need a "Custom script: call SetUnitZAngle(udg_TempUnit, udg_TempReal)"
In this case it will set TempUnit's Z-facing to TempReal degrees.

I am not quite sure but I think you have to remove the (*bj_RADTODEG) part.
 
Status
Not open for further replies.
Top