Use angle of a curve to define an attribute?

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 07 July 2012   #1
Use angle of a curve to define an attribute?

I'm animating a speedometer but will potentially have to do this again and again.. thought it might save me a bit of time if I can have it automated.

So my idea is that I want to use the actual angle of the car's Z Translation curve to be used to define the rotation of the speedo's needle.
By that I mean that if I have only 2 linear keys at different points and the car is moving, the needle would be perfectly still, but if I flatten one out it would rotate a bit before stopping..

I then of-course need a way to re-define those figures, but I'm pretty sure I can do that with a Set-Range node, right?

I've got the relevant nodes in the hypershade and have tried connecting every output of the Z Translation animation curve into the Z rotation of my needle.. none of them seem to animate it.

I've played around with other nodes but couldn't find any way a SamplerInfo or CurveInfo could help my cause, does anyone have any ideas?

Thanks for your time,
Tony
 
Old 07 July 2012   #2
sounds like what you need to do is query the velocity.

typically you get velocity by using getAttr to sample the position on current frame and then sample it again at previous frame, when you subtract the previous position from the current one, you get a vector. the lenght of this vector is the velocity, you can even specify a time offset of say 5 frames so that you can have the speedo lag a little bit.

check out the -t attribute for getAttr, this lets you specify which time to sample.

so as an example (im writing this out of memory so it may have errors)

$offset = -5;
$curFrame = frame + $offset;
vector $pos1 = `getAttr -t $curFrame someItem.translate`;
vector $pos2 = `getAttr -t ($curFrame-1) someItem.translate`;
$vel = mag($pos1 - $pos2);
speedo.rotateY = ($vel * 100);

so yeah, play around with that code, im sure i missed something since i code primarily with pymel. I multiplied the velocity by 100, but you would have to play with that to get the desired range of movement.

you could further extend this expression to limit the max speed of your speedo rotation, so that it slowly settles to 0, after the car stops moving, or bounce off a rev limiter by combining a sin with a max function..
__________________
From Russia, with love @ stooch.tv

Last edited by stooch : 07 July 2012 at 11:41 PM.
 
Old 07 July 2012   #3
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 05:04 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.