Creating a Pedal cycle animation

Ok,
What we have here is a mock up of the animation I need to create.
The final will be an animation that show hat muscle is being used at different points of of pedal cycle.

First:
I need is a pedal that rotates around a circle.
That seems easy enough.
But when I parent the pedal to the crank arm, the pedal rotates as the crank arm spins.
Is there an easy way to have the pedal rotate with the crank arm and not rotate the pedal on its axis?

Next:
I need the legs to change color depending on the degree or clock position of the pedal.
For example, when the pedal is at the 2 o’clock position the lower leg would turn red.

Is there a way to do this in Blender?
Dummy pedal rig attached.

Thanks in advance guys.



dummy5.blend (535 KB)

“First:
I need is a pedal that rotates around a circle.
That seems easy enough.
But when I parent the pedal to the crank arm, the pedal rotates as the crank arm spins.
Is there an easy way to have the pedal rotate with the crank arm and not rotate the pedal on its axis?”

Here what I would do:
Delete all the animation on pedal crank and bones of the leg.

Add an Armature with two bones for crank and pedal (Pelad bone = parented to crank bone).
Animate the crank bone with some keys (best Euler rotation) for a 359°rotation (or what ever is needed).
In the Armature / Bone settings (pose mode) for the pedal bone (=child): deselect ‘Inherit Rotation’.
Parent the pedal to the pedal bone (pose mode --> parent to bone)
Parent the crank to the crank bone (…)

Now the geometry should go with the bones, and the pedal shouldn’t rotate while going with the parent bone.

Foot following the pedal:
Select the Foot bone in the ‘Main’ Armature.
Add a Bone Constraint --> ‘Child Of’ to the Foot bone (pose mode)
Set the Target to Pedal. The foot bone might go wild here, but then click the ‘Set Inverse’ button which should remedy this.

Now the foot should go with the pedal which in turn goes along with the crank animation.


Attachments


Now for the color changing according to the rotation:
Seems to be something for drivers.
I would try giving the material color slot a driver which reacts to the rotation of the crank bone. Would need to figure out how to set this up in detail though…

LOL, now why didn’t I think of that.
So make the crank and armature as well.
I’ll try that.

About the color changing.
It sounds like hat I want to do may not be possible?

OK, I got it to work mechanically, but the material colors I applied to the parts that move don’t show up.
what am I missing?
dummy7.blend (709 KB)

Hi here is a simple driver on the (red) diffuse colour of your leg.

Rather than put the expression into the driver a script was used and added to the driver namespace, see the scripting window.


import bpy
from math import cos, sin

def leg_colour(rot):
    col = max(cos(rot), 0)
    return col

bpy.app.driver_namespace["leg_col"] = leg_colour

The world space x rotation of the crank is passed to the driver. When the cosine of the angle is > 0 the red colour will have this value otherwise 0.

I used the scripting method as to have a different colour for each clock face will require a more detailed script. If you use atan(tan(rot)) it will map the rotation to (-Pi, Pi). You can then use an if elif structure to give a discrete value for each twelfth of the clockface


import bpy
from math import atan, tan, Pi

def leg_colour(rot):
    mrot = atan(tan(rot))
    pon6 = Pi / 6.0
    if mrot > 5 * pon6:
        return 1
    elif mrot > 4 * pon6:
        return 0.8

    ... etc .. etc to > -6 *

bpy.app.driver_namespace["leg_col"] = leg_colour

The same driver on all r, g, b channels will give you a greyscale form black to white, otherwise set up a driver function for each.
Hope this makes some sense.

Attachments

dummy7.blend (750 KB)

Thanks for the replies.
Batfinger,
I downloaded the blender file and hit play but I don’t see the color change.
Do I have to load the script somehow or is it included in the Blender file?

I sort of understand what you’re saying and it looks like it is possible to make this work.
If I’m interpreting your post directly, it sounds as if I can use a script to tell a named part to changes its color between X° to Y° in the world view.
I’m not anywhere near expert enough to fully understand it.
If you have time to dumb it down for me I’d appreciate it.

I don’t even know how to load a script much less write one.