PDA

View Full Version : Improved path deform (with not so improved garbage collection)


Haamu
07-03-2007, 09:19 AM
Simple question really. This is a (relatively) quickie plugin I made to aid in some extremely tedious task. It is meant to deform mesh with 2 splineshapes instead of just 1, the second determing banking direction.

It works well enough. It's slow and all, but that's not the problem. It gives me errors after I close or open the file with this modifier and sometimes with heavy meshes too. Says something along the lines "unknown error encountered while performing garbage collection of maxscript. If you get this multiple times, consider restarting max"

The help says it might have a lot to do with local variables, but I don't think I can do this without them. Or would declaring those in parameter block help? I'm in bit of a hurry now so can't spend too much time testing aimlessly

plugin simpleMod pdeforms
name:"pathdeform bank"
classID:#(0x2728c9fd, 0x2b2d8d86)
(
local dh=[0,0,0]
local dm=matrix3 0 --matrix data

parameters main rollout:params
(
amount type:#integer ui:amtSpin default:0
tar type:#node
tar2 type:#node
b type:#floattab tabsizevariable:true
)

rollout params "path parameters"
(
spinner amtSpin "Amount: " type:#integer range:[0,1000,0]
button node "path"
button node2 "path2"
on node pressed do(
tar=pickobject()
if tar!=undefined then(
node.text=tar.name
ze=(getknotpoint tar 1 1)-center
)
)
on node2 pressed do(
tar2=pickobject()
if tar2!=undefined then(
node2.text=tar2.name
--ze=(getknotpoint tar 1 1)-center
)
)
)
on map i p do
(
try(
if i==1 then(
b=getseglengths tar 1
dh.x=b[b.count]
dh.z=1/(dh.x)
)
p.x+=amount
case of(
(p.x>dh.x):(dm.row4=getknotpoint tar 1 (numknots tar 1)
dm.row1=getoutvec tar 1 1--lengthtangent tar 1 1--dh.z
)
(p.x<0):(dm.row4=getknotpoint tar 1 1
dm.row1=getinvec tar 1 1
)
default:(dm.row4=(lengthinterp tar 1 (p.x*dh.z))
dm.row1=lengthtangent tar 1 (p.x*dh.z)
)
)
p.x=0
--if i==2 then $D1.pos=(lengthinterp tar 1 (100*dh.z))
dm.row3=normalize( (pathinterp tar2 1 (nearestpathparam tar2 dm.row4)) - dm.row4 )

dm.row3=normalize( dm.row3-((dot dm.row3 dm.row1)*dm.row1) )
dm.row2=cross dm.row3 dm.row1
p*dm
--(inverse(this.gizmo.transform))
)catch(p)
)



)

davestewart
07-03-2007, 11:00 AM
Hi Antton,
I ran the script, applied the modifier, selected the first spline... and max (9) froze. (It's still frozen now). I assume that's NOT supposed to happen?

Haamu
07-03-2007, 01:08 PM
Ow, not quite. Pardon me for not mentioning it's only tested in 8. There's not any error handling so make sure you select a splineshape. It should srew up your model temporarily, but not really hang max. Meh, need to fix that too.

Try deleting this line from the script.
ze=(getknotpoint tar 1 1)-center
No idea if that matters though

davestewart
07-03-2007, 03:29 PM
Wow, some pretty cool stuff there! I was working on something similar a while back but it was a pre-twist modifier using an f-curve to achieve the same thing - but this is very cool.

http://forums.cgsociety.org/showthread.php?f=98&t=411029&highlight=twist+profile

I do remember I had memory issues as well (see the title of the post!) and I had to drop matrices in favour of doing it all with trig - and it sped up IMMENSLY. But I was only working in one axis, and I'm not that up on dot product stuff etc, so I can't really add any input there.

I did have locals in the "on map i p do" though, and things were fine.

Sorry I can't be of any more help. If you want the code, let me know and I'll re-post.

Cheers,
Dave

davestewart
07-03-2007, 03:35 PM
Oh my lord - just seen you're running a try/catch on every iteration! No wonder it's so slow.
You really need to get a better check in there than that...

Haamu
07-03-2007, 05:57 PM
Oh heh, that thing is still there. I thought only getting into the catch part is the only slow thing in that, though. There should be no errors in that part any more so it's not very useful there either way.

I'm gonna try that trigonometric approach though. Seems pretty decent idea. Thank you for input.

CGTalk Moderation
07-03-2007, 05:57 PM
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.