RH2 / TD_B3D-UDK

Batch export & send instances. An attempt to Streamline the Process. Works with Unity and UDK. Unreal2.5 branch is now stable!
4 stars 2 forks source link

Angle conversion #2

Closed Hypersomniac closed 10 years ago

Hypersomniac commented 10 years ago

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.

Hypersomniac commented 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).

RH2 commented 10 years ago

rotationtest Older method on the bottom, newer on the top

pushed to master, thanks for the input!