Selecting and affecting objects in Arrays?

Discussions about SOFTIMAGEs© Interactive Creative Environment©
Mugatu
Posts: 13
Joined: 24 Nov 2011, 19:19

Selecting and affecting objects in Arrays?

Post by Mugatu » 30 Dec 2011, 14:54

Hi there, I was wondering if it is possible to say put 10 pieces of geometry in an array then randomly select an object from that array and affect it in some way e.g. move it to a location?

Im not looking for anyone to provide the exact compound or do it all for me etc I would just like to know if it possible via ICE and whether or not it is very hard to achieve. I have done some things with arrays in maxscript but would like to focus on ICE now.

Thanks :)

User avatar
xsisupport
Posts: 713
Joined: 09 Jun 2009, 09:02
Location: Montreal Canada

Re: Selecting and affecting objects in Arrays?

Post by xsisupport » 30 Dec 2011, 17:11

No. Scene references are resolved once, before the ICE tree is evaluated. You can't have a variable scene reference that changes every time the ICE tree is evaluated.
// Steve Blair
// "You're not a runner, you're just a guy who runs" -- my wife
//
// My Blogs: Arnold | Softimage

Mugatu
Posts: 13
Joined: 24 Nov 2011, 19:19

Re: Selecting and affecting objects in Arrays?

Post by Mugatu » 30 Dec 2011, 18:50

Forgive my ignorance, im not 100% sure what you mean. Do you mean that once it picked an object randomly from the array it cannot then continue the procedure or is the concept not possible at all?

Guess i'll go back to maxscript after all... /cry

Cheers

Chris_TC
Posts: 411
Joined: 22 Mar 2010, 16:43

Re: Selecting and affecting objects in Arrays?

Post by Chris_TC » 30 Dec 2011, 23:39

Do you want to affect existing objects from the scene? The main problem you'll run into is that you can't set data on groups. If you're only dealing with 10 objects, you can plug them in manually and randomly select which one you want affected. But if you have 100 objects, this won't be fun.

Another way would be to work with ICE topology instead, creating new geometry and thus only dealing with a single object (but many topologies). This of course has its own limitations.

Mugatu
Posts: 13
Joined: 24 Nov 2011, 19:19

Re: Selecting and affecting objects in Arrays?

Post by Mugatu » 30 Dec 2011, 23:47

well basically I was trying to replicate a loop like 'for i = 1 to $.count do' type scenario where you would loop through an array of objects and move them one at a time. I thought ICE was a visual programming language and therefore would be able to achieve similar results to that of maxscript.

Cheers

Chris_TC
Posts: 411
Joined: 22 Mar 2010, 16:43

Re: Selecting and affecting objects in Arrays?

Post by Chris_TC » 31 Dec 2011, 11:46

Mugatu wrote:well basically I was trying to replicate a loop like 'for i = 1 to $.count do' type scenario where you would loop through an array of objects and move them one at a time. I thought ICE was a visual programming language and therefore would be able to achieve similar results to that of maxscript.
You can work with loops, but you can't affect scene objects the way you suggested because you need to specify exactly which objects you want to work with.

Example: Let's say you have 9 objects that are called stone1 to stone9. You can work with all of these objects, but you'll have to specify each one separately, like so:

Code: Select all

Set Data stone1.attribute
Set Data stone2.attribute
.
.
Set Data stone9.attribute
You cannot do something like

Code: Select all

Set Data "stone" + i + ".attribute"
When getting data, you can put your objects in a group and work with them as an array. You could then do:

Code: Select all

Get Data stone_group.attribute
And this would return an array of attributes which you could work with. But you can't do the same when setting data.

In most scenarios that ICE is typically used for this is not an issue, but in certain cases I would REALLY like to be able to work this way.

Chris_TC
Posts: 411
Joined: 22 Mar 2010, 16:43

Re: Selecting and affecting objects in Arrays?

Post by Chris_TC » 31 Dec 2011, 11:52

Chris_TC wrote:In most scenarios that ICE is typically used for this is not an issue
Just to follow up on that. If, for example, you wanted to move nine stones consecutively up in the Y axis and wanted to do this with ICE, you would either use instanced particles or even ICE topology instead of working with the nine stones directly. I'll post an example to show what I mean.

Mugatu
Posts: 13
Joined: 24 Nov 2011, 19:19

Re: Selecting and affecting objects in Arrays?

Post by Mugatu » 31 Dec 2011, 12:01

Hmmm, ok so to sum up then I can only GET data from an array of objects but would not be able to MODIFY or SET the data of each object using a loop?


thanks for the info :) Much appreciated.

cheers

Chris_TC
Posts: 411
Joined: 22 Mar 2010, 16:43

Re: Selecting and affecting objects in Arrays?

Post by Chris_TC » 31 Dec 2011, 12:52

Yes, that's right.
Chris_TC wrote:I'll post an example to show what I mean.
Here is one ICE-way of doing things:

User avatar
xsisupport
Posts: 713
Joined: 09 Jun 2009, 09:02
Location: Montreal Canada

Re: Selecting and affecting objects in Arrays?

Post by xsisupport » 31 Dec 2011, 20:53

Mugatu wrote:Forgive my ignorance, im not 100% sure what you mean. Do you mean that once it picked an object randomly from the array it cannot then continue the procedure or is the concept not possible at all?

Guess i'll go back to maxscript after all... /cry

Cheers
Chris_TC answered already, but I'll explain what I meant.
Set Data and Get Data nodes use references to identify what data to get or set.
Those are the "scene references" I meant.

Those references cannot be variables eg you cannot have an array of objects, randomly select an object from that array and plug that into Get Data or Set Data.
// Steve Blair
// "You're not a runner, you're just a guy who runs" -- my wife
//
// My Blogs: Arnold | Softimage