|
|
|
Tell us what you think of the site.
|
Autodesk Media & Entertainment User Community
|
Autodesk® 3ds Max®
|
|
Autodesk® Maya®
|
|
Autodesk® Softimage®
|
|
Autodesk® MotionBuilder®
|
|
Autodesk® Mudbox™
|
|
Autodesk® ImageModeler™
|
|
Autodesk® Sketchbook® Pro
|
|
Autodesk® Smoke on Mac®
|
| Filling a solid with randomly generated smaller solids
|
|
|
It’s not so easy to see in the attached image, but I’m trying to fill a polygonal solid, in this case a large number “2”, with randomly positioned and rotated smaller polygonal solids, in this case small number ‘2’s. I’ve achieved what you see in the picture by emitting particles with a random rotation from the inside surface of the big number Two and making them collide with the big number two, so that they are emitted inside the big solid and then stay there. Then, I instance a small number two to those particles, and then finally I have written a MEL script that turns those instances into actual geometry objects.
Now, here’s the problem: In the final configuration the small number twos all need to touch each other because I want to export them as a model (sort of a skeleton) to be printed on a 3D printer and therefore I must have them all combined into one solid watertight object. I have written a MEL script that moves them closer and closer to their neighbors, but the problem with this is that the script does not respect the boundaries of the large two and so when the little twos move closer together they start wandering outside the larger form and lose the larger shape that I am trying to get them to hold. And I don’t want to reposition them one-by-one by hand because it is hard to see what I am doing and I will lose the random effect that I was looking for in the first place.
So, any suggestions how to accomplish this final result that I am looking for?
Specifically if anyone could tell me how to test in Maya 1) If a particular point is inside a solid? or 2) if a particular curve crosses a particular solid’s boundary faces? I could work that into my existing MEL script and probably get the result I want. Or if you just have a completely new idea how to accomplish this that would be fine too.
One more thing: I’ve already had the suggestion to scale all the little twos up in all directions so that they eventually touch each other. This is not a good solution for me because I have chosen their size carefully so that the final form will have a lot of open space between the twos even though they all touch each other. Scaling them up results in a much denser-looking arrangement, which I don’t want.
Thanks for reading such a long post and for any ideas you can give me!
| Attachment
|
|
|
|
|
|
Hey Iceberg,
This looks like a graphics programming question than a modeling problem ;P. So I’m not aware of any command in Maya that can check if a point is inside a solid or not. My suggestions are:
1.) As a shot in the dark, try performing the boolean intersect function for each mini ‘2’ before you put in the big ‘2’. If you see anything left over, the you know that the mini ‘2’ was outside the area of the big ‘2’. However, I can never rely on those boolean functions since they’ve always been kinda hairy…
2.) Since you’re already working in the script level, try putting each of the mini ‘2’s into a bounding box. Store the verts that make up the bounding box for each little ‘2’. Now for each triangle of the big ‘2’, compare the 3 verts of the triangle with all of the verts of the bounding box. If all of the verts of the bounding box are less than the verts of the triangle (calculate the direction of the bbox vert from the triangle vert) then you don’t have an intersection. If you notice one or more of the box verts greater than the triangle verts (so some box verts are below the triangle and some are above) then you have an intersection. So I’m thinking of something like this:
for(all triangles of the big 2)
for(all bounding boxes of the mini 2)
current_triangle_verts[3];
current_bounding_box_verts[8];
bool intersect = false;
bool below = false;
bool above = false;
for(all the verts of the current triangle)
for(all the verts of the current box)
find the direction of the box vert with the triangle vert as the origin
if(the current box vert is less than the triangle vert)
below = true;
else if(the current box vert is greater than the triangle vert)
above = true;
if(above == true && below == true)
intersect = true
return intersect
So I know it’s kinda brute force, but it’s a very rough start on a different approach you can use if you have access to all these variables. But if you get the direction I’m going, you’ll see that you’ll need to compare some value of the mini ‘2’ with the big ‘2’ for intersections…
Good luck! Sounds like a cool project.
|
|
|
|
Yeah it’s definitely a graphics programming question! :) At first I thought maybe Maya would have operations that would somehow do all this for me, but still it’s nice to let Maya worry about the whole software infrastructure of storing, representing, and displaying these objects, etc. so that in my scripting I only have to focus on solving the “real problem”. PS Like any programmer I am looking to generalize this approach in the end, ie write a single script that will do this whole process, including using the particles to pack the objects, on ANY polygonal solid. Then I can just model objects, press a button, and have them built out of themselves.
So, thanks for your response and I think your ideas are good ones to try.
The boolean operations always seemed like they were sort of what I wanted but they seem to only work predictably in very simple situations, like two objects that you just created by hand. And I’d really rather have methods that would tell me the result of the boolean operations without having to actually perform them, because if one of my resulting little Twos ends up outside, I don’t just want to throw it away but rather move it somewhere else. But I’ll take another look at these operations with your method in mind.
As for your second idea, that looks nice too, and I’ll give it a shot. I’ll let you know about the results. Thanks again!
Anyone else with suggestions feel free to keep them coming. Especially if they involve built-in Maya or MEL functions that can do these things without me having to write the math myself (not opposed to doing it, just don’t want to reinvent the wheel).
|
|
|
|
research the docs (maybe they are bonus tools? devkit?....I just don’t remember.) for closestPointOnMesh.....there is also one for nurbs Curves....these should help you test potential points.....perhaps you could use the python api to implement a mel command using the available geo. mesh iterators in the api to gain access to vertex info for speed up....do you know python?...it really is a must now for maya.......it will give you the ability to write mel commands that use the api methods and load them in as a plugin.....it is distinct from a mel procedure that you write and save in a scripts folder, though you use them the same......the python would get pre-compiled? into bytecode, so there would be some small savings in execution time.
edit:: ncloth if you have the unlimited version....
|
|
|
|
I don’t know Python but I have a lot of experience with C/C++. So in order to decide what’s the best use of my time, can you answer the following: can you do more with Python than you can with MEL? When I looked through the documentation the first time I got the impression that MEL and Python had all the same functions so you just had to choose what syntax/language you wanted to use, but it sounds like I got that wrong. Are you also saying that through Python you can access all of the functionality of the C/C++ API? If either of the above are true then I will definitely take your advice and check out Python - it’s something I’ve been wanting to learn anyway. I thought MEL would be the quick/dirty/easy way to get this thing done, but if the Python API has additional functionality that will make this easier I’ll go for it.
|
|
|
|
yes you can access the c++ api through python as either a plugin or a user script....
But don’t hang up your c++ hat, there are lots of places where that is going to be faster and you will have to use it...shaders, textures...any thing that is computationally intensive.....c++ is the way....and the current version of mel is not going to go away anytime soon....maya’s interface is built outta mel....so much of maya is mel scripts......that would be a huge task...I would think......?
|
|
|
|
Yeah from what I can see they’d need to do a pretty huge overhaul on the user interface and some of the functionality if they were going to ditch MEL, so you’re right that won’t be going away. But I’m guessing that the C++ API, whether used from C++ or Python, is going to make a lot of sense to me.
So, looks like I’ve got the direction I need to go in. I’ll dive in to the bonus tools and the developer kit and see what I can find. I’ll come back here and post my solution and a snapshot if all goes smoothly. Otherwise I’ll put more questions here :)
Thanks for all the tips so far.
|
|
|
|
|
|