• 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.

Working with Pitch and Roll Facings

Status
Not open for further replies.
Level 11
Joined
May 26, 2005
Messages
194
Is there a way to set a units pitch or roll facing?

The only way i can think of is the following:
A dummy model is used to do the roll facing, with lots of animations which each represents a specific facing.
This rolling is applied to the head-bone, then SetUnitLookAt is used on the head-bone doing pitch and normal facing.

However, as SetUnitLookAt resets the facing before it applies the new one, i cannot call this function every 0.03 seconds, that would look ugly, so:
each model to turn would need 2 units, which will be replaced again and again, everytime SetUnitLookAt is used, the old model is placed where the user sees it, the new one gets the new facing, in the next loop the correctly faced unit will replace the currently visible one, and the visible one will be updated and hidden somewhere.... all that, again and again

that solution is quite ugly, and makes ribbon emitters impossible, however, if it works, it would open incredible new possibilities regarding a flight simulator... and ribbons could still be replaced by fast particle emitters


so, all of you, what do you think, is it possible?

any other ideas would be great, too.
 
Level 11
Joined
May 26, 2005
Messages
194
oh my god! ^^

it seems like SetUnitLookAt works instantly when you use SetUnitPosition(U,x,y) instantly after it!

SetUnitPosition is quite slow, however, in thise case i dont think it can stop me from using it in the way i found out now...

this function works, together with a model with 252 animations for rolling
it first applies the face angle, from this angle then pitch, and rolls around the resulting vector, great! ^^
JASS:
function SetUnitFacing3D takes unit U, real Pitch, real Roll, real Face returns nothing
    local real CosPitch = Cos(Pitch)
    local real offX
    local real offY
    local real offZ
    local integer i
    if CosPitch<0 then
        set Roll = Roll + bj_PI
    endif
    set offX = Cos(Face)*CosPitch*100.
    set offY = Sin(Face)*CosPitch*100.
    set offZ = Sin(Pitch)*100.
    set i = ModuloInteger(R2I(Roll*bj_RADTODEG*0.7+0.5),252)
    call SetUnitAnimationByIndex(U, i)
    call SetUnitLookAt(U,"bone_Head",U,offX,offY,offZ)
endfunction

    call SetUnitAnimation(U,"stand")
    call SetUnitPathing(U,false)
    call SetUnitTimeScale(U,1000.)
    call SetUnitFacing3D(U,pitch,roll,face)
    call SetUnitPosition(U,x,y)

wait some time and you will probably see a flightsimulator uploaded here xD not sure, but maybe^^
 
Level 11
Joined
May 26, 2005
Messages
194
sorry for triple-posting, but in case someone else is interested in this:

it seems like SetUnitLookAt only works instantly when used on a unit near the map center... probably i will just scale everything very low and make the map veeeery small... but dont know how to expand that area

and with very small scales, the wc3 cam has a min-distance to the camera, everything else isnt rendered... so scaling it down very much doesnt work either, damn...
 
Level 8
Joined
Aug 6, 2008
Messages
451
Is the size of that area constant or does it depend on whole maps size?


Also, that Combat Zones flight simulation was pretty awesome. I hope you can get this working.
 
Level 11
Joined
May 26, 2005
Messages
194
The size is constant

im currently trying to move the object to the center of the map, then update the animation there, and then move it to its correct position, without affecting the animation, but i did not find something yet

EDIT: yeah, have a guess who fixed the problem! ^^

i just had to edit the model a bit, the bounds radius has to include the maps origin for SetUnitLookAt to work (thats my theory), now i set the bounds radius very high and it works! ^^
 
Status
Not open for further replies.
Top