Closed Hypersomniac closed 10 years ago
Well after some testing it appears that UDK is using rounded UP integers for positives angles but rounded Down integer for negatives ones.
90° <=> 16384 Unreal Angle Unit <=> 65535 * 0.25 = 16383,75 rounded UP -90° <=> -16384 Unreal Angle Unit <=> 65535 * -0.25 = 16383,75 rounded DOWN 270° <=> 49152 Unreal Angle Unit <=> 65535 * 0.75 = 49151,25 rounded UP
so the script line become : TDSTRING+="\t\tRotation=(Roll="+str(int(math.ceil(65535((ob.rotation_euler.x%(2_math.pi))/(math.pi_2)))))+",Pitch="+str(-1int(math.ceil(65535((ob.rotation_euler.y%(2_math.pi))/(math.pi_2)))))+",Yaw="+str(-1int(math.ceil(65535(ob.rotation_euler.z%(2_math.pi)/(math.pi*2)))))+")\n"
I'm using the modulo operator to only ceil positives number and then applying the correct axis inversion (-y & -z).
Older method on the bottom, newer on the top
pushed to master, thanks for the input!
Angle conversion should use the round function before converting to int. If not the instances in Unreal may have a small offset like 90 degrees becoming 89.9.
The line should be:
TDSTRING+="\t\tRotation=(Roll="+str(int(round(65535(ob.rotation_euler.x/(math.pi2)))))+",Pitch="+str(int(round(65535(-1_ob.rotation_euler.y/(math.pi2)))))+",Yaw="+str(int(round(65535(-1_ob.rotation_euler.z/(math.pi_2)))))+")\n"
A little lazy to make a commit and a pull request for that.