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
   
 
Rolling ball expression for two axis
Posted: 15 October 2016 11:38 PM   [ Ignore ]  
Avatar
Total Posts:  121
Joined  2010-11-01

Hey guys,

someone asked me this today, about how to set up an xpresso setup for a rolling ball that works in both the x and z direction.  Having done it before for tires on a car i figured its easy just to apply the same setup to the other rotation plane.

But I’m missing something, probably to do with the rotation order.

I’ve attached a scene to demonstrate.  The ball rotates as expected if you move the root null in the X direction, and also fine if you move in the Z direction.  But moving both x and z at the same time causes it to flip out.

Is there a better way to set this up, or even just one that works?

Thanks

File Attachments
RotatingBall.zip  (File Size: 101KB - Downloads: 98)
Profile
 
 
Posted: 16 October 2016 05:06 AM   [ Ignore ]   [ # 1 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

Hi Rich,

Yes, certainly the rotation order, as you mentioned.
Have a look at the Sphere’s Parent (Rotate) Attribute > Coord.> Order [HPB]. Not that this will solve this problem, but it is a first hint.

The problem is given in the fact, that what ever axis rotates the sphere first, will change the axis system for the next one in your set up. So the second will only be correct if the first one was 0º.

If you move the Sphere with the leading axis so it turns for example 180º, the sphere will will rotate with the second order of rotation then in the opposite direction.

Besides that, there might be also a point where the axis are lined up with another, and the “Euler Angle Problem” shows up.
https://help.maxon.net/#OCUBE-ID_BASEOBJECT_GROUP1
The Quaternion will not work here, as it uses start and end point to calculate the best path, and that as well as only to 180º per calculation.

What you need to do is to use the vector (rotation delta) of X as well of Z, to create the combined vector. This is the Vector your sphere should have in the next frame.
The position change can be done via Previous Position, but that is of course then the shortest distance, perhaps not the real route. If you dial up the frames per second for the calculation that will be fine. I have preferred so far to use a Tracer and set the interpolation to the closest path. Via XPresso you get the length (Memory for the previous value). Since the Matrix is just 12 vectors Off/V1/V2/V3 it should be simple if sin or cos(valueº) etc is used. Draw a cube with the vectors to see what I mean. Or use the Vector2Matrix node ;o)

All of that has a problem, as the vector is a 360º limitation. Again a higher FPS for that set up will decrease the rotation per frame, then bake would be more precise, if rotational motion blur is needed.

(There are certainly some Python Scripts available that can solve this via Matrix Math, but that is not my area of expertise.)

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 October 2016 05:13 PM   [ Ignore ]   [ # 2 ]  
Avatar
Total Posts:  121
Joined  2010-11-01

Hey thanks very much Dr Sassi, some great ideas to look into there.  Really appreciate the help, and glad it wasn’t just a simple stupid user error smile

Profile
 
 
Posted: 16 October 2016 05:23 PM   [ Ignore ]   [ # 3 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

Hi Rich,

Thanks for the reply. I go with the idea above more into the direction of result based, i.e., renderings. Keep in mind that the problem with the Editor View is, that it refreshes, so the previous Rotation or Matrix will mess things up, which makes it so hard to see what one is doing.
The per frame change is perhaps the simplest, yet not an easy way to get it. I have the impression that with XPresso we have no way to do it. Python might be possible, or C.O.F.F.E.E.
Reseting the Axis, while moving all points back at the same time, so the illusion is given. With larger objects, to shift all points around seems quit an adventure.

Please note that the Distance Node, if feed with a single Real Number, will use those as a Vector! A distance of 100 will result in 173.2 for example
Multiplying and then go from degree to rad , can be done with one node. Rad=2PI for 360º.
If you use the Distance with a Proxy, (Null Object), place the Null as far away from the scene as needed, a position change (relative to the proxy) from -100 to 100 will seen other wise a zero

However, to get the difference angle of the X axis and the Z axis expressed in a vector, and calculate the resulting vector, to change this based on the existing is pure Matrix math, so far, I wasn’t able to find anything. I guess many people would go with that line already into Dynamic and call it a day. I have to admit, that the dynamic has here some advantages. As any object has normally a certain amount of “mass”. This mass and the friction of the sphere to its environment will add more than the mathematical distance/roll ratio, and that is certainly much easier to do in Dynamics. ;o)

My best wishes for your explorations.


https://www.amazon.com/clouddrive/share/HKMNuLtkWZppUrWyhOnmSRezZW5DliXUv531dYERE7h?ref_=cd_ph_share_link_copy

Information added.

 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: 17 October 2016 03:53 AM   [ Ignore ]   [ # 4 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

P.S.:  All source I have found so far, leave the axis untouched and move the points.

So, I used the only combination I came close to do that and I would call it “Work In Progress”.

Since we talk here about a frame by frame appearance of change, and not a game engine, perhaps this might come close.

Not in the link is a version where I tried to rotate the points via XPresso around one axis and then via FFD for the other direction. I run into the HPB hierarchy even then.

I tried all combinations, even deleting polygons and work for the first two cubes only with points, just in case. The Point Normal was used as well (Vector to Matrix) to feed the Rotate Point Node (X-Pool)

I’m not sure what I miss, but I guess it is time after many hours to let you take over ;o) [Edit: the process should be only for two rotations, then the frame is done. Any further rotations wouldn’t happen during rendering. The need to reset the information, as mentioned naming it as “delta”, is required, as shown in the next post. I was running into the “game” trap, to play with it on one frame over and over again. Which has nothing to do with the request at hand. Also, please note that the two rotation (split) with the rotate point node isn’t needed. the resulting vector as mentioned above is the key here. So, all was fine, but again, we do not develop interactive games here, we work for rendering and the final results /edit]

Two scene files:
https://www.amazon.com/clouddrive/share/UJne9da8oEK1FPqbt3b1dxYZVb5qQuIDEZuxcgeaBkp?ref_=cd_ph_share_link_copy

Screenshot (simple version)
https://www.amazon.com/clouddrive/share/7VqqaPSdQqEkWlfewksS7Zz8N8rYziSJ4lQGU0h86UK?ref_=cd_ph_share_link_copy

I searched as well for a plug in, but I haven’t found one.

I’m not happy to leave it in this state, but I might need some creative out time ;o) Perhaps use it as brainstorming, and—fingers crossed—you have an idea.

All the best

edited

 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: 17 October 2016 06:37 PM   [ Ignore ]   [ # 5 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

Hi Rich,

Here is the element that might work for what you like to do. I did it with a cube to keep it simple.

The key is, that the rotation for the two axis is set to the beginning of the “calculation, see XGroup hierarchy.

Once the points are rotated the axis is set back to zero of that Rotation and the next “Delta Rot<360º” can be applied in the next frame.

The Points are set back on Frame zero.

I hope that is the most simplified and easy to use set up. Well, the axis could be separated and processed one after the other, but I guess a per frame evaluation might tolerate that little HPB hierarchy result.

All the best


File:
https://www.amazon.com/clouddrive/share/QnqFumeqVAADBSGcjIabTJ8XJFq9o4hUMUx6NfGrRbk?ref_=cd_ph_share_link_copy
Short little clip
https://www.amazon.com/clouddrive/share/4JiSDBqTXtLaH3CKZCU1q8IBykoKSf469FHS5TEXr4E?ref_=cd_ph_share_link_copy

P.S.: with the Rotating Point option, one could also use the previous position and the current to create the vector I mentioned earlier, and based on distance create the rotation needed, with the two points, the rotation axis would be 90º of it (simplified). A Condition Node could handle the zero movement (if zero then the points are the same. Similar to the reset at frame zero set up, shown in a file above). I followed so far with your two direction rotation, but I guess this would be simpler.
All of that effort makes only sense if the texture needs to roll in an adequate way. If that would be needed, then a simple spline animation would have done, I assumed that wasn’t the target.

 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
 
 
   
 
 
‹‹ Q&A_miscellaneous      Merge joints ? ››