Friday, May 30, 2008

Big Buck Bunny!


Big Buck Bunny premiered on the web today AND I got the DVD today as well! The 10-minute short created with Blender turned out great! I'm looking forward to exploring the DVD, which not only has the movie but also has the files used to create the movie. Even more amazing when you think that it was done with open source software that is only 9mb to download. Also cool was seeing my name in the HUGE list of credits for folks who purchased the movie before they started making it, I think our confidence in Blender and Ton's group paid off :)

Wednesday, May 21, 2008

MacBook Pro


Just a quick note... I just got a new 17" MacBook Pro, so of course one of the first things I did was download Blender. WOW! Blender launches in a heartbeat on it, I was stunned at how fast it opened. The graphics re-draw while working in it is fast, too. For fun I downloaded the Blender Render Benchmark and did a test. It rendering in about 1 minute 10 seconds. That's pretty fast for a dual-core. On my quad-core Vista machine it rendered in 51 seconds. The MacBook Pro feels more like a desktop when it comes to power. Make me wonder about the eight-core Mac Pro towers... :)

Sunday, April 13, 2008

Reflection in ActionScript 3

I'm not a big fan of the old eval() function in earlier versions of ActionScript. As of ActionScript 3, it is no longer supported. For the most part, that is a very good thing. My buddy, Jason, is migrating from AS2 to AS3 and he found himself looking for the eval() function. He came to me and asked me about it, I replied "you mean the evil() function?".

The problem with eval() is that you were executing code that was being created at runtime, meaning there's no chance of the complier helping you catch errors. He showed me the code he was working on and --usually-- you can solve the lack of eval() through a better architecture. As I looked at his program, I realized he had a pretty elegant solution. Re-architecting would take a good deal of time and not necessarily yield as elegant result. Java has quite a few classes for dealing with reflection, so I figured (given how similar AS3 is to Java) there must be some similar classes. As it turns out, the pickings are pretty minimal... but there were enough to come up with a nice, dynamic solution to his problem.

In the flash.utils package, there are a number of public functions. The one we were looking for (before we even knew it) was getDefinitionByName(). This function takes a string that is the name of a class, an returns the class object for it. With the class object, you can then create an instance of the class. Here's a simple example you could run in the Flash IDE:
var myClass:Object = getDefinitionByName("Symbol1");
addChild( new myClass() );
It assumes you have a Symbol named "Symbol1" that is exported for ActionScript. If you are doing this in Flex or inside an external class file, remember to import the flash.utils package. The danger of runtime errors still exists, but it is more limited now in that you can create classes and not just execute and arbitrary chunk code on the fly like you could with eval().

Audio Display List?

The Flash 9 player using ActionScript 3 (for Flex or Flash), has an internal structure called a display list. Items in the display list, will be shown, items not in it will not be shown. So if you load an external SWF, it will not be visible until you add it to the display list. Once it is in the display list, it'll receive events (like MouseEvents, KeyboardEvents, ENTER_FRAME, and so on). That's nice, because you can load it and display it at will.

But what about a SWF that also contains audio? As it turns out, there is no audio equivalent to the display list. Once a SWF containing audio is loaded, it will begin to play and you'll hear the audio, whether or not you're displaying it. To stop the audio, listen for Event.INIT on the loaderInfo in the Loader object. Event.INIT fires when the first frame is loaded so you can call stop() it to prevent the playback head from moving forward in the timeline.

Something I love about open source

I was just re-reading through the Blender release logs and for version 2.45 (the current one):

The 2.45 is a bugfix release, to stabilize the 2.4x series.
No new feature have been added, but serious effort has been put in tracking bugs and fixing them. Some performance issues have also been addressed.

Years ago, when I was used Director daily, I don't know how many times I read posts crying for a release that just addressed bugs. Skip new features. I guess the business folks at Macromedia (now Adobe) couldn't makes sense of the importance of stability to users. Blender is one of the most stable pieces of software I use. When you're trying to get a job done, stability is paramount.

Tuesday, April 01, 2008

Blender Basics 2


Blender Basics 2 was released today by CartoonSmart (no foolin')! BB2 is 4 hours (twice as long as Blender Basics!). In BB2 you learn how to:
  • Use procedural textures on materials
  • Place an image using UV maps
  • Use the Screw tool to create corkscrew extrusions (like springs)
  • Use multiple textures
  • Extrude along 2d and 3d bezier paths
  • Lathe using the Spin tool
  • Create a basic rig (a skeleton)
  • Skin a rig 3 different ways
  • Use boolean modifiers on objects
  • Use layers
  • Use groups
  • Append from other files
  • Create new screens
  • and more tips on working with materials, meshes, objects, lights, and rendering
BB2 assumes you are familiar with navigating around the 3d workspace. So it is appropriate for users who have seen Blender Basics!, either the full version or the free version (which is the first 40-minutes of Blender Basics!), or if you are already familiar with some of the basics this video should be fine for you. It is still going through the many features of Blender through the creation of the scene pictured above.

The video high quality, it is compressed using the H.264 codec at Best quality, Millions, 1024x768. The audio is AAC 44.100kHz. The only place to get it (legally) is CartoonSmart.com. Just as we did for Blender Basics!, CartoonSmart.com and I will be donating a percentage of the profits to the Blender Foundation to support further development of Blender.

Thursday, March 27, 2008

DNA script


After writing the script I posted in the previous blog, it occurred to me that I should be able to create all the nucleotides with a script, not just color them. So I poked around in the Blender Python APIs and came up with the following:
import random, math
import Blender
from Blender import Object, Scene, Material

scn = Scene.GetCurrent()
colors1 = [Material.Get("G_Nucleotide"), Material.Get("C_Nucleotide")]
colors2 = [Material.Get("A_Nucleotide"), Material.Get("T_Nucleotide")]
groups = [colors1, colors2]
for i in range(0, 90):
rot = i*.125*math.pi
o = scn.objects.new(Object.Get("nucleotide").getData())
o.colbits = 1
o.modifiers = Object.Get("nucleotide").modifiers
o2 = scn.objects.new(Object.Get("nucleotide").getData())
o2.colbits = 1
o2.modifiers = Object.Get("nucleotide").modifiers
groupNum = random.choice([0,1])
firstColorNum = random.choice([0,1])
if firstColorNum == 0:
secondColorNum = 1
else:
secondColorNum = 0
firstColor = groups[groupNum][firstColorNum]
secondColor = groups[groupNum][secondColorNum]
o.LocZ = i*.2
o.RotZ = rot
o.setMaterials([firstColor])
o2.LocZ = i*.2
o2.RotZ = rot + math.pi
o2.setMaterials([secondColor])
scn.update()

Python is one of the more unique languages I've worked with. After my initial shock at being forced to indent, I've now found I like it. I'd do it anyway, but now it is sure to be done and done consistently. It makes for reading my code and others' code much nicer. As I get used to syntax and familiar with the Python and Blender APIs, I find I am looking for more excuses to use it. :)

For one of my future courses, I'd like to teach how to program... using Python as the language and Blender as the environment. This would be for folks who want to learn to program, but haven't a clue were to start. It's nice to be able to solve some of the more tedious tasks (like creating and coloring nucleotides) programmatically.

Another course I'd like to teach is one on the Blender Game Engine. With the logic bricks, you can do a lot of programming logic without getting into the syntax issues you get in a language. A cool thing in Blender is you can extend the logic bricks by calling Python scripts.

About the image: The image above has over 1200 objects, but only one mesh. Each object reference the same mesh (making changes easy). I applied the Material color to the object (not the mesh, which is the default). By using a script, I was able to apply the colors randomly but following the rules that the A color had to go with T (or T with A) and the G color had to go with C (or C with G). Since all the nucleotides of the same color share the same Material, color and texture changes are also easy.