CGTalk > Software > Autodesk 3ds max > 3dsMax SDK and MaxScript
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 10-09-2012, 05:25 AM   #1
VVaari
PRO
 
VVaari's Avatar
portfolio
D.H.
Finland
 
Join Date: Nov 2008
Posts: 61
PFlow scatter

I need to scatter xref objects to a surface so I thought of creating my own scatter tool using maxscript with pflow. Well creating actual scatter flow with maxscript is easy, but a problem comes when I need to actually place to objects in scene. I can't use shape instance and mesher compound because it kills all xref related stuff.

First thing that came to my mind is just loop thru all particle positions and place objects that way. Problem is that I need to align my objects to that surface and so far I havent figured out how to get normal from each particle. I could use intersectray to find face normal, but how do I know which direction ray needs to be shot from each particle position?
 
Old 10-09-2012, 06:14 AM   #2
VVaari
PRO
 
VVaari's Avatar
portfolio
D.H.
Finland
 
Join Date: Nov 2008
Posts: 61
Oh damn I thought I could just use particlePos() to get positions but it doesnt work with PFlow. Looks like I need to do some more reading about PFlow and maxscript integration.
 
Old 10-09-2012, 07:13 AM   #3
VVaari
PRO
 
VVaari's Avatar
portfolio
D.H.
Finland
 
Join Date: Nov 2008
Posts: 61
Well got it working. Although I need to do completeRedraw() before looping thru particles, otherwise it doesn't find them. Any idea why is that?

Code:
( delete objects local sp = Sphere radius:50 segments:32 local pf=pf_source logosize:10 name:"pf" Quantity_Viewport:100 particleFlow.beginEdit() local rendParticles=renderParticles() pf.appendAction(rendParticles) local pCount = 40 local evt = event() local birthAction = birth amount:pCount emit_start:0 emit_stop:0 local positionObjectAction = position_object emitter_Objects:#(sp) location:3 Random_Seed:(random 0 10000) local speedBySurfaceAction = speed_by_surface surface_objects:#(sp) direction_type:0 local rotationAction = rotation direction:3 euler_y:90 local speedAction = speed speed:0 particleFlow.endEdit() evt.appendAction birthAction evt.appendAction positionObjectAction evt.appendAction speedBySurfaceAction evt.appendAction rotationAction evt.appendAction speedAction pf.appendInitialActionList evt completeRedraw() for i=1 to pf.numParticles() do ( local pos = pf.getParticlePosition i local tm = pf.getParticleTM i local t = teapot pos:pos radius:5 t.transform = tm ) completeRedraw() )


Now I just gotta do some collision tests and maybe even create some slope test so user can decide if particles are placed on steep surfaces.
 
Old 10-09-2012, 07:13 AM   #4
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,481
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 08:50 AM.


Powered by vBulletin
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.