PDA

View Full Version : help with piston expression



meshpig
11-08-2007, 02:20 PM
Hello...

Help! I'm a little lost in expression builder. I have a piston set up with IK;

http://www.newtek.com/forums/showthread.php?t=75928

but see now it's not so accurate.

- So, I want to write an expression. The crank in IK has a null at both ends and pivoted at "0".

Can anyone get me started?

Thanks!

M

stevecullum
11-08-2007, 05:45 PM
-asin(crankradius x sin (crankrotation)/rodlength)

Try that. I can't fully explain the trigonometry here, as I only know the basics, but I have used this expression on several occasions for piston actions. Hope it helps!

Edit: you apply this to the rotation channel of the piston rod object.

meshpig
11-08-2007, 07:48 PM
-asin(crankradius x sin (crankrotation)/rodlength)

Try that. I can't fully explain the trigonometry here, as I only know the basics, but I have used this expression on several occasions for piston actions. Hope it helps!

Edit: you apply this to the rotation channel of the piston rod object.

Hey, thanks for that. That makes it clearer. So, is that an Lscript? I mean are the parentheses correct?

-When you click on a function from the menu, say asin how do you then add sine, or more than one function since it overwrites it?

Preumably, the crank rotation will be in radians... ?

Working on it.

Thanks.

M

stevecullum
11-12-2007, 05:31 AM
Sorry, I don't think the syntax is bang on, but you do need to write this as an expression in the graph editor and apply it to the rotation channel of the rod object.

Its one I used in an old XSI project and it worked great. If you have trouble I'll see if I can apply it to a LW version.

meshpig
11-12-2007, 11:36 PM
:help: I seem to be having trouble.

ie. Is the length of the rod and the radius of the crank a value, a channel, or a vector?

Thanks!

M

stevecullum
11-13-2007, 04:14 AM
Yes, the radius of your crank, should be the distance between your pivot point of the rod and the centre of your crank axel. The Rod length is also a fixed amount.

I'll see if I can setup a simple scene to demonstrate....

stevecullum
11-13-2007, 05:09 AM
Got some weirdness going on. Got the expression in, except its not doing what I expected, which means I'll have to dig out the old scene files to see whats gone wrong.

In the meantime have a look at this thread where I discussed this very thing.

http://www.newtek.com/forums/showthread.php?t=74132&page=2&highlight=piston

stevecullum
11-13-2007, 05:55 AM
Right, found this on CGtalk and its working fine. You'll see if you look at the expressions that we were near enough there, but needed some extra math to finish it off. I think this is to do with Global and Local rotations...not sure totally, but least it works!

meshpig
11-13-2007, 11:39 PM
Right, found this on CGtalk and its working fine. You'll see if you look at the expressions that we were near enough there, but needed some extra math to finish it off. I think this is to do with Global and Local rotations...not sure totally, but least it works!

Hey, that's awesome... thanks for that, including the link. Interesting! It's very neat and accurate!

I'll post it when I have tidied the model up and rejigged it!

:thumbsup:

Thanks again.

M

meshpig
12-07-2007, 11:14 PM
Got back to this project this morning before breakfast. Seems like once the problem of animating machinery is solved, you can go ahead with modeling.

Saturdays are good for knocking stuff up...

52920

52921

52922

52923


M

stevecullum
12-08-2007, 05:24 AM
Nice modelling sir!

I'm also trying to figure out a good way to animate a chain. I got a cool morph trick and a hardlink set up so far, but there is a few teething problems.... are you also going to animate the chain in this scene - any ideas?

meshpig
12-08-2007, 08:58 PM
Nice modelling sir!

I'm also trying to figure out a good way to animate a chain. I got a cool morph trick and a hardlink set up so far, but there is a few teething problems.... are you also going to animate the chain in this scene - any ideas?

Thanks Boss..! Yes, it seems to work fine with just a morph. This is all I have on hand.

52942

I have done some using 2 chains on top of each other with different maps for each. I think it's a matter of timing, getting the move distance over the speed right.

Also, the twist deformer seems to work for compressing a spring. if you twist it outwards, the mesh expands... so when you stretch the y axis of object to half size the spring appears to maintain it's shape. It rotates though, so you need a channel follower to compensate. Still working on it but bones are out of the question because you need to snake quite a few of them up the tube to get an even effect.


52943



M

evenflcw
12-08-2007, 11:51 PM
Also, the twist deformer seems to work for compressing a spring. if you twist it outwards, the mesh expands... so when you stretch the y axis of object to half size the spring appears to maintain it's shape. It rotates though, so you need a channel follower to compensate. Still working on it but bones are out of the question because you need to snake quite a few of them up the tube to get an even effect.

Neat finding. Don't think I've ever read about anyone using that approach. Not sure I understand how that works. Any chance you could write some more and post some files? The more common approach is not using bones, but endomorphs. Commonly you would lathe two springs, one compressed and one relaxed, and use bkg2morph to assign one to the other as a morph. Then use modifier or expression to drive the morph. This might be less optimal to you because you might not remember your Lathe settings and/or you might have messed up the point order when you continued working on the spring.

EDIT: Nice pistons! :)

meshpig
12-09-2007, 12:00 AM
Hey, also. I spent some time reflecting on what I actually did recall from 30 years ago when I dropped maths to do art.

It's quite amazing what you actually do recall when you freeze something in it's tracks and/or need to.

-Arcsin is the inverse function of Sine where you are looking for angles for which Sine is = to half. "sin-1()".


m

meshpig
12-09-2007, 12:31 AM
Neat finding. Don't think I've ever read about anyone using that approach. Not sure I understand how that works. Any chance you could write some more and post some files? The more common approach is not using bones, but endomorphs. Commonly you would lathe two springs, one compressed and one relaxed, and use bkg2morph to assign one to the other as a morph. Then use modifier or expression to drive the morph. This might be less optimal to you because you might not remember your Lathe settings and/or you might have messed up the point order when you continued working on the spring.

EDIT: Nice pistons! :)

Sh!te, I'm just spline patching the springs in all of a few minutes. I hadn't thought of bkg morphing, thanks that's logical and probably why it's most often used.

The twist deformer is interesting probably because I am being a little too ponderous. It does and it doesn't, the problem is the outward twist isn't easily compensated by HPB.

Apart from that, it does bloat the mesh along the one axis rather than simply stretch it. I'll compare and post.

Thanks!

m

stevecullum
12-09-2007, 07:55 AM
I would also go with morph springs, as its easier to animate in layout, but everything seems to be coming together nicely so far. ;)

meshpig
12-09-2007, 04:24 PM
I would also go with morph springs, as its easier to animate in layout, but everything seems to be coming together nicely so far. ;)


Yes, compared to using the twist deformer they're very quick to build and animate. Bkg2morph is the perfect tool.

As you can see using the deformer isn't nearly as good.

M

52961

52962