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
   
 
Xpresso Help: controlling the distance between two objects with a slider
Posted: 14 January 2015 01:51 PM   [ Ignore ]  
Avatar
Total Posts:  12
Joined  2010-03-24

I’m not a very good Xpresso connector so I am having a little bit of difficulty with a project.
I have two objects that are already apart from each other on the x-axis, I want to be able to have a User Data slider that allows me to move the distance between the two equally. The distance they are currently at I want to keep the starting point. The distance can increase or decrease.
Is there a tutorial that has a similar issue that I can gain insight from?

Profile
 
 
Posted: 14 January 2015 05:36 PM   [ Ignore ]   [ # 1 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

Hi edgepark,

Sorry for the delay in my reply, but I got no notification (happens sometimes, sorry)

Please share a simplified scene-file or at least specify if the objects have only the need for the distance in X direction.

A simple Null-Parent with two Nulls as “child”, with the same initial distance would allow to take teh Position and Rotation from the Childs and apply it to the two objects in question. The Parent Null would have only the need to be scaled in S.X. It is easy to set up, and allows even adjustments of the Null Childs later on. I tried to find the simplest version so you feel comfortable with it.

This allows to move both through space without “Matrix Mathematic” or other more or less complex ideas. If only the X axis is in question, it might be really simple. Let me know

All the best

File Attachments
CV2_r16_drs_15_XPdt_01.c4d.zip  (File Size: 43KB - Downloads: 202)
 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: 14 January 2015 08:02 PM   [ Ignore ]   [ # 2 ]  
Avatar
Total Posts:  12
Joined  2010-03-24

Thanks Dr Sasi for the one solution.
I have included a simplified version of what I am trying to do. I made several cubes with one cube called “Orginal right Cube position.” This is where I what the cube to start off from and use the controller to push the distance between itself and its left cube equally.
I thought that if I made a null and put it between the average between all the cubes I could use the distance between the existing position and the null and just add that to the current position to make a new. However that will not work. I then used a null as a container to push that but when I link the items in express the cube automatically jumps to a new start position that I do not want.

File Attachments
EquiCubes.c4d.zip  (File Size: 45KB - Downloads: 170)
Profile
 
 
Posted: 14 January 2015 08:10 PM   [ Ignore ]   [ # 3 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

Are you certain that I have the right file, edgepark?

(BendyS…..dW…...c4d.zip (File Size: 107KB - Downloads: 1)

There is not a single “cube” in the scene… nor anything that is named that way.

 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: 15 January 2015 11:36 AM   [ Ignore ]   [ # 4 ]  
Avatar
Total Posts:  12
Joined  2010-03-24

I sorry. I really didn’t want that file out there.
Here is the correct file.

File Attachments
EquiCubes.c4d.zip  (File Size: 45KB - Downloads: 217)
Profile
 
 
Posted: 15 January 2015 05:18 PM   [ Ignore ]   [ # 5 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

Hi edgepark,

The problem with this is certainly given that you like to change something, but at the same moment you like to work with the original data. Once the changes start, the calculation will be done for each frame or with each frame “refresh”. Think of a microphone feedback loop.

To avoid this, we need something to store the original data in, this can be Nulls, a complete (invisible) copy of the cube) ore just points of a mesh. Which brings my idea back to the original idea, which is simpler to do.
You didn’t use it, so lets move on. Another simple way would be done with polygons (single) and a Connect Object and then via MoGraph. Scale from the Effector origin. I skip this here as well, as you didn’t use the first one, XPresso is requested. OK. :o)

I assume that the moment is larger when the distance was initially larger, and smaller if closer. So a dynamically movement, right. If you add just the slider-value to it, then you would need the middle point.
Hence why I suggested the scale/null method. You haven’t answered the X only question, so I assume here as well, that X is the only direction you need.

The Original Right Cube stays on its position, otherwise to which of the cubes is it supposed to be reacting to. It can’t to the average of all, as they react to the cube, feedback loop again.

So the right cube stays, and the distance is scaled each time, no middle point needed.

Have a look to the file, and the slider on the “XP_controller Null”. 100% means here, they moved completely to the original right cube. Negative values means, they move away. Of course 0% they do not change at all. IF you move the “stored” cubes, you create a new start. You could even feed the Z and Y values, if you like to adjust the stored ones.

You will see that I added to the P.X value 100,000 before I went on to move the cubes. This is a step that prevents to mess with the +/- coordinates. As distance and added values to positive as well negative X values would lead to an unwanted result. If your cubes have the need to move beyond that dimension of 100K, adjust the values!

All the best

Sassi

P.S. file…01 had two adapters in it, which were obsolete already. …02 is fixed.

File Attachments
CV2_r16_drs_15_XPcc_02.c4d.zip  (File Size: 63KB - Downloads: 188)
 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: 15 January 2015 05:43 PM   [ Ignore ]   [ # 6 ]  
Avatar
Total Posts:  12
Joined  2010-03-24

Thanks again Dr Sassi! I do only want to move the objects on the X axis. I see that is is working but I am still trying to wrap my head around the last part of adding a P.X value of 100,000. Could you explain how the iterate operation functions in this instance? There is an end value of 6 but how does this effect the rig? I see how it is linked to a link list manager (which is very helpful) which contain my 7 cubes. I’m just trying to get a better understanding of what is going on so I can apply similar solutions to future projects.

Thanks so much for your help.

Profile
 
 
Posted: 15 January 2015 07:21 PM   [ Ignore ]   [ # 7 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

Of course I will do.

To move the initial values way beyond its origin will make certain that I do not have negative values. In a nut-shell, the distance of the objects will stay the same, e.g., (-3) distance to (+4) equals 7, or 99,997 to 100,004 is also seven.  If I added: (-3) + (+4) I get one! So, if I mix the negative and multiply things in the same way, it changes. Distance is absolute, the positions are not: they are negative or positive.
Let me try it more practically, set the 100,000 to 1 in both “Add” nodes. Now observe the Left.1 and Left.2. While using the slider, the Left.2 moves so much faster to the left now (!), even with a smaller distance to the static origin cube, which is not what we want.


The Iteration node, is set to 0-6 for the seven member of the Link List. The first position is here the zero. Member 7 is the number 6. (In the old days the systems where weak, so the zero was used for that, and not tossed away, To keep all compatible, this works even today in many areas that way)
The Iteration counts from 0- to 6 in this case one time (!) per frame. So it provides per frame one time each member to the Object container. In that way the values of each can be read out or re-written.
I use here on Link List to request the original state of the cubes, the copies. Then I do the math and provide that data to the Link List members in a similar way. As both Link Lists get the same iteration, they work in sync on those cube pairs.

Let me know if you need more information here. (BTW, reload the file please, I left two adaptors in it—not needed)

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 January 2015 12:15 PM   [ Ignore ]   [ # 8 ]  
Avatar
Total Posts:  12
Joined  2010-03-24

Dr. Sassi,

So the values in the math additive operators have really nothing to do with the distance between cubes then? I was messing around with this and thought I could add another user data filed that filled in that parameter that I could control. I think i would have to make sure this was a positive number from what your saying then.  I wound up breaking the rig but thought I would experiment.
Thanks for taking time to further explain. I really appreciate it.

- Ken

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

Hi Ken,

I have used several Math-Nodes. The two with the “+100,000” are the ones who deal with the “polarity” of the coordinates. It moves it for a short moment out of the problem-zone.

All the other Math Nodes (Add, Sub, Mul) are there to find out how to move the cubes along your description from above. I tried to find the logic in it that made the most sense (to me), as often—there might be another interpretation possible.

My suggestion, explore and even break things apart, Anything you do will fill the “library” inside of you and that is the “stuff” that makes you work with ease inside of XPresso after a while. I say that, as I explore “what learning is” since over a decade, in terms or teaching 3D and Cinematography, via, e.g., tutorials or hands on classes. My findings so far, after “consumed” nearly 6,000 tutorials from others and many courses, some will elevate you, some will even block your future development. BUT: your own curios exploration and asking if you hit the wall, will allow for the vast options real “creativity” has: to be infinite. So, enjoy the ride and play!

My best wishes

 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