Posts

Showing posts from May, 2019

A 3D Python Maze for Art of Illusion

Image
I 've always had a fascination with mazes. While messing with the Python plugin for Art of Illusion I decided to write a maze generator in Python. The image to the right is a rendering of the maze that is produced by that code. I did it as a Scripted Object, which was probably not the best idea since it recalculates the maze whenever something changes, but my excuse is that I was testing out some things related to Python scripted objects in Art of Illusion. I'm including the code below, but with the caveat that it has a defect at one of the boundaries that I haven't figured out yet. It doesn't remove a wall for one or two of the cells. Aside from that, it will produce a good 3D maze. import random mazeWidth = 25 mazeLength = 25 wallLength = 1.2 wallHeight = 2.25 wallThickness = 0.05 WALL_UP = 0 WALL_DOWN = 1 WALL_FIXED = 2 class cell():   X = 0   Y = 0   N = WALL_UP   S = WALL_UP   E = WALL_UP   W = WALL_UP   visited = False   def createm...

Advantage of Python over Java

H ere's a question for you: what is the advantage of using Python over Java? Because of the recent publication of the second edition of Extending Art of Illusion I've been spending time working on scripts for Art of Illusion. Straight out of the box, Art of Illusion provides scripting capability for Groovy and BeanShell. This makes sense because Art of Illusion is written in Java and both of these scripting languages are based on Java. But most other graphics programs use some variation on Python as their scripting language. In a post on Python Scripts in Art of Illusion  I wrote about creating a plugin that adds Python to the languages that Art of Illusion supports. I use Python for things I do in my day job mostly because it's available. But with adding it to Art of Illusion I have a direct comparison between Java and Python. It got me thinking. Is there some reason to choose to script in Python rather than using Java, Groovy, or BeanShell? When I setup the interpreter...

Python Scripts in Art of Illusion

I took a break from the cloth simulator to look at adding Python as a scripting language for Art of Illusion. I had some success at pulling in the Jython library and was able to get the following Tool Script to add a Cube to the scene: undo = UndoRecord(window, True) obj = Cube(1.0, 1.0, 1.0) objInfo = ObjectInfo(obj, CoordinateSystem(), "Cube "+str(1)) window.addObject(objInfo, undo) window.updateImage() window.setUndoRecord(undo) In a video I demonstrated that a Groovy script could be used to add a Cube to the scene . The Groovy script was as follows: undo = new UndoRecord(window, true); obj = new Cube(1.0, 1.0, 1.0); objInfo = new ObjectInfo(obj, new CoordinateSystem(), "Cube "+1); window.addObject(objInfo, undo);                       window.updateImage(); window.setUndoRecord(undo); As you can tell, the code is essentially the same except Python doesn't use the new keyword, True is capitalized in Pyt...

Art of Illusion Examples

F or each of the first ten chapters of Extending Art of Illusion I have created a video that demonstrates some aspect of it. One of the things I found when writing the book was that it is difficult to demonstrate animation on the printed page. In chapter 7 I give code for a tracker object that will rotate an object or objects so that the object is always pointing at one of the other scene objects, no matter where it is located in the scene. In the book I tried to show this with a sequence of still images taken from the animation. But in the video I have been able to show the video of a head with eyes that follow an object as it moves around the scene. Not only that, but it is possible to show that these changes are occurring even as the scene is being edited. Below is the list of videos: Chapter 1: Use a Script to Add a Cube to Art of Illusion Chapter 2: Storing and Loading Chapter 3: Position Objects on Floor Chapter 4: Point at Objects Chapter 5: Resting One Object on Anot...