Simply Maya User Community

Simply Maya User Community (https://simplymaya.com/forum/index.php)
-   Programming (https://simplymaya.com/forum/forumdisplay.php?f=32)
-   -   fit objects to surface (https://simplymaya.com/forum/showthread.php?t=33025)

Falott 07-09-2009 07:06 AM

fit objects to surface
 
ok, this question must have been risen here allready I just cant find anything - so here´s my question.


I have a wide area of soil with grass on it. the plants which are needed to be placed on the ground are lowPoly-alphaTexture models simply planes most of the time. the ground surface is uneven. so -

the tricky part - I´ve allready placed the plants from the top view. what I now need is to make them stick/fit to the surface by somehow constraining them with a script (only Y-axis matters in this case.) paying attention to the Y-axis and only and the normalDirection of the soily groundSurface.

I got about 10,000 (simple planes only) objects, so I realy need a script or something.

I allready googled alot, but theres nothing I found what is actually working how it´s supposed to do. maybe I just used wrong keywords...

reminder: I dont want to fit the objects to vertices - they just need to be moved down until touching the surfaceGeometry.

I hope anyone can help me. Script, Url, ideas - it doesn´t matter - any input is greatly appreciated!

daverave 08-09-2009 05:55 PM

Couldnt find any thing Mel script but found this tutorial.
hope this helps

http://learnfobia.com/category-Maya-...Maya-2257.html

daverave 10-09-2009 05:52 PM

I am new to mel script just finding my feet but I think what you are looking for is geometryConstraint I have tried to wright script but only works for the first one selected

string $mySelection[] = `ls -sl`;
delete `geometryConstraint -weight 1 $mySelection[0] $mySelection[1]`;

This is suppost to work that the first one selected is the ground then select all others that you want to move to it then it deletes the constraint

hope you can make some thing of this.......dave

Falott 11-09-2009 08:30 AM

some lines of code thrown together

string $stem = "dupe_";
string $suffix= "_GEO";
string $dupeSel[] = `ls ($stem + "*" + $suffix)`;



// this is from an older script of mine. the default objects
// to randomly duplicate them are named like
// dupe_1_GEO, dupe_2_GEO, ... / I painted particles to a
// live surface and instanced geometry to them



int $count = `particle -q -count particleShape1`;
for ($i =0 ; $i < $count; $i++)
{
$pPos = `getParticleAttr -at position particleShape1.pt[$i]`;
$object = `duplicate $dupeSel`;
move $pPos[0] $pPos[1] $pPos[2] $object;
}

NextDesign 12-09-2009 03:17 PM

Set the pivot points to the bottom of the cards. Select the ground and the cards (or other way around, can't remember) and use Animation>Constraints>Geometry Constraint.

You'll need to do this for every card, so run this script instead. You'll need to run the constraint first on one card to get your settings. Select all your cards first.

$sel = `ls -sl`;

for ($obj in $sel)
{
// geometry constraint settings go here
}

Hopefully you can get it to work. If not, I'll post up the full code tonight.

Falott 16-09-2009 11:48 AM

woohooo!

perfect! thx alot!

NextDesign 20-09-2009 04:03 AM

No problem mate. Glad to help! :)


All times are GMT. The time now is 07:45 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Simply Maya 2018