Jump to content

Xpresso Increment Node


shao

Recommended Posts

Hello guys 
im trying to make a car with two wheels, and trying to make those two wheel rotate dinamically with the car movements on the X,Z  axis, 
the problem i have is that i need a node or system using xpresso to get increment a value(distance traveled per frame) so i can get the whole distance traveled through the timeline and whatever the direction of the car is, 
so to make more simple i did a screen, what i want exactly is something that gives me the amount increment of the value in circle in every frame, 
like ((distance in frame 0) + (distance in frame 1) + (distance in frame 2) + (distance in frame 3) + (distance in frame 4) + ...........(distance in the current frame))

XPRESSO.PNG

Link to post

Hello Sir 
thanks at first 

what am i trying to do is to have a tyre of a car  rotates wherever the car goes, the wheel rotates correctlly, 
and i found that the only way to do it is to calculate the distance traveled until a certain frame,

using the distance between each two frames (ex:T1,T2 or T22,T23) and then calculate the sum of all the previous values, 

my prblem is that i dont find a node that calculate the sum of the distance values, 

how can i find a node like that ?

A.PNG

B.PNG

Link to post

My recommendation would be to make use of a User Data parameter as storage for the distance travelled and simply sum the distance per frame into this.

For example it could look like so:

image.thumb.png.eaed89282f006fac04272d3c44e54141.png

The additional Time/Equal/Condition node group is needed to reset the distance on frame 0, otherwise it's pretty straight forward. The "Distance Travelled" port is the User Data parameter of type Real added to my travelling cube, but you could add this parameter to basically any other object or tag you like and see fit.

And the scene: test_xpresso_distance_per_frame_3.c4d

Cheers

Link to post

You can add incrementally by reading the current rotation value and adding to it every frame

 

wheel.c4d

 

distance is always positive, so only works for the car going forwards. There's some clever code written by Base 80 that allows for forward and reverse. You make your wheel a child of the Base80 wheel eg

 

wheel2.c4d

 

BaseWheel1.7.c4d

 

adjust the Base80 wheel to same radius as the real wheel. Only move Base80 wheel by parent null.

Edited by jed
more info
Link to post

All above solutions can work great, and here's my input:

I'm using a Tracer Object, to trace a Cube (Turn Off Trace Vertices in the Tracer Attributes). This will generate a Spline and record the Cube's Trajectory (You can animate the cube by any means and I have chosen a Vibrate tag because I'm lazy).

Then we use XPRESSO to read the length of the Tracer Spline, as it reflects the distance travelled.

I use that as an input to a Range mapper that takes the Circumference of the Wheel (2*Pi*Radius), and maps that to one Radian (Negated because the wheel is going "the other way").

I then put that back into the Wheel P Rotation as Radians (Default Rotation Unit for XPRESSO).

 

I also use an "Align to Spline" Tag to align the wheel to the end of the spline, and set it to Tangential so that it follows the Spline Tangent and orient itself. The Tracer offers the ability to create wheel tracks as well.

Fun!!!

Distance travelled 01A.c4d

Link to post

@noseman I've actually seen solutions to the car wheel problem using the degree node twice, and bringing 360 into things 😁

 

For any radian noobs - a radian is the angle at the centre of a circle when the arc equals the radius. In this pic the red X is distance travelled by the car. Solving for A gives

 

angle = distance / radius

 

radians.png.26cc34553e91b0068d32be9f51955966.png

 

pi is defined by circumference = 2 pi R, but since we are not bothered about complete wheel rotations, pi doesn't really come into this calculation. Radian does not 'include' pi IMHO.

Link to post
1 hour ago, jed said:

..pi doesn't really come into this calculation. Radian does not 'include' pi IMHO.

I meant that in the sense that 2π radians is equal to 360 degrees. So for a full rotation of the wheel, we have 2 Pies... hence the pie is very tasty.

Just in case I wasn't clear.

Link to post

You mean this pie ?

 

homer.png.3543ec70293ed274287bf9af61702cfd.png

 

re @noseman and pi

 

degrees are defined as 1/360 of a full rotation, but radians are defined by the arc radius malarkey - not by the division of a circle, so radian does not "include pi". The reason 360 deg = 2 pi radian is due to the definition of pi ie C = 2 pi R.

 

...changes username to Mr Pedantic...

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...