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 iteration and getting index of objects upon object specific event
Posted: 17 April 2016 09:46 AM   [ Ignore ]  
Total Posts:  108
Joined  2015-11-30

Hi all,

I have a bunch of objects being iterated through to check if they are colliding with a plane,
I’d like to get a read-out which indicates when a collision takes place and the index of the object(s) colliding. Is this possible with xpresso?
Please check my test scene:
https://dl.dropboxusercontent.com/u/24304389/step2time_collision_v3.c4d

I have come across this problem in the past, what exactly does the iterator output, does it have a format? list?
If it was like a proper for-loop then we should be able to do things like interrupt,
execute things while the loop is going..
Am I right in thinking that xpresso nodes all execute once per frame, and an iterator exectues x amount per frame, so its impossible to do things while in the actual loop?

Profile
 
 
Posted: 17 April 2016 05:58 PM   [ Ignore ]   [ # 1 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

Hi NNenov,

The Iteration node counts from one number [integer] to another number [integer] with a single steps [1]. To have the same result as with the Hierarchy you need to fill these objects in a Link-List. Eventually this will shorten the set up.

The Iteration is a “counter” not an If-Loop, so it does what is requested per step and then goes to the next step, all in on frame ONLY. What ever information flow/calculation is required for that single step will be done, and then it goes to the next.

Please note, this might require often to go to the X-Manager, and sort the items in the sequence they have to be processed. Typically XPresso figures the logical sequence on its own, but it doesn’t hurt to keep this in order.

The XPresso Node has [Attribute Manager] a Camera Dependent checkbox, which keeps things “real-time-like”, as well the Hierarchy in the whole set up [Object manager] is most of the time crucial.

If my impression goes in the right direction, you might rather look into Python. Based on storing values, but I have used points from meshes as “memory” to keep values, just a thought.

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: 18 April 2016 08:45 AM   [ Ignore ]   [ # 2 ]  
Total Posts:  108
Joined  2015-11-30

I haven’t looked properly at the xmanager before, thanks for the tips, I’ll check the order of things.
But it looks like I will probably have to use (and learn) Python to do this properly.

Profile
 
 
Posted: 18 April 2016 01:55 PM   [ Ignore ]   [ # 3 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

You’re welcome, NNenov,

If you need to make a decision while the Iteration is running, it will have to be for all the same. E.g., In the Logic part of the X-Pool (which you have used already), you will find nodes to make those comparative decisions.

In the Calculate, you will find the Formula Node, which opens up a lot of more options, e.g., an “If then statement (as formula). All formulas are in the Appendix of the manual.
https://help.maxon.net/us/pics/024452.jpg


Python is certain a mighty option in Cinema 4D and if you like to learn it, go for it. I would start with the “normal introduction” of Python. It is a language developed for kids, so not very cryptic. The deeper stuff starts, compared to the language itself, to use all the options in C4D-Python. I have done course in German and English, and I missed in all, a fundamental and detailed explanation of the SDK. So, no suggestion here, I presume that this question would come. FXPHD has both—introduction and C4D based course. You find some short examples here of course on Cineversity.

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
 
 
Posted: 18 April 2016 06:27 PM   [ Ignore ]   [ # 4 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

P.S.: here is a little example with collision and how it can manipulate objects (supply a random number as long as the collision is going on.)

File Attachments
CV2_r17_drs_16_XPcl_01.c4d.zip  (File Size: 59KB - Downloads: 123)
 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: 19 April 2016 05:38 AM   [ Ignore ]   [ # 5 ]  
Total Posts:  108
Joined  2015-11-30

Woah thats really interesting, I’ve not used the formula node before, thank you for that example!

I had a look at the formula reference you linked and I cant quite figure out what you are doing in the formula field still,
does it mean: if port 1 = 1 (theres a collision), then output random number, else, output whatever it was before (port 2)?

And the time node is just to make it start working at frame 1?
Although my file is different, I’m achieving something similar, each hierarchy object has its own user data to store its index number and collision status.
In my example scene I could have just made text as child of each cube which uses that data.

The objective is to trigger sounds (or one sound with pitch adjusted) based on index at collision event.
I am getting ahead of myself since I have yet to figure out if its even possible to trigger and render/output synchronised sound based on events in xpresso.

Profile
 
 
Posted: 19 April 2016 01:15 PM   [ Ignore ]   [ # 6 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

Hi NNenov,

You asked about the ? formula and you [edit] gave yourself the answer. yes that is how it works.

Sound is a mixed bag in C4D. Besides great options to place loudspeakers and microphones in “space” and get even up to 7.1 sound, there is very little directly doable.

However, have a look here:

http://nitro4d.com/blog/freebie/soundfx/

It says it is only up to R16, but I guess he is too busy doing his great developments to keep things on the website updated. So I tested it, and it works for me. Please check carefully, as it is a 3rd party product, no guarantee from here)
Note that the collision option triggers a complete play of the sound, including perhaps a the silent part of the sound on the beginning. Which might sound “wrong” (pun certainly intended)

It might be even all you need for what you are up to.

(Side note, I used the Text Object in my file to have a better visual for the demo. Using “User Data” as “memory” is just fine. I like often to use a geometry, and there the point to store my data, in that way you can manipulate the “data” even much more… ;o)


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: 19 April 2016 01:40 PM   [ Ignore ]   [ # 7 ]  
Total Posts:  108
Joined  2015-11-30

Great.
Yeah I emailed maxon and they recommended the same plugin, tested and it works great! renders out and everything.
I wish I could figure out what its doing..

anyways, thank you for all the help.
I’ve never used point data as storage, sounds interesting, do you have any tutorial links for this or can give a general breakdown of your technique?
Thanks again!

Profile
 
 
Posted: 19 April 2016 01:55 PM   [ Ignore ]   [ # 8 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

You’re welcome, NNenov, I’m glad the support confirms it as well, the missing R17 classification made me a little bit uncertain, as I can’t test all configurations (e.g., Team Render with various OS)

I have attached a simple set up as screen shot. Practically you have three values for each point—plus—the number of each point. So, a nice list. It could stroe positions, colors, and more.
I placed the Itteration and the Time [Frame] node close , just a suggestion. The set up with Time[Frame] and position to points is pretty much “Capuccino-Lite”. ;o)

Think of the Global position and local position. If you use the Y value of a Plane object (editable) and store data into each Y , you could just lift the whole object and have added to each value, rotate it and so one. The local values are the same, but the global values will change, and you get a “read-out of all values in the Structure Manager per object. :o) Easier to save out as well, kind of.

You asked as well about the “Time[Frame]>Is Null>Condition”. This is my way of reseting things on frame zero. Often a problem occurs when things are not set back, then anything might be used rather then “original state”, waht ever that was…

My best wishes for your project

 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: 22 April 2016 05:09 AM   [ Ignore ]   [ # 9 ]  
Total Posts:  108
Joined  2015-11-30

Thanks for that example! Learned a lot of handy things in this thread smile

Profile
 
 
Posted: 22 April 2016 06:04 AM   [ Ignore ]   [ # 10 ]  
Total Posts:  108
Joined  2015-11-30

By the way, I also made my first python script to populate the soundFX node file inputs with he contents of a folder of sound files, you select a file in the hierarchy and run the script, select a sound file in a folder of sound files, then the script will populate the file fields of all the soundFX nodes.
Heres a link if you are interested!

https://www.dropbox.com/s/3a6ifk6x7urc4da/GetDir_v1.2.py?dl=0

Profile
 
 
Posted: 22 April 2016 01:10 PM   [ Ignore ]   [ # 11 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

You’re welcome, NNenov, and thanks for sharing.

We have some very fluent Python speakers here, so in all respect to them, because I’m not fluent, so I do not interfere with it. ;o)

Perhaps you can define what you need and make a tutorial request.

… or just have an eye on the Cineversity Wiki:

http://www.cineversity.com/wiki/Category:Scripting/

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