Mike Foran
Forum Replies Created
-
I had already discounted this because it felt like to blunt an solution, and it was breaking the other wheel rotation script you wrote in a previous post. But after some finessing this actually worked quite well. Thanks again.
-
Yes, I meant anchors when I said handles, sorry about that.
Still not quite working the way I need. I am attempting to rotate a wheel from it center point anchor on the Z axis, while at the same time orienting it from a second anchor at center bottom. I am trying to be able to roll the wheel, but angle it out when it goes around sharp corners by changing the x orientation. The bottom of the wheel should not slide as it rotates.
I am having a tough time figuring it out. I have built a test comp (which you can see here: https://www.dropbox.com/s/7t4m3zgl63nmfvn/Rolling%203D%20Wheel.2.aep) in which I have my main wheel (blue) which I rotate on the Z axis from the center anchor. I have a controller wheel (red) that shifts it’s anchor point so it can then orient on the x axis.
The problem, as demonstrated here, is that the main wheel, not sharing the same anchor point, looks like it is sliding away when the controller changes orientation. How can I keep the position of the blue wheel the same as the controller while it rotates and orients?
-
Seriously. What kinds of boats do you like Dan? Sailboats? Motorboats? How about a nice big yacht? I’m taking up a collection. That worked perfectly and I’ve been trying to write that for 2 days.
-
So I am trying to modify this script so that, when it reaches a marker on the timeline, it reverses rotation. But since it is calculating rotation based upon total length traveled I am geting errors when I try to set rotation for the opposite direction. I am not sure setting markers is the right way to do it, but I need a way to reverse the rotation. The way I have it now it resets the rotation to 0 when it hits a marker, but I would like it to not change rotation at all until it starts moving again. I would love any suggestions as to the best way to handle this.
Here is a link to the test project: https://www.dropbox.com/s/s5dfegqbvghddbd/Comp%2010.aep
// -------- Experimental Rotation Script --------- //;n = 0;
dist = 0;
w=width;// Determine if there are any markers on the timeline and if so if they are odd or even
if (thisLayer.marker.numKeys > 0){
n = thisLayer.marker.nearestKey(time).index;
if (thisLayer.marker.key(n).time > time){
n--;
}
if (n > 0){
f = timeToFrames(time);
f0 = timeToFrames(thisLayer.marker.key(n).time);
for (i = f; i > f0; i--){
p2 = position.valueAtTime(framesToTime(i));
p1 = position.valueAtTime(framesToTime(i-.5))
p0 = position.valueAtTime(framesToTime(i-1));
dist += length(p0,p1) + length(p1,p2);
}
if (n%2){
// ODD: rotate clockwise
-360*(dist/(Math.PI*w))
}else{
// EVEN: rotate counterclockwise
360*(dist/(Math.PI*w))
}
}else{
// NONE: rotate clockwise
f = timeToFrames(time);
f0 = timeToFrames(inPoint);
for (i = f; i > f0; i--){
p2 = position.valueAtTime(framesToTime(i));
p1 = position.valueAtTime(framesToTime(i-.5))
p0 = position.valueAtTime(framesToTime(i-1));
dist += length(p0,p1) + length(p1,p2);
}
360*(dist/(Math.PI*w))
}}
-
I see. Very informative. Thanks again Dan. What kinds of boats do you like?
-
Yup, that’s it. I knew straight position wouldn’t work in this case so I was trying to figure out out to determine the distance between the previous frame and the current and rotate accordingly, but I couldn’t get the math and context right. It appears that you are determining rotation from the starting point, or are you getting it just from the previous frame?
And just out of curiosity, how would one work out sub-frame sampling?
I really appreciate you taking the time to sort that out. We really ought to take up a collection here and buy you a boat or something.
-
WEll I hope I stimulated everyone’s brain this morning, but I was able to solve the issue with the .valueAtTime() expression. Woot!