Self-installable plugins otherwise known as callback heaven
February 27th, 2005 by Patrick Boucher - Viewed 2914 times - Popularity: 5%When the self-installable plugin reared it’’s head in XSI it blew me away! Gone were the days of all those plugin registration antics and on top of that the the SDK had a whole new branch that dealt with the dynamic creation of PPGs thus destroying the usefulness of SPDL, which in my book was a good thing - one less thing to learn.
If you aren”t allready using self-installables, you should. Hopefully this little case study of my publicly available PB_Render can give you a little hand in getting started. First of all we”ll look at what makes a self-installable plugin tick, then we”ll take a look at our practical example. We”ll then finish off with a little look at PPG control and access.
The allmighty callback
I tought myself how to program and when I first started, I worked alone. Most of my code was fairly linear, using functions mostly to get my code more readable, not necessarilly harnessing their full power, not the least of which is code reuse. My skills were first confronted within a small team of web developers that were working on a search engine. The project lead was having us write Perl modules. His code would load our modules and, according to whatever conditions, he would invoke our functions whose names had a specific pattern to adhere to. What I would later figure out was that he had implemented a form of callback and that callbacks were definitely your friend, especially in event-driven forms of programming.
The way I see it, a callback system is a really cool way of being lazy. By implementing such a system you”re asking something else (a user, another coder or another one of your own modules) to do the dirty work. You”re saying: I”ll manage the dispatching, the higher level logic, but when it actually comes down to doing something usefull I”ll tell you to doIt() and I”ll get out of the way. In the case of XSI it puts the power in the user’’s hands, yours and mine.
XSI’’s SDK is teeming with callbacks and the self-installable plugin is one of the areas where they are abundant. To use a callback you just need to know it’’s definition and you”re set. This means knowing what name the callback should have - if the callback is registered automatically by the system or simply expected, which is the case with XSI’’s self-installables - and what argument you should expect when your callback is invoked.
When writing a self-installable plugin the first callback you will need to write is the XSILoadPlugin callback that is expected in any file you will drop into your Application\Plugins folder. This is the callback that tells XSI which commands, properties, menus, etc. the rest of your file will be defining. Once you have defined these items another series of callbacks will then take over and each one of your custom commands, properties, menus, etc. will be initialized and be available for use inside XSI. If you”ve defined a property page, a third level of callbacks will be invoked by the PPG’’s UI as in the logic blocks of good old SPDL files.




