Notifications
Clear all

[Closed] expose transform rotation conversion

So I’m having trouble finding the answer to this, which seems like it should be fairly simple, but so far nothing I’ve tried is working–
I’m rigging some gears up, and using expose transform as parents, wiring rotations of child gears to those parents. Problem is, because the rotation of the expose transform helper is from 180 to -180, I get a jump in rotation between gears that aren’t a 1 to 1 ratio when the it crosses from negative to positive values.
How to convert from the rotation value that is exposed by the expose transform helper to a 0 to 360 value?

Thanks for any input.

10 Replies
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

i would not use a expose transform helper at all in this rig. the easier way is to setup Wire Controller or Script (Expression) Controller. It will help you to set any animation delay (offset).

Correct me if I’m wrong, but I think you will always have a jump in your rotations using an expose transform helper for the exact reason you just mentioned.
If it is possible to convert theses values to prevent this flip, I don’t know the method but… personally I would go with wire parameters or script expression to do that sort of thing.
Hope it can help you.

The down side to easily readable Euler controllers. You will need to edit the Euler Order to get the values you expect. From the help:

Euler Order These three settings determine the order in which the Expose Transform helper will look for an Euler rotation.

                         This  parameter corrects for anomalies that can be introduced when a local  rotation value is generated in relation to other                               rotation values. For example, when Z Order  is set to XYZ, the Z value is generated in reference to X and then Y.  Or when X                               Order is set to ZXY, the Z value is  generated directly in reference to the parent, regardless of X and Y  rotations.

-Eric

Thanks for the replies.
I’ve tried changing the rotation order with no change in values.
The issue is this:
The master parent gear in this chain has a link constraint that starts at some point after frame 0. (not spinning at first, then linked to a constant spinning gear at frame 180).
So, if I wire the children in this chain to this master, they don’t spin since the master is only reading its rotation from the passed link. Which is why I decided to try a expose transform.
I need an expose transform on each gear in the chain so I can calculate the gear ratio of each down the line. However, this is proving to be a flawed approach, I think, due to the difference in the way the rotation values are output from the expose transform.
Am I missing something? I feel like this should really not be this hard.

So a workaround for now is to just replace all of the standard helper parents with expose transform helpers so their rotation is consistent. I don’t know why I didn’t think of this until now.

EDIT: This actually did not solve the problem. Gears are still jumping.

Ok, here’s another thought–since the gear ratio of the gears in question is 63/68, every time the parent gear makes a full revolution, the child gear spins a bit more slowly, as it should since it is larger, but as the parent gear starts a new rotation (rotation value goes back to 0), the child gear is reset and jumps to 0 as well.
How can I account for this in wiring or a script controller? I want to compound the rotations instead of cycling through one 360 degree rotation.

Have you seen this video from Paul Neale on doing a gear setup? May help provide an alternative setup that may give you a way to handle your issue(s).

-Eric

Thank you PiXeL_MoNKeY for the link. I somehow missed that one even though I’ve been through most of his site. Some great nuggets of info in there, though I still am having problems.
I’ve scrapped trying to use the expose transform so now my problem is: how can I get a gear to start moving at a certain keyframe (that is greater than 0)?
Previously, I was using a link constraint but that caused the child gear of that link constraint to read a 0 rotation value which made wiring anything else to it not work (which is why I was trying to use the expose transform helper in the first place). I need the first set of gears to start at frame 0, then a second set of gears to start later in the animation, and everything else needs to be wired to that second set, but based on the rotation of the first set.
It seems I could perhaps write an expression that wires to another object after a certain frame, but I’ve had no luck figuring out how to do that. My scripting skills are quite undeveloped.
Anyone have any ideas here?

Thanks again for all the replies.

actually your gear rig is not trivial and i see it as very interesting challenge for every rigger. most complicated part is to provide an enable/disable spin ability. i see at list 5 ways to do it. but only one i like most of all.
does anyone else want to show his solution?

here is a little tool that makes three gears constraint with simple Wire Connection. you can play with radius values and see that everything works correct. But the challenge is – change the rig to give a functionality of enabling and disabling driven gears spin at any time…


try(destroydialog TwoGearsConstraint) catch()
rollout TwoGearsConstraint "Two Gears Constraint" width:200
(
	group "Driving: "
	(
		spinner radius0_sp "Gear Radius: " type:#float range:[0,1e9,10] fieldwidth:56 align:#right offset:[4,-5] 
	)
	group "Driven: "
	(
		spinner radius1_sp "Gear 1 Radius: " type:#float range:[0,1e9,5] fieldwidth:56 align:#right offset:[4,-5] 
		spinner radius2_sp "Gear 2 Radius: " type:#float range:[0,1e9,20] fieldwidth:56 align:#right offset:[4,-2] 
	)
	group "Setup: "
	(
		button create_bt "Create Gears" width:182 align:#right offset:[4,0] 
	)
	fn makeGearConstraint driving driven = 
	(
		ratio = driving.radius/driven.radius
		
		paramwire.connect driving.rotation.controller[3] driven.rotation.controller[3] ("-Z_Rotation*" + ratio as string)
		
		ok
	)
	fn createGears = 
	(
		delete objects
		
		r0 = radius0_sp.value
		r1 = radius1_sp.value
		r2 = radius2_sp.value

		b0 = cylinder name:"driving" radius:r0 sides:32 height:3 slice:on sliceFrom:-3 sliceTo:3 pos:[0,0,0] wirecolor:(random white black)
		b1 = cylinder name:"driven1" radius:r1 sides:32 height:3 slice:on sliceFrom:-3 sliceTo:3 pos:[r0+r1,0,0] wirecolor:(b0.wirecolor*0.5)
		b2 = cylinder name:"driven2" radius:r2 sides:32 height:3 slice:on sliceFrom:-3 sliceTo:3 pos:[r0+r1+r1+r2,0,0] wirecolor:(b0.wirecolor*0.3)

		makeGearConstraint b0 b1
		makeGearConstraint b1 b2

		animate on 
		(
			at time 100 b0.rotation.controller[3].value = -720
		)
	)
	on create_bt pressed do undo "Create Gears" on animate off createGears()
)
createdialog TwoGearsConstraint pos:[800,200]