We are pleased to announce that the si-community board has been upgraded to phpBB version 3.2.1! Let us know what you think , report bugs , and find out what has been improved in this thread
Click the "X" in the upper right corner to close this announcement

BookScatter

Post Reply
caledonian_tartan
Posts: 252
Joined: 17 Feb 2010, 16:13

BookScatter

Post by caledonian_tartan » 14 Sep 2012, 15:18

Moderator edit - I've forcefully and experimentally moved this topic to our Community ICE Project subforum,
just to focus your attention at that part of the community once again - HB


Hello Community
i stumbled on this a few days ago:
http://mourelask.weebly.com/bookscatter.html

it's a max script to scatter books into a shelf.

what a nice training to do this in ice.

Already (more or less) working is this:
- create Rows and Colums of an arbitrary number of books.
- flip probability
- random scale
- align in Z
- tilt some books

i'm stuck with a few things.

1. if a book is tilted, the other ones should move to the side accordingly. (collision)

2. it should be possible to make some books stapled rather than standing

SceneFile


Image
Image

don't get scared by the messy ice tree. looks worse than it really is. the lower half of it is only WIP...
just download it and fiddle around.

i'd be happy about every input/comment.
cheers
SI 2015 @ WIN7-64

User avatar
origin
Posts: 619
Joined: 09 Jun 2009, 11:59
Location: warsaw

Re: BookScatter

Post by origin » 14 Sep 2012, 20:21

you probably need to check previous particle orientation & scale (bounding box of mesh?) to see how much you can rotate.

just for fun, bookshelf with bullet particles ;)
bulletparticlesbookshelf.jpg
Attachments
bookshelf_with_bullet.7z
(147.03 KiB) Downloaded 467 times

User avatar
Mathaeus
Posts: 1659
Joined: 08 Jun 2009, 21:11
Location: Zagreb, Croatia
Contact:

Re: BookScatter

Post by Mathaeus » 14 Sep 2012, 21:45

Hi there,

here's old one I already have. It performs, let's call it, one dimension packing. The trick is to create an array, take position of two neighboring members, place an appropriate particle in the middle of two. Array is created from bounding boxes sizes. This one works by carefully aligning all members "on the corner", placing centers to bounding box centers (by appropriate SI command). So, group member's global position, represent a half of bounding box. In this way, there is no need for ICE tree on each member of instance group, for calculating bounding box. Rotated ones are just "faked".

As it is noticeable, it's able to align instances of different sizes.

I've added a few comments in ICE tree.
BTW, Origin's solution looks a bit... smarter :) Anyway, take it here.

Image
The renderer "turtle" used by this scene, is not currently available. The "turtle" renderer will be used instead.

caledonian_tartan
Posts: 252
Joined: 17 Feb 2010, 16:13

Re: BookScatter

Post by caledonian_tartan » 17 Sep 2012, 11:36

thanks guys!
looking forward to check your scenes!
...you probably need to check previous particle orientation & scale (bounding box of mesh?) to see how much you can rotate...
that's what i do. i check the previous or the next particle depending on it's tilt angle (pos or neg). it also only checks the books group in the same part of the shelf.

simulating works, and looks quite cool, but i try to avoid to simulate.

i hope i find some time to work on this afternoon.
SI 2015 @ WIN7-64

User avatar
origin
Posts: 619
Joined: 09 Jun 2009, 11:59
Location: warsaw

Re: BookScatter

Post by origin » 17 Sep 2012, 14:40

I was thinking about something different,
vect1 = particle[id+1].position - particle[id].position
vect2 = vect1 - book_height
angle = angle_between(vect1,vect2)

maybe also position +- book width, and book height vector rotated with particle orientation
Attachments
angle.jpg
angle.jpg (9.67 KiB) Viewed 5847 times

User avatar
dwigfor
Posts: 392
Joined: 17 Nov 2009, 18:46

Re: BookScatter

Post by dwigfor » 17 Sep 2012, 18:57

I was looking at a similar approach to that, Origin, but I think opposite. Knowing the angle of the books (some are tilted), how far would you have to push the book to the side to make room.

That could be accomplished by taking the sin of angle * book height = how far book would move to side (x). You'd also have to account for thickness of books.

The next problem would be if the book next to it was also tilted. I think you could calculate their intersection point via emTools intersecting line compound. But I didn't get that far...

User avatar
origin
Posts: 619
Joined: 09 Jun 2009, 11:59
Location: warsaw

Re: BookScatter

Post by origin » 17 Sep 2012, 20:45

semi-working ;) solution...
dunno if you can get bounding box of instanced shape in ice. If think for such things some kind of script node would be faster to setup

[media]https://vimeo.com/49622503[/media]
Attachments
bookshelf_bleh.zip
(145.99 KiB) Downloaded 542 times

User avatar
Mathaeus
Posts: 1659
Joined: 08 Jun 2009, 21:11
Location: Zagreb, Croatia
Contact:

Re: BookScatter

Post by Mathaeus » 17 Sep 2012, 21:24

about getting bounding box, well there is a stupid trick I've mentioned before, just to put center on bounding box, then to place object "on the corner" to some null or so - distance is then a half of bbox. Actually this works with rotated objects too. Definitively it should be faster to calculate the bbox once for forever. Last time I've tried to get bbox, using ICE tree on each object, it worked, but SI liked to crash.
The renderer "turtle" used by this scene, is not currently available. The "turtle" renderer will be used instead.

iamVFX
Posts: 697
Joined: 24 Sep 2010, 18:28

Re: BookScatter

Post by iamVFX » 17 Sep 2012, 21:41

origin wrote:dunno if you can get bounding box of instanced shape in ice
sure, by multiplying the bounding box size of the original object by the size and scale vector of each of the particle

User avatar
origin
Posts: 619
Joined: 09 Jun 2009, 11:59
Location: warsaw

Re: BookScatter

Post by origin » 17 Sep 2012, 22:08

yes, but it's not possible (?) to get data from .shape attribute (maybe with custom node?)
(when you try to make user-friendly compound, with only shape attribute exposed)
or when you put a group in instance shape node, you can't retrieve group id of object.
I hope I make sense with my pseudo english

User avatar
Mathaeus
Posts: 1659
Joined: 08 Jun 2009, 21:11
Location: Zagreb, Croatia
Contact:

Re: BookScatter

Post by Mathaeus » 17 Sep 2012, 22:29

origin wrote:yes, but it's not possible (?) to get data from .shape attribute (maybe with custom node?)
(when you try to make user-friendly compound, with only shape attribute exposed)
or when you put a group in instance shape node, you can't retrieve group id of object.
I hope I make sense with my pseudo english
I know you know :) that group contains array of whatever attribute exists on all members. So, if all members of group have ICE tree which calculates bbox and sets it as custom attribute, it's possible to assign this to particles in point cloud, created by same pattern. self.ID> select in array and so. But doesn't seem to be so stable, at least in my experience.
The renderer "turtle" used by this scene, is not currently available. The "turtle" renderer will be used instead.

iamVFX
Posts: 697
Joined: 24 Sep 2010, 18:28

Re: BookScatter

Post by iamVFX » 17 Sep 2012, 22:32

origin wrote:yes, but it's not possible (?) to get data from .shape attribute (maybe with custom node?)
(when you try to make user-friendly compound, with only shape attribute exposed)
or when you put a group in instance shape node, you can't retrieve group id of object.
When you selecting a group in instance shape node you still need to provide id of the object for each of the particle. Sure, you should also provide the name of the group for a compound, it is an ice limitation, user should deal with it, because it is nesssecary for selecting the object from the group array to get bounding box information.
origin wrote:I hope I make sense with my pseudo english
Look at my messages, I make mistakes all over the place and sadly nobody even corrects me :Р
Mathaeus wrote:that group contains array of whatever attribute exists on all members. So, if all members of group have ICE tree which calculates bbox and sets it as custom attribute, it's possible to assign this to particles in point cloud, created by same pattern. self.ID> select in array and so.
Exactly. Basically when you referencing a group name in Get Data node you get an array of attributes of its objects which matches the id of particles, if the same group was selected as an instance group

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest