It is currently 24 Jul 2017, 20:39

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 12 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: BookScatter
PostPosted: 14 Sep 2012, 15:18 
Offline

Joined: 17 Feb 2010, 16:13
Posts: 252
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


Top
 Profile  
 
 Post subject: Re: BookScatter
PostPosted: 14 Sep 2012, 20:21 
Offline
User avatar

Joined: 09 Jun 2009, 11:59
Posts: 619
Location: warsaw
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 ;)
Attachment:
bulletparticlesbookshelf.jpg
bulletparticlesbookshelf.jpg [ 48.88 KiB | Viewed 5907 times ]


Attachments:
bookshelf_with_bullet.7z [147.03 KiB]
Downloaded 463 times

_________________
http://vimeo.com/origin/videos
Top
 Profile  
 
 Post subject: Re: BookScatter
PostPosted: 14 Sep 2012, 21:45 
Offline
User avatar

Joined: 08 Jun 2009, 21:11
Posts: 1649
Location: Zagreb, Croatia
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.


Top
 Profile  
 
 Post subject: Re: BookScatter
PostPosted: 17 Sep 2012, 11:36 
Offline

Joined: 17 Feb 2010, 16:13
Posts: 252
thanks guys!
looking forward to check your scenes!

Quote:
...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


Top
 Profile  
 
 Post subject: Re: BookScatter
PostPosted: 17 Sep 2012, 14:40 
Offline
User avatar

Joined: 09 Jun 2009, 11:59
Posts: 619
Location: warsaw
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 5720 times ]

_________________
http://vimeo.com/origin/videos
Top
 Profile  
 
 Post subject: Re: BookScatter
PostPosted: 17 Sep 2012, 18:57 
Offline
User avatar

Joined: 17 Nov 2009, 18:46
Posts: 392
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...


Top
 Profile  
 
 Post subject: Re: BookScatter
PostPosted: 17 Sep 2012, 20:45 
Offline
User avatar

Joined: 09 Jun 2009, 11:59
Posts: 619
Location: warsaw
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



Attachments:
bookshelf_bleh.zip [145.99 KiB]
Downloaded 539 times

_________________
http://vimeo.com/origin/videos
Top
 Profile  
 
 Post subject: Re: BookScatter
PostPosted: 17 Sep 2012, 21:24 
Offline
User avatar

Joined: 08 Jun 2009, 21:11
Posts: 1649
Location: Zagreb, Croatia
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.


Top
 Profile  
 
 Post subject: Re: BookScatter
PostPosted: 17 Sep 2012, 21:41 
Offline

Joined: 24 Sep 2010, 18:28
Posts: 697
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

_________________
Constantine
Learnable Programming
The Future of Programming


Top
 Profile  
 
 Post subject: Re: BookScatter
PostPosted: 17 Sep 2012, 22:08 
Offline
User avatar

Joined: 09 Jun 2009, 11:59
Posts: 619
Location: warsaw
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

_________________
http://vimeo.com/origin/videos


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group