SimplyMaya Forums

Welcome to the forum, feel free to ask questions here.

Home / forum / Animation / Mel Scripts & Programming / fit objects to surface
Register FAQ Members List Calendar Mark Forums Read

New Thread
 
Thread Tools
Old 07-09-2009, 07:06 AM   #1
Falott
Registered User
 
Falott's Avatar
 
Join Date: Jan 2005
Location: vienna
Posts: 1,095
Thanks: 3
Thanked 20 Times in 18 Posts
Default 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.
Falott is offline   Reply With Quote
Old 08-09-2009, 05:55 PM   #2
daverave
The thin red line
 
daverave's Avatar
 
Join Date: Aug 2009
Location: England
Posts: 4,472
Thanks: 101
Thanked 952 Times in 879 Posts
Default

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

http://learnfobia.com/category-Maya-...Maya-2257.html
daverave is offline   Reply With Quote
Old 10-09-2009, 05:52 PM   #3
daverave
The thin red line
 
daverave's Avatar
 
Join Date: Aug 2009
Location: England
Posts: 4,472
Thanks: 101
Thanked 952 Times in 879 Posts
Default

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
daverave is offline   Reply With Quote
Old 11-09-2009, 08:30 AM   #4
Falott
Registered User
 
Falott's Avatar
 
Join Date: Jan 2005
Location: vienna
Posts: 1,095
Thanks: 3
Thanked 20 Times in 18 Posts
Default

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.
Falott is offline   Reply With Quote
Old 12-09-2009, 03:17 PM   #5
NextDesign
Technical Director
 
NextDesign's Avatar
 
Join Date: Feb 2004
Posts: 2,988
Thanks: 33
Thanked 532 Times in 471 Posts
Default

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.
NextDesign is offline   Reply With Quote
Old 16-09-2009, 11:48 AM   #6
Falott
Registered User
 
Falott's Avatar
 
Join Date: Jan 2005
Location: vienna
Posts: 1,095
Thanks: 3
Thanked 20 Times in 18 Posts
Default

woohooo!

perfect! thx alot!
__________________
everything starts and ends in the right place at the right time.
Falott is offline   Reply With Quote
Old 20-09-2009, 04:03 AM   #7
NextDesign
Technical Director
 
NextDesign's Avatar
 
Join Date: Feb 2004
Posts: 2,988
Thanks: 33
Thanked 532 Times in 471 Posts
Default

No problem mate. Glad to help!
__________________
Imagination is more important than knowledge.
NextDesign is offline   Reply With Quote
New Thread

« Previous Thread | Next Thread »

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem solving many dynamic objects in a pile? rohiniduggal Dynamics & Special Effects 3 14-01-2011 06:26 PM
Strange Problem - Unable to change attributes for multiple objects anthonysw3 Technical Issues 4 04-12-2010 10:56 PM

1 Month

$34

Month-to-month billing
$34/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
 
 

3 months

$87

Billing every 3 months
$29/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $5 per month or $15 in total compared to monthly billing with this package.

12 months

$288

Billing every 12 months
$24/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $10 per month or $120 in total compared to monthly billing with this package.

Your plan will automatically renew. You can cancel at any time via your PayPal account to avoid being charged again.

You can view the FAQ on our video plans here. You can contact us directly here. By clicking one of the buttons above, you agree to our Terms and Privacy Policy.