Notifications
Clear all
[Closed] Convert rotation to offset
Nov 21, 2016 6:20 am
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
Nov 21, 2016 6:20 am
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
Nov 21, 2016 6:20 am
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
Nov 21, 2016 6:20 am
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.