A new version of Cineversity has been launched. This legacy site and its tutorials will remain accessible for a limited transition period

Visit the New Cineversity
   
 
Expresso to solve tire rotation.
Posted: 24 May 2012 06:39 PM   [ Ignore ]  
Total Posts:  13
Joined  2010-01-19

Hey all,
I know this is kind of a complex question but thought I would shoot it out there anyway.  I have modeled a planter for planting crop and it has different sizes of wheels and I need to find a way to calculate the rotation of each wheel of its distance.  I am sure this would be possible using expresso for best and most accurate results just have no idea how to set something like this up.  My only other option at this time would be to do it by hand… Let me know if you have any ideas on this.

Thanks!

Profile
 
 
Posted: 24 May 2012 06:48 PM   [ Ignore ]   [ # 1 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

Hi QAgraphics,

it is a returning question and my favorite idea is so far to use the “Previous Global Position” and the “Global Position” to get the needed distance and then the rotation from frame to frame. This in relation to the diameter (PI) of the wheel and you get the rotation. I guess that part is not in question.  You might use the distance for all, if no curve is driven, or calculate for each wheel/tire a new one.

This results in a frame by frame calculation, which might will not work for Motion Blur! If that is needed and not working otherwise you need to turn this expression into an Motion/Animation Clip. Check the data if it works smooth for MB and you are ready to go.


I hope that helps

All the best
Sassi

 Signature 

Dr. Sassi V. Sassmannshausen Ph.D.
Cinema 4D Mentor since 2004
Maxon Master Trainer, VES, DCS

Photography For C4D Artists: 200 Free Tutorials.
https://www.youtube.com/user/DrSassiLA/playlists

NEW:

NEW: Cineversity [CV4]

Profile
 
 
Posted: 25 May 2012 10:26 AM   [ Ignore ]   [ # 2 ]  
Total Posts:  13
Joined  2010-01-19

Hey Sassi,
Thanks for the reply.  I did some more digging into more methods and actually found this.  Might be helpful for some people to see another solution.

File Attachments
Rotation wheels Different Sizes.zip  (File Size: 160KB - Downloads: 529)
Profile
 
 
Posted: 25 May 2012 12:11 PM   [ Ignore ]   [ # 3 ]  
Total Posts:  21
Joined  2007-03-27

Please see example below if it helps.

Cheers
Lennart

# simpleWHEEL Python example by tcastudios.com@2011
#
# Copy and paste all this to a Python Tag attached to an Object to be rotated (Pitch).
# Place the Object Under a parent. Move the parent :)

import c4d
from c4d import Vector 
as v

#  Stored position
lastpos v(0)

def main():
    global 
lastpos

    
#  Check for parent to drive the roll
    
wheel op.GetObject()
    if 
not wheel.GetUp():
        return 
False

    
# Set the radius
    
radius  200

    
# Get Parent info
    
parent    wheel.GetUp()
    
parentm   parent.GetMg()
    
parentpos parentm.off

    
# Check if Lastpos memo
    
if not lastpos:
        
lastpos parentpos

    
# Get the Last position as a local value
    
lastpos = ~parentm lastpos

    
# Calculate the rotation using Lastpos z vector as delta (distance)
    
rot lastpos.z/radius

    
# Set the new rotation by adding new rotation to old rotation
    
wheel[c4d.ID_BASEOBJECT_ABS_ROTATION,c4d.VECTOR_Y] wheel[c4d.ID_BASEOBJECT_ABS_ROTATION,c4d.VECTOR_Y] rot

    
# Store Parent position
    
lastpos parentpos 
 Signature 

R13 | OSX | http://tcastudios.com

Profile
 
 
Posted: 25 May 2012 12:20 PM   [ Ignore ]   [ # 4 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

Hey QAgraphics,

You’re welcome. Nice of you to think on others. It might be helpful, but my intention here is that people try to solve it on their own, a reason why I do not suggest so often plug ins, it creates in my perspective only dependency. This idea follows relatively my suggestion from above, which I did many years ago for the PXC.
If you have to rely on other peoples solutions, you can’t change them as quick as it would be your own that you change. To create your own solution sets you free. As this is Cineversity, I hope people check this out and try to rebuild from memory! (Not just copy it) The more one is creating such things, the more s/he will be more efficient in his environment and with that more successful. This is certainly my target here.

Base:80 (to give the credit he deserves) is the author of your attached file and certainly a well accepted source of solutions.

Have a great weekend

Sassi

 Signature 

Dr. Sassi V. Sassmannshausen Ph.D.
Cinema 4D Mentor since 2004
Maxon Master Trainer, VES, DCS

Photography For C4D Artists: 200 Free Tutorials.
https://www.youtube.com/user/DrSassiLA/playlists

NEW:

NEW: Cineversity [CV4]

Profile
 
 
Posted: 11 May 2015 07:53 AM   [ Ignore ]   [ # 5 ]  
Avatar
Total Posts:  4
Joined  2007-01-30

Thanks! For me the best solution ever because of the ease of use and no plugins grin Is there a way to set the Radius of the object automatically..?

tcastudios - 25 May 2012 12:11 PM

Please see example below if it helps.

Cheers
Lennart

# simpleWHEEL Python example by tcastudios.com@2011
#
# Copy and paste all this to a Python Tag attached to an Object to be rotated (Pitch).
# Place the Object Under a parent. Move the parent :)

import c4d
from c4d import Vector 
as v

#  Stored position
lastpos v(0)

def main():
    global 
lastpos

    
#  Check for parent to drive the roll
    
wheel op.GetObject()
    if 
not wheel.GetUp():
        return 
False

    
# Set the radius
    
radius  200

    
# Get Parent info
    
parent    wheel.GetUp()
    
parentm   parent.GetMg()
    
parentpos parentm.off

    
# Check if Lastpos memo
    
if not lastpos:
        
lastpos parentpos

    
# Get the Last position as a local value
    
lastpos = ~parentm lastpos

    
# Calculate the rotation using Lastpos z vector as delta (distance)
    
rot lastpos.z/radius

    
# Set the new rotation by adding new rotation to old rotation
    
wheel[c4d.ID_BASEOBJECT_ABS_ROTATION,c4d.VECTOR_Y] wheel[c4d.ID_BASEOBJECT_ABS_ROTATION,c4d.VECTOR_Y] rot

    
# Store Parent position
    
lastpos parentpos 
Profile
 
 
Posted: 11 May 2015 02:04 PM   [ Ignore ]   [ # 6 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

Hi StudioLex,

Perhaps via “Bounding Box”, but I think that wouldn’t be the way. If it is initially checked and stored, the rotation wouldn’t work with a tire that has a flat ;o) ...seriously, tires are most of the time not perfectly round, and slow-rotation with the little “belly” towards the floor reduced the radius and with it the amount of rotation increases, if centrifugal power works on it it might be a little bit larger than when it stops, but perhaps that is covered with motion blur.

Just my two cents, Python free - though.

Perhaps you add two Null Objects—one on the axis and one on the outer edge of the tire. The distance might be easy then.

All the best

 Signature 

Dr. Sassi V. Sassmannshausen Ph.D.
Cinema 4D Mentor since 2004
Maxon Master Trainer, VES, DCS

Photography For C4D Artists: 200 Free Tutorials.
https://www.youtube.com/user/DrSassiLA/playlists

NEW:

NEW: Cineversity [CV4]

Profile
 
 
Posted: 16 May 2015 02:01 AM   [ Ignore ]   [ # 7 ]  
Avatar
Total Posts:  4
Joined  2007-01-30

Thanks Dr. Sassi

Profile
 
 
Posted: 16 May 2015 03:33 AM   [ Ignore ]   [ # 8 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

You’re welcome, StudioLex, even if I think I did not help a lot.

If you have a little scene file, and let me know your target, I’m happy to explore it with XPresso in mind—or perhaps something else pops up ;o)

Have a great weekend

 Signature 

Dr. Sassi V. Sassmannshausen Ph.D.
Cinema 4D Mentor since 2004
Maxon Master Trainer, VES, DCS

Photography For C4D Artists: 200 Free Tutorials.
https://www.youtube.com/user/DrSassiLA/playlists

NEW:

NEW: Cineversity [CV4]

Profile
 
 
Posted: 16 May 2015 02:18 PM   [ Ignore ]   [ # 9 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

Hi there,

Thinking about this, I would like to offer an alternative. My intention is not to have a game like option to play with a car in C4D, but to get closer to a comfortable set up for an animation that results in a car/tire movement. Lets start with a single tire. (All of that is a suggestion/brainstorming)

First we need a path, a “Spline” with a vertices/point on each frame. This can be taken from any baked animation of Character>Manager>Cappucino. In the Timeline (keyframe) the function is called Position Track to Spline. Have at typical “head and tail” of 10 or 20 frames padded to your animation, I will explain later.

If that is a flat Spline with no altitude change, you might project a copy to the surface. Mesh>Spline>Project. With that we have two splines, one above the surface, and which can (if needed) work as “rail”, to get things stable.

I repeat the idea with the axis and the null: Use a child null to pull it to the tire size, which gives two objects and with that the radius.

With the splines we have a representation of the path, and the information of the next position and all other position as well. This allows now to calculate the the distance between Spline vertices, and even the direction. The spline allows as well with the Mesh>Transform Tools>Magnet to manipulate the Spline (preferably a copy), take a large radius if the tire jumps for example.

The points or vertices allows as well to calculate an average position, which could be used for the shock-absorbers and springs to get some “delay” kind of data, as these elements sits between the car body and the tire. With that average, we getting closer to the brainstorming of a whole vehicle.

The rear tires follow the front tires, the front tires follow the next vertices. The frame work of the vehicle follows the average motion based on inertia. based on the numbers of tires, two, three or four. We have to decide how to manage the movement of the vehicle. With two it is rather simple, but it needs an idea to get the tilt movement established in the curves. Having driven a motorcycle bike, the last one a self-build replica of an “EGLI” bol d or, I know how to get the bike into a curve, after 70K miles this is muscle-memory, but it is always lead by an little counter curve. Anyway, that is maybe not really visible.

For a car, I would think of the rear axis as one point (position Mix in XPresso) and the two front tires/axis as two more points. With that we have three points to stabilize the framework of the vehicle. Position, Target and Up vector will create a stabile triangle. The position of each should be an average of the positions—how many—is based on the “set up of the car. A sports-car has maybe half of a second, a family station wagon up to two seconds. Which would be an easy thing in Python (loops) but not impossible in XPresso, but way more work.

I hope that little brainstorming helps to create you very own car set up. Some “Euler Angle” problems will occur if the tire stops, but perhaps a “If” question about equal position of target and tire might heal that. ;o)

There are other methods, with several Null Objects, overcoming some problems. It is all in the preparation, and as I mentioned initially, the target for me is a rendering, not simulating a game interactivity. For game like things, perhaps Dynamic and Python is the key, with key board directing.

Enjoy your weekend

 Signature 

Dr. Sassi V. Sassmannshausen Ph.D.
Cinema 4D Mentor since 2004
Maxon Master Trainer, VES, DCS

Photography For C4D Artists: 200 Free Tutorials.
https://www.youtube.com/user/DrSassiLA/playlists

NEW:

NEW: Cineversity [CV4]

Profile