Notifications
Clear all

[Closed] Plugins – How to write?

Hi!
I want to write my first plugin. I have knowledge in C++ and Maxscript but not in the 3ds Max SDK. I want to read in all selected objects and their animationpath and also their vertices. In the program I want to calculate new animation path and want to write them back, if they are changed. Further there should be a User Interface. So I want to read in parameters from the User Interface, which I want to use in my program.
I have currently no idea how to start. I looked in the SDK, but it’s dificult to get an overview of the things I need. The first question is, which type of plugin project I should create? Utility? Animation? or something else? And how should I start? Are there any very good examples anywhere?
Thanks a lot,
cgneuling

31 Replies

I’ve done a little with the sdk and the best place to start is with the how to’s and tutorials in the sdk docs.

What I did and what would be by far the easiest would be to write an maxscript extension plugin that adds the functions required to do what you want, then build the ui in maxscript as a scripted plugin or just plain old dialog and pass the objects / inputs to the function and let it do the rest.

It is far easier to build a ui in maxscript and maxscript extensions are the simplest type of plugin to write.

You can even write the whole thing in maxscript first, which may be fast enough for what you want to do, then just replace the maxscript functions with c++ versions as you finish them. Basically make I work then make it faster.

Ok thank you
I have already written the program in maxscript, but it is too slow. So I want to make it as Plugin. Is it also possible to read the animation path, vertices, objects,…with maxscript and to pass them as arrays to the c++ program and than pass the calculated animation path back to maxscript and to set the new animation paths in maxscript?

Yes, you can send data from maxscript into your plugin.
I do this for an exporter I’m making.
the function itself is in c++, I then run the function like this in maxscript:

ExportMyObject objectname “C:\filepath.ext”

then the c++ code takes over and exports the object.

It’s a very good way of doing it, because in c++ you create the functions, and you just use the functions in your maxscript GUI – then you do not have to worry about complex gui coding.

and yes, you can read \ modify all the data you ask for.

I believe you can pass whatever data you want into the function, keep in mind it will probably be easier if you try to follow c++ rules, like not mixing data types in arrays passed to the fn etc…

I would probably pass the object, data, and animation path then do all the work including assigning the new motion in the function.

first of all you have to get why it’s slow.
you can find some samples on this forum where an initial mxs code was improved to work 50 times faster.

The problem is that I want to look if 1000 objects have a collison during 1000 frames, and the script only is fast for about 100 objects for 100 frames.
I don’t know how to start writing the plugin.
I only would need that the Plugin gets from the Script a two-dimensional array with animation paths, and 3 further arrays which have only float values. Then I want to calculate something and then the script should receive the new two-dimensional arrray with animation paths from the plugin. The script will further write it to the objects like it does it right know. So it should be a collision detection, which calculates the new animation paths, the objects should take.
Can someone tell me what I should have to make? Thanks a lot

a c++ function will be able to take multiple arrays even nested arrays as inputs so that is not a problem. If you can use visual studio max has a plugin wizard that can get you started.

The only way for you to do this is to just get starting coding, the sdk is complex and difficult for anyone here to tell you exactly what you need to do. I can tell you that I successfully wrote a maxscript extension in c++ with no experience with the sdk or c++ at the time. It took a lot of trial and error but I got there eventually.

ok. I started with it to write an extended function as plugin. My problem now is. I wanted to create an integer array by int name[i][j], but it doesn’t work. Does anybody now why? i and j are the length of the field which the script will give to the plugin. It should be a two dimensional field, but it also doesn’t work with a one dimensional field, but when I type in int name[5] then it works.

I believe you cannot do that with an int array, I’m still new to c++ as well so I may be wrong. I would recommend using something like std::vector instead, they can be nested.
The code below is completely untested.

std::vector<std::vector<int>> nestedvect; // would create a multi dimensional int array, basically its an array of int arrays.

for(int i = 0 ; i < 10; ++i){
     std::vector<int> intvect; //makes a array of ints that is resizeable, random access etc..
     for(int j = 0; j < 10; ++j){//fill intvect array
          intvect.push_back(i);//add i to 1D array
     }
     
     nestedvect.push_back(intvect);//add int array to multi-dimensional array
}

if you want to use this i believe you have to #include <vector>, you may want to look into something like boost, which has other array options.

Page 1 / 3