View Full Version : How to avoid collision / intrusion of objects???

05 May 2005, 08:30 AM
Hi guys!
I'm working on a realtime-"application" in Maya where I need to avoid the intrusion of other objects - for example: a cylinder shouldn't be able to get inside a cube, but always stay outside. Does anyone know how to achieve this??

I've tried some solutions, here's the last one:
Locator with geometry constraint on the cube an parent constraint on the cylinder. Cylinder is point constrained to its parent (i.e. a group node) and to the locator on the geometry.

If the distance between the group and the cube-locator is small enough or the group is inside the cube (I'm using the "pointIsInsideMesh"-script from highend3d here), the point constraint weight changes from the group to the locator and vice versa.

This is quite complicated and the results aren't that satisfying - does anyone have other ideas?

05 May 2005, 10:08 AM
1. Take a look at the closestPointOnMesh plugin

2. You could use rigid bodies and/or fields (radial).

Explain us a bit more about to setup for more detailed help.

05 May 2005, 11:26 AM
Thanks for the answer.

The closestpointonMesh-plugin is already in use (it's used to check whether the cylinder-group is inside the cube or not)!
I've also used it to determine the position of the locator on the cube - but a geometry+parent constraint do the same and seem to need less calculation (or isn't that true?)

So, here's the whole story:
I'm driving a character with magnetic MoCap sensors and this character shouldn't run into any obstacles. A dynamic simulation won't be too cool because everything has to be in realtime.

So the idea is for example: the character's hand is checked if it is inside an object. If it is, it should only get to the boundary of that object.

I've also tried using translate minimum/maximum but it seems to be even more complicated esp. when the objects in the scene should be moveable.

Hope, that's enough info. Can anyone help please? Thanks!

05 May 2005, 01:07 AM
Sounds like what you're trying to implement is basically a simple collision detection system. So I'd recommend you take a look at the collision detection libraries/code/books that are available out there, e.g.

Real-time collision detection, Christer Ericson
Game physics, David Eberly (and some of his other books and his website, which used to be at ( but has since moved somewhere else... unfortunately can't locate it.)

Eventually, we can hope that hardware-accelerated physics engines will get integrated in Maya. Look at ( for a sign of what's to come. Their engine (Novodex) is orders of magnitude faster than Maya's old rigid solver, and they are developing the world's first physics chip. (Disclaimer: they are a client of mine so of course I'm somewhat biased. ;-)

Good luck,

Christian Laforte
Maya API consultant

05 May 2005, 08:15 AM
Yeah, thanks for the links. But actually I need to do it all in Maya as simple as possible. Just because the MoCap sensors are hard to implement in other programs and we already have the plugin for Maya.

So I'm really looking for a way to do the collision stuff with "simple" MEL.

CGTalk Moderation
05 May 2005, 08:15 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.