Thursday, September 6, 2018

Still Making Plugins and Scripts Work with Art of Illusion

Update: I'm happy to say that after writing this post I made the decision to revise the book and it is now available for purchase. In the process, I developed a cloth simulator plugin for Art of Illusion. I include it as part of the book as an example of a use of Art of Illusion Distortions.

When a reader of Extending Art of Illusion contacted me about the possibility of updating the Art of Illusion scripts to Groovy, I became concerned. Firstly, because he wasn’t able to download the source code from the location specified in the book. Broken links on a webpage are one thing, but broken links in a book can be costly. Secondly, because I haven’t attempted to keep up with all of the changes to Art of Illusion that have taken place since the publication date of the book. There hasn’t been enough demand for the book to justify a revised edition. To address my concerns, I went back through the examples I included in the book—rebuilding with latest Java compiler and using Art of Illusion 3.03. With joy I’m able to say that they all still work. In spite of the book being seven years old, it remains useful anyone who is looking for instruction on how to create plugins for Art of Illusion.
I did find a couple of things that I would add to the book if I were to revise it. The first is that to use the examples you need to include the Bouy.jar in the list of linked libraries. I’m not sure if this is a result of a change or of an oversight on my part. The second is that I would include scripts written in Groovy in the book. I’ve somewhat corrected this by adding Groovy scripts to the .zip file that contains the examples. At this point, Art of Illusion still support BeanShell even as it is moving toward Groovy, so it is really up to the person writing the script to decide which one they want to use. There are a lot more similarities between BeanShell and Groovy than there are differences, so the only change I made to the axes script was to change the file extension from .bsh to .groovy
There were more differences with the Room script. At line 18 I removed the “private” specifier for the class. At line 105 I deleted “LayoutWindow layout”. At line 106 I removed the “final String” specifier because Groovy couldn’t see windowTitle as a global variable. And at line 116 I deleted “int roomCount = 0”. At 128 I rewrote the declaration as:
    float[] roomSmoothness;
    roomSmoothness = [0.0f, 0.0f, 0.0f, 0.0f];
Overall, it wasn’t difficult to make the changes, but it did take some effort and a little research to figure out the differences between the two scripting languages.