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 06-10-2013, 03:41 PM   #1
JokerMartini
Expert
 
JokerMartini's Avatar
portfolio
John Martini
CG Supervisor, 3D, Maxscript, VFX
Ingenuity Engine
Los Angeles, USA
 
Join Date: Mar 2009
Posts: 1,330
Send a message via AIM to JokerMartini
plexus WIP

This is the start of a plexus maxscript. It's a work in progress, rather rough draft right now. Check it out. Open to suggestions and feature requests.

Code:
clearlistener() delete objects numCtrls = 20 numBranches = 5 ctrls = for c = 1 to numCtrls collect (point cross:true box:false pos:[random -50 50, random -50 50, random 0 50] wirecolor:yellow size:5) plexusData = #() fn getRandomNode nodes:#() excluded:#() = ( useableNodes = for node in nodes where (findItem excluded node) == 0 collect node count = random 1 useableNodes.count return useableNodes[count] ) sp = splineshape pos:[0,0,0] wirecolor:blue name:(uniqueName "Plexus_") for ctrl in ctrls do ( for b = 1 to numBranches do ( addNewSpline sp spIndex = numSplines sp addKnot sp spIndex #corner #line ctrl.pos randomCtrl = getRandomNode nodes:ctrls excluded:#(ctrl) addKnot sp spIndex #corner #line randomCtrl.pos append plexusData #(ctrl,randomCtrl) ) ) updateShape sp fn wireKnotToCtrl knot: index: target: = ( if knot != unsupplied do ( scriptCtrl = point3_script () sp[4][8][knot].controller = scriptCtrl scriptCtrl.addTarget "control" plexusData[index][target][3] scriptCtrl.setExpression "control.pos" scriptCtrl.getTarget "control" --Get the Target Track as SubAnim value scriptCtrl.getTarget "control" asObject:true --Get as Object ) ) /* Controlable Knots */ animateVertex sp #all knotA = 2; knotB = 5 for k = 1 to plexusData.count do ( /* Knot A */ wireKnotToCtrl knot:knotA index:k target:1 wireKnotToCtrl knot:knotB index:k target:2 /* Increment for each knot controller */ knotA += 6; knotB += 6 ) /* Animation Ctrls */ sp.showFrozenInGray = false sp.isfrozen = true animationRange = interval 0f 144f for t = animationrange.start to animationrange.end by 12 do ( with animate on at time t ( for ctrl in ctrls do ctrl.pos = [random -50 50, random -50 50, random 0 50] ) )
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
Old 06-10-2013, 06:06 PM   #2
grabjacket
Connecting 3D
 
grabjacket's Avatar
portfolio
Klaas Nienhuis
Schiedam, Netherlands
 
Join Date: Sep 2007
Posts: 248
Nice,
you could make the movement more organic by adding a slight wobble to the keyframes
Code:
for t = animationrange.start to animationrange.end by 12 do ( for ctrl in ctrls do ( local theTime = random (t-6) (t+6) with animate on at time theTime (ctrl.pos = [random -50 50, random -50 50, random 0 50]) ) )
 
Old 06-11-2013, 12:30 AM   #3
JokerMartini
Expert
 
JokerMartini's Avatar
portfolio
John Martini
CG Supervisor, 3D, Maxscript, VFX
Ingenuity Engine
Los Angeles, USA
 
Join Date: Mar 2009
Posts: 1,330
Send a message via AIM to JokerMartini
grabjacket

Nice touch grabjacket
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
Old 06-11-2013, 06:52 AM   #4
caustikstudio
Veteran
portfolio
Amine Alameddine
Creative & Managing Director
caustik
Beirut, LB
 
Join Date: Aug 2010
Posts: 34
Hey John,
Why don't you use splineIKs instead?
Have you tested it with more control objects? i tried with 200 and the viewport performance drops dramatically.

Suggestions:
1. Loading a point cloud to create the plexus object
2. Selecting a geometry as point cloud with ability to skip nth Vertex
3. setting number of knots per branch (currently it's 2 - one at the start, one at the end)
3. Adding Position Noise controllers on the control objects
4. A master controller for the points to set the weight of the noise controller
5. adding a flex modifier on the plexus object.
__________________
--
Caustik | Detail in Motion
MotionGraphics and Visual FX studio
work: www.caustik.tv
blog: www.caustik.tv/blog
 
Old 06-11-2013, 07:42 AM   #5
gazybara
Architect
 
gazybara's Avatar
portfolio
Branko Živković
Freelancer
Niš, Serbia
 
Join Date: Apr 2011
Posts: 1,103
Quote:
Originally Posted by caustikstudio
Hey John,
Why don't you use splineIKs instead?
Have you tested it with more control objects? i tried with 200 and the viewport performance drops dramatically.

Suggestions:
1. Loading a point cloud to create the plexus object
2. Selecting a geometry as point cloud with ability to skip nth Vertex
3. setting number of knots per branch (currently it's 2 - one at the start, one at the end)
3. Adding Position Noise controllers on the control objects
4. A master controller for the points to set the weight of the noise controller
5. adding a flex modifier on the plexus object.

This solution will eat a lot of memory. Probably bast way for plexus-like behavior is usage of cebas TP. Also Flex modifier have huge problem when "start animaton range" have value below 0.
__________________
Looking in the right side. [bgaTools]
 
Old 06-11-2013, 01:34 PM   #6
JokerMartini
Expert
 
JokerMartini's Avatar
portfolio
John Martini
CG Supervisor, 3D, Maxscript, VFX
Ingenuity Engine
Los Angeles, USA
 
Join Date: Mar 2009
Posts: 1,330
Send a message via AIM to JokerMartini
Yeah I had created one once already using the spline ik. It still had performance issues and I wanted to see how this method proved to work. Seemingly there is no real solid method out there, especially if there are a lot of objects.
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
Old 06-11-2013, 05:17 PM   #7
em3
day dreamer
 
em3's Avatar
portfolio
Dave Tyner
3D Artist
Polyform Media
Denver, United%2BStates
 
Join Date: Jan 2004
Posts: 984
Send a message via Yahoo to em3
Thanks dude, this is awesome! It definitely gets the idea machine working. I will try to post some follow up ideas.
__________________
www.davetyner.com
 
Old 01-28-2014, 03:09 PM   #8
postite
New Member
portfolio
Vanaubel Stephane
Liege, Belgium
 
Join Date: Jun 2009
Posts: 1
Hi, very nice script! Like the others...

It would be cool if the position of the points could "loop" at the and of time.

Hope to see updates
 
Old 02-03-2014, 11:04 AM   #9
JHN
maxscript/c# lover
 
JHN's Avatar
Johan Boekhoven
Technical Artist
Freelance TD/Generalist
Netherlands
 
Join Date: Apr 2002
Posts: 1,720
You don't need script controllers, you can just instance the position controllers of the nulls to the knots. As long as plexus is on world zero and nulls also have world as parent. I'll bet performance will be better as well.

-Johan
__________________
Online: LinkedIn
 
Old 02-05-2014, 04:43 PM   #10
Tamyl
PRO
 
Tamyl's Avatar
portfolio
Kamil
Lodz, Poland
 
Join Date: Sep 2010
Posts: 98
I thought about giving thickness to those splines basing on distance between control points, but it needs each line to be separate shape. This is my approach, but it's pretty slow unfortunately.



Code:
numK = 20 for i = 1 to numK do geosphere pos:[random -20.0 20.0, random -20.0 20.0, random -20.0 20.0] wirecolor:(Color (random 155 155) (random 0 55) (random 0 55)) segs:5 radius:(random 1.0 2.0) name:("ctrl"+i as string) ctrls = for i = 1 to numK collect (getnodebyname ("ctrl"+i as string)) for t = animationrange.start+30 to animationrange.end+30 by 30 do ( for ctrl in ctrls do ( local theTime = random (t-10) (t+10) with animate on at time theTime (ctrl.pos = [random -50 50, random -50 50, random 0 50]) ) ) distmax = 35.0 thickmax = 2.5 for i = 1 to ctrls.count do ( for j = i+1 to ctrls.count do ( sp = splineShape pos:[0,0,0] render_renderable:true render_displayRenderMesh:true wirecolor:(Color (random 150 255) (random 150 255) (random 150 255)) scr = float_script() str = stringstream "" format ("dist = distance $"+ctrls[i].name+".pos $"+ctrls[j].name+".pos") to:str format ("\nif dist>"+distmax as string+" then return 0.0 else return ((1.0-(dist/"+distmax as string+"))*"+thickmax as string+")") to:str str = str as string scr.setExpression str sp.render_thickness.controller = scr addNewSpline sp addKnot sp 1 #corner #line ctrls[i].pos addKnot sp 1 #corner #line ctrls[j].pos updateShape sp animateVertex sp #all local lista = #() append lista (ctrls[i]) append lista (ctrls[j]) spm = Spline_IK_Control linkTypes:2 helper_list:lista addModifier sp spm ep = Edit_Poly() addModifier sp ep ) )
 
Old 02-05-2014, 04:43 PM   #11
CGTalk Moderation
Expert
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,478
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



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 11:16 PM.


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