Home Technical Talk

Maya - Fill an area with polygons? Bookshelf

polycounter lvl 11
Offline / Send Message
Toast polycounter lvl 11
Hi there,

I'm just wondering how to fill a certain area with existing polygons in Maya?

The main goal is to get like about 10 books and scattering them across different shelves.

Most solutions provided in Maya are not adequate and doing this manually is a pain. I'm a little lost on the MEL part. Does anyone know of a basic example or solution I can work with to get started?

Replies

  • passerby
    Offline / Send Message
    passerby polycounter lvl 12
    instance something across with a random translate value on 1 axis? to do a whole shelf at once.

    would be pretty simple to do this vai python.

    i could make a script that lets you scatter objects within the volume or ontop of a other object which could be your shelf.

    or if you want to work with existing scripts that are already out there, you could use the 'duplicate along path toolbox' script, which lets you scatter things across a curve, which you could make buy selecting a edge loop in your book shelf and running the 'CreateCurveFromPoly' command
  • Toast
    Offline / Send Message
    Toast polycounter lvl 11
    Thanks for the reply :)

    Duplicate along path is fantastic for fences etc, but ultimately I'm not sure it would be the best solution for this type of job. Unfortunately there are a lot of shelves to be filled and I think instead of manually doing it like I always do (I usually have to do this a lot on projects) I'm hoping to learn how automate a few things for short term pain, long term gain!

    http://www.scriptspot.com/3ds-max/scripts/fill-my-bookshelves
    This is the basic idea.

    I'm not aiming for something that complex at the moment. Just something basic as I have no idea on the initial code or any ideas on how to actually "fill the volume or on top of another object which could be your shelf." like you mention. I tried a few things, but can't come up with anything so far.
  • passerby
    Offline / Send Message
    passerby polycounter lvl 12
    ya when i got more tonight i could make up a little code to get you on your way.

    best way would be to grab the bounding box information from the selected polygons, and work with that data. you would also want to but some tests in compare the bounding boxes of the books to so they don't intersect.
  • passerby
    Offline / Send Message
    passerby polycounter lvl 12
    What you would want to do is create a list, with the references of all the books you want to instance across. Than create a "for loop", that runs for the amount of books you want, and on each iteration it chooses a random book from the list, with the start and end values, being the min and max values, on the desired axis of the shelf. Also a minimum step value of the book width too would stop intersecting books.

    Thats just the basics you could also add in random depth values too in a range of the shelfs depth or a manual range, and with a little more math, have some books flat on there side or leaned where there is space for them.

    Thinking i will make this at some point to toss on my portfolio site once done, but thought i should explain the basics since i don't use mel.
  • Toast
    Offline / Send Message
    Toast polycounter lvl 11
    Cool that makes sense. I'll have a tinker around with that.
Sign In or Register to comment.