PDA

View Full Version : mesh vetex to loacators


tungaunga
06-20-2007, 08:00 AM
Hello,
I'm looking for a way to create a locator per vertex in a deforming/animated mesh. So each locator have to have the same position animation of it vertex.
I thougth of first creating a particle per vertex and then atach one locator per particle... but I have no clue of how to do this.
Thanks in advance for any suggestion.
T

trancor
06-20-2007, 08:37 AM
Well, I know of a really inefficiant way of doing this. Take the number of verts in the object and run a for loop to generate locators with expressions to getAttr of the translation of the vertex that the locator is connected to. This would use up alot of cpu ussage just to work on the scene if you have a large quantity of verticies on the object.


something along the lines of -
Script editor this-


$MaxVerts=22;
$vertObj="pSphere1";

for($x=0;$x<$MaxVerts;++$x){
spaceLocator -n ("vertLoc"+$x);

$pos=pointPosition ($vertObj+".vtx["+$x+"]");

setAttr ("vertLoc"+$x+".translateX") ($pos[0]);
setAttr ("vertLoc"+$x+".translateY") ($pos[1]);
setAttr ("vertLoc"+$x+".translateZ") ($pos[2]);
}


This will generate your locators


And this will keep them in place -
Expression this -

$MaxVerts=22;
$vertObj="pSphere1";

for($x=0;$x<$MaxVerts;++$x){
$pos=pointPosition ($vertObj+".vtx["+$x+"]");

setAttr ("vertLoc"+$x+".translateX") ($pos[0]);
setAttr ("vertLoc"+$x+".translateY") ($pos[1]);
setAttr ("vertLoc"+$x+".translateZ") ($pos[2]);
}


$MaxVerts=22; - The number of verts in the object
$vertObj="pSphere1"; The name of the object
Locators will be named vertLoc##, you could edit this to form your own naming system I'm sure.

simple, but it works. You'd probably want to add an if (-exist) on the locators and make it all one script. And maybe add something to automatically evaluate how many verts are on the object.

GiantG
06-20-2007, 09:08 AM
I don't know how many vertices you have.
If there aren't too much you can just select manually a vertex and execute "EmitFromObject;"

You can use the the emitter-node instead of a locator. The Particle Node can be deleted.
Note: This workaround won't take the Orientation of your vertex (normal direction) into account.

If you have many vertices loop through them.

Pretty easy....


Cheerz

tungaunga
06-20-2007, 04:06 PM
Thanks a lot guys,
Will see whish solution is better, I found one my self yesterday that may work too.
I converted the mesh into a softbody, creating particles per vertex and made aan instance of a locator for each particle. the I found this plugin:
http://www.nimblestudiosinc.com/joomla/nimble-tools/uninstancer.html
it helps to deinstance the locators preserving the animation.
Thanks again

ewerybody
06-21-2007, 08:55 AM
have a look at rivet.mel:

http://www.highend3d.com/maya/downloads/mel_scripts/animation/Rivet--button--976.html

No Plugin, just ingenious! But you have to select 2 edges at a vertex to make it attach a locator.
Maybe its easy to change this to work with a single vertex as well *shrug*...

CGTalk Moderation
06-21-2007, 08:55 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.