Maya 2020 fundamentals - modelling the real world
Get halfway through a model and find it's an unworkable mess? Can't add edge loops where you need them? Can't subdivide a mesh properly? If any of this sounds familiar check this course out.
# 1 07-09-2009 , 07:06 AM
Falott's Avatar
Registered User
Join Date: Jan 2005
Location: vienna
Posts: 1,095

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!


everything starts and ends in the right place at the right time.
# 2 08-09-2009 , 05:55 PM
daverave's Avatar
The thin red line
Join Date: Aug 2009
Location: England
Posts: 4,472

# 3 10-09-2009 , 05:52 PM
daverave's Avatar
The thin red line
Join Date: Aug 2009
Location: England
Posts: 4,472
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

# 4 11-09-2009 , 08:30 AM
Falott's Avatar
Registered User
Join Date: Jan 2005
Location: vienna
Posts: 1,095
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;
}


everything starts and ends in the right place at the right time.
# 5 12-09-2009 , 03:17 PM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
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.


Imagination is more important than knowledge.

Last edited by NextDesign; 12-09-2009 at 03:24 PM.
# 6 16-09-2009 , 11:48 AM
Falott's Avatar
Registered User
Join Date: Jan 2005
Location: vienna
Posts: 1,095
woohooo!

perfect! thx alot!


everything starts and ends in the right place at the right time.
# 7 20-09-2009 , 04:03 AM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
No problem mate. Glad to help! user added image


Imagination is more important than knowledge.
Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads