Monday, April 29, 2019

Why Buy My Book About Scripts and Plugins

After the second edition of Extending Art of Illusion went to press my attention turned once again to the question of getting it into the hands of readers. Outside of people called Mom, people don't generally buy books just because someone wrote it. I've purchased a few books just because I knew the author, but I don't buy second and third books "just because."  Those of us who love books need a reason to buy a book. No, that's not right. We want a reason to buy a book. We are begging authors and publishers to give us a reason to buy a book. We want to see a book and say, "If I buy this book this is the knowledge I will gain or the story I will enjoy." We are cheering for authors to provide us with a good book. It's in that context that I make the case for people to buy the latest edition of Extending Art of Illusion.

I stopped to ask myself why anyone would need this book. It may seem like it is a little late to be asking that question. Over 550 pages into a project and with it already coming off the press is not the time to be asking whether it is worth doing, but there's something a little odd about doing a second edition of a book. On this edition, my focus was on very specific aspects of the book rather than on the project as a whole. It was important to me to update the reference material at the back of the book so that it matches the current release of Art of Illusion. But a higher priority than that was the cloth simulator described in Chapter 10. I have this urge to tell people that they should buy the book because it provides a cloth simulation for Art of Illusion, but the cloth simulator isn't a reason to buy the book. It is a reason to install the plugin, but it isn't a reason to buy the book.

As I thought about that, I wrote a script that I thought might help illustrate why people need to write scripts and plugins for Art of Illusion. If they understand that then it is easier to make the case for them to buy a book that will teach them how to write scripts and plugins.

The picture to the right is one of the images that I rendered from that script. The script adds 1000 sphere to the scene. Adding 1000 of anything isn't something you would want to do by hand. Not only would it take a long time but it would be impossible to get all of the positions exactly right. With a script you can let the computer do the heavy lifting. The Groovy script I used is below:

size = 0.2;
spacing = 4.0*size;
t = script.getTime();
maxTime = 10.0;
timeDelta = maxTime/1000.0;
myTime = 0.0;

for(k = 0; k < 10; k++){
 for(j = 0; j < 10; j++){
   for(i = 0; i < 10; i++){
   myTime += timeDelta;
   if(myTime > t) break;
   S = new Sphere(size, size, size);
   infoS = new ObjectInfo(S, new CoordinateSystem(), "Sphere");
   infoS.coords.setOrigin(new Vec3(spacing*(i-5.5), spacing*(j-5.5), spacing*(k-5.5)));
  if(myTime > t) break;
 if(myTime > t) break;

You would place this script in a Scripted Object. The code is simple enough, but how would you change it if you wanted to use Cubes instead of Spheres? What if you wanted the objects spinning or pointing at the same thing? Imagine a thousand eyeballs looking at the camera. How would you achieve that? This is why people who want to do scripting in Art of Illusion need the book. Not only does it provide plenty of examples but it provides a listing of every public interface in Art of Illusion. My name is on the cover and yet I found myself reaching for this book as I was writing this script. I could have looked up the functions I needed in the source code, but I found it preferable to have the book open in front of me. And it is my belief that if you are writing scripts for Art of Illusion you will find that beneficial as well.

You can buy the paperback from
There is also a hardback version available.