View Full Version : SDK - writing a maxscript extension
10 October 2009, 08:44 AM
I have a script that is running pretty slow, and integral to the script is a function that checks distance from a point to a line segment. Now I was thinking, that if this function could be made into a maxscript command through the SDK, the speed increase should be massive. And also, writing a maxscript command should be a doddle compared to writing, say, a modifier? Especially when it's just a simple trigonometric command?
But I can't find where to start! Inside the Plugin Wizard there are no categories for maxscript, and I can't seem to find any samples inside the SDK either. I only see a curve controller, an activex thingy, a dotNet thing, and then a folder of general functions (which I assume is used by the other ones?).
Could anyone point me in the right direction, so that I at least can have the framework for such a plugin up and running?
10 October 2009, 08:57 AM
There is basic maxscript extensions samples in maxsdk\howto\maxscript. Also see maxsdk documentation about maxscript sdk, MAXScriptSDK.chm in maxsdk\help ("How to Write a Basic MAXScript Plugin" tutorial is very handy to start).
10 October 2009, 09:24 AM
Thanks, I somehow missed the separate maxscript help file. After a brief look, it seems like they don't use the wizard at all, and there's probably a reason for that :)
10 October 2009, 08:51 AM
Are you using MaxScripts Native 'Distance' command? Just curious....
10 October 2009, 09:28 AM
Yes I am, for portions of the code. It's inside the function that calculates the length from a point to a line segment. That part is the main loop, and the one I'm looking at accelerating.
What the script is doing, is figuring out what bone is closest to each polygon in a mesh. It then splits up the mesh in parts and parents each part to the bone, effectively doing a very crude low-res mesh for my animation rig (it's great with fingers!).
I made it a lot faster yesterday, actually. I accelerated the script by precalculating some of the bone information, and then storing them in arrays. The main loop is now a bare-bones distance search. I have successfully split up a 90.000 polygon object in two minutes, and I probably won't be going beyond half a million polygons. I probably don't need to go to the SDK, but I'm thinking it might be a good exercise!
10 October 2009, 02:46 PM
no Pun intended for the "Bare-Bones Distance" search I'm sure! :-)
If you have them arrayed, you may want to implement a half step search algorithm, where you check the first point vs the "middle" data point. If a the middle is a shorter distance, you check end point vs "middle" point else First vs Middle... repeat until the resolution of your array is expired.
10 October 2009, 02:46 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.