Hey guys another fun and collaborative tool here. I figured why not!
I’ve recently come across some cool book shelve filling tools, but sadly there were all seemingly missing basic features/controls that I’d expect to see. Aside from that, some cost way to much $$$ which we all know, not many of us have lying around waiting to get spent on a little mxs.
Any who lets get to it.
I’ve gone ahead and began to hard code a basic book layout tool.
The script creates a plane as a shelf, then distributes the books according to the settings.
For now I’m just hard-coding everything like I have in the past and then I’ll develop a UI once this gets far enough along. I’d love to take in everyones contributions and ideas to make this tool like many past ones, a solid tool that users can find useful.
Now for the task lists
- Books distribute randomly from the back of the shelf to the front base on desired settings
- Struct implementation to store the node and its dimensions.
Things To Do!
- Add a random rotation with a range control for Y
- Along with the random Y rotation, adjust books to fit snug against one another
- Allow for random number of books to be placed lying flat on the shelf, face down
- Add ‘N’ number of books until the shelf is full
The next thing to tackle is figuring out how to aligns books against one another whom have a varying Y rotation on them.
delete objects clearlistener() shelf = plane length:20 width:60 pos:[0,0,10] wirecolor:[150,215,230] struct bookData (node, thick, depth, height) curBooks = #() disableSceneRedraw() for i = 1 to 20 do ( mybook = box width:(random 0.5 3.0) height:(random 8.0 20.0) length:(random 8.0 15.0) pos:[(-3*i),0,0] wirecolor:[150,230,90] bb = nodeLocalBoundingBox mybook thick = abs (bb.x - bb.x) depth = abs (bb.y - bb.y) height = abs (bb.z - bb.z) append curBooks (bookData node:myBook thick:thick depth:depth height:height) ) enableSceneRedraw() /*Start the calculating*/ bb = nodeLocalBoundingBox shelf shelfWidth = abs (bb.x - bb.x) shelfDepth = abs (bb.y - bb.y) offset = 0.0 for b = 1 to curBooks.count do ( book = curBooks[b] shelfCorner = [bb.x,bb.y,shelf.pos.z] --back left corner of shelf book.node.pos = shelfCorner + [(book.thick/2.0),-(book.depth/2.0),0] --place book in furthest back corner of shelf --now adjust books position so there is no collision with previously placed books book.node.pos.x += offset --now adjust the books position depth wise based on the backFront backFront =( random 0.0 1.0) -- 0.0:back 1.0:front book.node.pos.y -= (backFront*(shelfDepth-book.depth)) offset += book.thick --continue to count offset from previous books )