Jump to content

Wheel rotation along path


carlo_c

Recommended Posts

Been at this for a bit now and am a bit stuck   :ph34r:

 

I've got 4 points conformed to a surface with ray. The object is parented to a Null and that is being animated with a curve and the path object parameter at object level. I have a wheel aligned to it using the Copy SOP. 

 

I have a working wheel rotation setup based off distance, but it doesn't want to work when it's copied onto the point. It is rotating, but in a strange way and I can't figure out why as it's working if I animate it inside it's geometry node with a transform. 

 

Any help is much appreciated, thanks all!

 

 

car_rig_v05.hipnc

Edited by carlo_c
Link to comment
Share on other sites

What about something like this. Instead of raying the wheel to the ground, I have rayed the curve to the ground. Using a measure sop I have added the length of the curve as an attribute named 'perimeter'.

 

Then the wheel simply looks at the length of the path, the position along the path, it's own radius and calculates a rotation value which gets stamped into the X axis for rotation.

 

The attribute wrangle makes the rotation that the copy will stamp with.

float pi = 3.14159;

// Fetch the curve length as a Pimitive attribute from the measure sop.
string handle_path = "op:/obj/curve_length_measured/CURVE_OUT";
float curve_length = prim(handle_path,"perimeter",0);

// Fetch position along path from NULL.
float position_along_path = ch("../../null1/pos");

// The radius of the wheel as a constant, scale as needed or measure the model.
float wheel_radius = 1.0;

//Wheel rot value.
@wheel_rot_X =  360 / (2*pi*wheel_radius) * (curve_length * position_along_path);

ap_wheel_rotates_along_curve_landscape.hipnc

Edited by Atom
  • Like 1
Link to comment
Share on other sites

Once again thanks for your help Atom, that's a much more elegant solution than what I was going with. I'm trying to build a simple car rig and this is really helpful! I was trying to do the wheel rotation independent of needing to know the curve length but I think for my purposes this is actually a much better solution :)

Edited by carlo_c
Link to comment
Share on other sites

I have progressed with my very simple car rig but am at a bit of a road block again.

 

I'm trying to align the car body to the wheels, it's hard to explain but if you take a look at the hip file I've annotated it all. basically the body needs to be aligned to the wheels but I just can't seem to get it to. Hopefully the screenshot explains it a bit too.

 

As you can see it starts off aligned but then decides to do it's own thing, I have tried building my own orientation for it without much success! Any help would be much appreciated, thanks all :)

 

Screenshot_2015-11-18_21-57-48.png?dl=1

 

Screenshot_2015-11-18_21-57-29.png?dl=1

 

car_rig_v09_odforce.hipnc

Link to comment
Share on other sites

Hi Carlos,

The car *really* wanted to become a monster truck, so I obliged.

It is really tempting to pull the prim normal from the oriented bounding box, but that is folly as the prim numbers change as the object rotates. You just need to calculate a solid N and Up for your copy SOP. Your existing N made a decent Up. To calculate N I created a point at the front and subtracted the point in the middle. This new N will always point forward. With this valid N and Up you no longer have to point the nose of the car towards the sky before the copy operation.

 

car_rig_v09_odforce_monsterTruck.hipnc

Link to comment
Share on other sites

To get the direction of A to B, you take B and subtract A.

I wanted to get the normal pointing "forward" in model space. I got a point in the middle/front of the box. I take the position of the middle/front point, subtract the position of the center point, and that gives me the vector from the center point to the middle/front point. I stuff vector that into the normal. The normal and up attributes assist the copy sop node orientation.

 

Understanding (at least) vector math is critical to doing things in Houdini.

Edited by loopyllama
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...