Notifications
Clear all

[Closed] Convert rotation to offset

i have to boxes…
i connect them wire parameters: box01 z.rotation to box02.texture.coords.V_Offset
I need to convert the z.rotation of the box to box02 texture V_Offset value 0.0-1.0
help plz!

6 Replies

fn clampAngleTo360 theta =
(
theta = mod theta 360 
return (if theta < 0.0 then (theta + 360) else theta)
)

offset = clampAngleTo360($box01.z.rotation) / 360
offset -- if it is for controller

EDIT: just revised the code

Can you explane…where and how i use it?

so i add

(Z_Rotation)/6.283

to the right side and it`s working…
i dont know why 6.283…but i saw this number in the v_offset value
when i rotate the box 360…

1 Reply
(@aaandres)
Joined: 11 months ago

Posts: 0

6,283 = 2*pi = 6,2831853… == 360º in rad

it’s a radian value for 360

anyway just
paste this on the right side and connect it…


theta =  Z_Rotation
if (mod theta 360) < 0.0 then (theta  + 360) else theta 
radToDeg(theta) / 360

EDIT: I should note you that if you keep rotating it may pass 360 degree causing the UV value to get higher than 1.0. Unless you don’t care about it. then you already solved the problem.

thank