Simple and Efficient Approximate Convex Decomposition

Please don't post Bullet support questions here, use the above forums instead.
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: Simple and Efficient Approximate Convex Decomposition

Post by Flix »

Thank you for your exhaustive answers :)! .
RBD
Posts: 141
Joined: Tue Sep 16, 2008 11:31 am

Re: Simple and Efficient Approximate Convex Decomposition

Post by RBD »

khaled wrote:it would be great if someone creates some plugins for V-HACD for easy integration with popular editors (i.e., Max, Maya...)
Adding V-HACD to Blender would require a well thought out code patch, at this time core team has a lot on their plate, not to mention unified physics, which, with compound support, would be highly desirable for this.

An alternative, simple way, is to create an add-on that utilizes an external executable.
Since you have already created testVHACD executables for most platforms, I put together a Blender add-on today to allow others to (hopefully) easily use your V-HACD test program directly from within Blender (I copied your descriptions into tooltip help for each param):

Image

Notes:
  • Anyone wanting to try the attached Blender add-on, you also need to download Khaled Mamou's testVHACD executable from his repository.
  • Add-on basically just runs V-HACD on the selected objects, I haven't added any physics processing.
  • Not a lot of error checking, may not work with all situations, may crash. However it should work with most objects, including text, nurbs, curves, metaballs, with all modifiers, etc.
  • Blender's file selector does not work right now, you'll need to enter path names manually, sorry… although thankfully you can save presets. (Alternately, you can manually hard code the default paths in the add-on's .py file)
  • Make sure you have an open console window before starting the process (Window > Toggle System Console) in order to monitor V-HACD's progress.
* Add-on updated... see below...
Last edited by RBD on Tue Dec 16, 2014 4:45 pm, edited 1 time in total.
khaled
Posts: 22
Joined: Mon May 02, 2011 3:26 pm

Re: Simple and Efficient Approximate Convex Decomposition

Post by khaled »

Great job RBD!
Thanks for sharing the add-on. Please, is it possible to release the script under a more permissive license (e.g., BSD license)?
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: Simple and Efficient Approximate Convex Decomposition

Post by Flix »

@RBD: Thanks for posting it :) !
P.S. On Linux 64bit and Blender 2.72b (and maybe on other POSIX systems), I had to change:

Code: Select all

            vhacd_process = Popen(cmd_line, bufsize=-1)
     
to

Code: Select all

            vhacd_process = Popen(cmd_line, bufsize=-1, executable=None,
            stdin=None, stdout=None, stderr=None,
            preexec_fn=None, close_fds=True, shell=True)
     
to make it work. Don't know if this change breaks the Windows version or not.
RBD
Posts: 141
Joined: Tue Sep 16, 2008 11:31 am

Re: Simple and Efficient Approximate Convex Decomposition

Post by RBD »

khaled wrote:is it possible to release the script under a more permissive license (e.g., BSD license)?
Done.
Flix wrote:On Linux 64bit and Blender 2.72b (and maybe on other POSIX systems), I had to change[...]
Thanks for testing and reporting! I've applied the change, thank you.

I've updated the add-on (attached)
Changes:
  • Now creates BGE (Blender Games Engine) compound active rigid body physics structure for each object from the convex hulls.
  • Option to calculate physics mass and change center of mass from object's volume and specified density
  • Option to use / keep mesh generated for V-HACD (e.g. for game engine visuals)
  • Fixed executable and data path browsers (and now has separate Presets from operator)
I think I'm done with this add-on, barring any bugs. If it works, hopefully we'll get more people testing V-HACD v2.

* updated below
Last edited by RBD on Thu Dec 18, 2014 1:50 pm, edited 1 time in total.
khaled
Posts: 22
Joined: Mon May 02, 2011 3:26 pm

Re: Simple and Efficient Approximate Convex Decomposition

Post by khaled »

Thanks RBD for the updated version. I have just submitted your add-on to the V-HACD git repository https://code.google.com/p/v-hacd/source ... t_vhacd.py

Please, let me know if you would like me to add you as a contributor to the V-HACD.
RBD
Posts: 141
Joined: Tue Sep 16, 2008 11:31 am

Re: Simple and Efficient Approximate Convex Decomposition

Post by RBD »

From playing with V-HACD, I have to say that overall it's been working very well. For some objects with diagonal parts it appears to perform better when they are rotated... so I've added a pre-processing option to the plug-in to apply transformations to the generated / exported mesh. (hopefully last update :) )
Image

I've noticed that V-HACD is sensitive to holes in meshes, closed meshes generally need to be water tight, otherwise it will do ACD of the skin (does a good job of that) rather than the shape. I don't think this really is a problem, because in some situations, such as a vase with a small opening, that might be the desired result. We just have to patch holes.

Still not done playing with the many parameters, but here are some thoughts: would be nice if hulls were not larger than the original geometry as this adds an extra gap for physics collision detection. For real-time simulation, we want the least number of convex hulls possible, but also the least number of vertices per convex hull. V-HACD sometimes produces hulls with more vertices than the original part it encompasses... it has the maxNumVerticesPerCH param, which is great, however, it will use that number for small and large convex parts equally. So a small part that could use fewer vertices gets more than needed, and a large part that could use more might not get enough.

Thanks.
Attachments
object_vhacd_py_v0_2.zip
V-HACD v2 add-on for Blender v0.2 with pre-processing option to apply transformations
(4.97 KiB) Downloaded 1009 times
khaled
Posts: 22
Joined: Mon May 02, 2011 3:26 pm

Re: Simple and Efficient Approximate Convex Decomposition

Post by khaled »

@RBD Thanks for the feedback and for the updated script. Please find below some comments:

- In order to reduce execution time, the current version of V-HACD considers only axes-aligned clipping planes. Therefore, to get optimal decomposition results, the user should apply transformations to the input mesh such that the best cutting planes are along the x, y and z directions. I’ll try improve the algorithm by extending the search to include more clipping directions.

- In the example you shared, more precise decompositions could be obtained by increasing the resolution and decreasing the maximum allowed concavity.

- Yes, open meshes are considered as surfaces and not as volumes and the ACD is computed on the surface, which may be the desired behavior for some use-cases (e.g., CAD models). If this later behavior is not desired, it is the responsibility of the user to close the holes before submitting the mesh to V-HACD.

- V-HACD (without capping the number of vertices per convex-hull) generates convex-hulls that are guaranteed to encapsulate the original mesh (i.e., bigger that the original mesh). The distance between the convex-hulls and mesh is controlled by the precision (or resolution) of the voxelization stage. For now, in order to produce more precise results, a higher resolution is needed, which comes at the cost of a higher computation time. I’ll try to fix this in future versions.

- I have added a new parameter that controls the adaptive sampling of the convex-hulls
Image

- I have updated your latest script to include the new parameter in the UI. The latest version is available here https://code.google.com/p/v-hacd/source ... t_vhacd.py
RBD
Posts: 141
Joined: Tue Sep 16, 2008 11:31 am

Re: Simple and Efficient Approximate Convex Decomposition

Post by RBD »

That's excellent, I like it a lot. And, great, simply decreasing the maximum allowed concavity fixed the above example issue.
edit: Yeah... as you get used to the params, the way it works, and a little patience, it's very good stuff. 8) Lots of fun to be had...Image

Thanks.
Link to V-HACD posted on Blender Artists.
khaled
Posts: 22
Joined: Mon May 02, 2011 3:26 pm

Re: Simple and Efficient Approximate Convex Decomposition

Post by khaled »

A new faster version of V-HACD is available. Check the following link for details http://kmamou.blogspot.ca/2015/01/openc ... -hacd.html
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: Simple and Efficient Approximate Convex Decomposition

Post by Flix »

I've updated RBD's Blender addon to support VHACD version 2.2.
Here it is:
object_vhacd.py.zip
v-hacd 2.2 version of the Blender plugin
(5.25 KiB) Downloaded 1115 times
P.S. My knowledge of python is minimal and I tested the plugin on Ubuntu only. Hope it works on other systems as well.
P.S.2 There's a visual artifact in the GUI when loading presets: the GUI does not update properly until the mouse is moved to the modified fields.
I don't know how to fix it and if it affects only Linux systems or not: however I think we can live with it.
RBD
Posts: 141
Joined: Tue Sep 16, 2008 11:31 am

Re: Simple and Efficient Approximate Convex Decomposition

Post by RBD »

khaled, showing off use of V-HACD in an animation:

YouTube video: Homemade Hydraulic Cylinders, Excavator Arms, Hexapod - Bullet Blender

I ran V-HACD on Blender extruded curve objects (before bevelling) with a collision margin set to the bevel depth, then bevelled the curve objects after, so collision margins are factored into the visual display meshes.
Post Reply