Tuesday, November 20, 2007

Blender


No, that's not a self-portrait! It's been quite a while since I last played around with Blender. Last weekend I decided to take a break from Flash/Flex/ActionScript and Painter activities and give Blender another try. Blender is a very powerful, stable, fast, open source 3d program. I'd found an excellent tutorial model on character animation and couldn't resist. I didn't get through the entire tutorial yet (I got through modeling and rigging), I hope to get through the rest of the tutorial soon. It's very exciting to start with just a plane (four vertices!) and build a model that you can then move around and render. It's like making your own toys :)

One of the problems with only occasionally working with a tool as complicated as Blender is that I end up having to re-learn a bunch of the basics. Blender's got a great user interface, it is very flexible and does a great job of allowing you to maximize your workspace. It's just that it is not similar to any other software I've ever used. Ironically, after using Blender a bit, I found myself wanting to use the "G" key to move stuff in Illustrator (which I've used since 1987). That says something about Blender's design.

I first got into 3d with Swivel 3d in 1989 (I think), it was the same year the IIci came out. Once I'd got all that 68K power I thought I'd try 3d. I didn't care much for Swivel because I was doing stuff for print. I did end up using it once to set up a scene in perspective which I then drew over it in Illustrator. I probably could have drawn the image quicker from scratch but it was a good experience. In 1992 I jumped into Strata 3d. After attending a 5-day training course put on by the Strata folks in beautiful St. George, Utah, I got hooked on Strata's outstanding rendering quality. The modeler wasn't great, so I dabbled in some other 3d programs as well at the time (like Infini-D), but I always came back to Strata for rendering. Strata in those days was as stable and dependable as Photoshop.

One of the other 3d packages I tried was Playmation. It had a very nice spline-based 3d, modeler. In fact the whole program, which was geared towards character animation, seemed revolutionary. Unfortunately, it was the most unstable program I ever owned. Over the years, I continued to upgrade it as it became Animation:Master. Never having much luck with the stability. When I crossed from the Mac world to the Windows world, I tried it a couple more times, hoping that it would be more stable on the platform it was developed on.

(And I'll just avoid mentioning Raydream's addDepth and Adobe Dimensions. While they're 3d and I enjoyed them both, they're not really in the same vein as they were vector tools and far simpler than your standard 3d program)

At work I got the opportunity to try Cinema 4d. It has a very approachable interface, is pretty stable, but a little on the slow side. The friendliness of its UI was reminiscent of Strata.

Eventually, I came across Blender. I downloaded it, installed it, opened it, then closed it and uninstalled. The user interface was just too strange! Some time later, I gave it another shot. This time going through a tutorial. I was hooked. The strange interface worked amazingly well. Blender was also very stable (like Strata), had a great modeler (different than A:M but just as powerful) and it was fast even on older machines. I worked with it in my spare time for a while but with mergers, job changes, etc. I'd let it fall lower in the priority cue until it fell right off.

I'm really glad to be back working with it (and 3d) again. I can't figure out what the appeal of 3d is for me, why it keeps pulling me back. Part of it is what I mentioned earlier, being able to create something from scratch and move it around (or move around it). Strata's animation ability is one of the things that led me to interactive multimedia... I didn't want to just animate, I wanted to interact with the animations, which in turn led me further down the programming path. Now I think I'm coming full circle. One of the cool things modern 3d tools have is scripting languages. Blender has Python (which I've never tried), so that might be on the agenda down the line.

Tuesday, October 09, 2007

Interacting with Flex in Flash

I was trying to bring a Flex 2 SWF into Flash CS3 and interact with it. I was able to load the Flex swf without a problem but when I tried to access a public property or function I'd get the following error:

ReferenceError: Error #1069: Property hello not found on
_Main_mx_managers_SystemManager and there is no default value.

So I did the natural thing and Googled it before spending time figuring it out :)
Unfortunately, my search came up empty :(

Looking into the docs class mx.managers.SystemManager gave me the clue I needed. To get at the actual application, I needed to get to the first child of the loaded content. The compiler was unhappy with calling getChildAt() on the content object, so I cast it into an Object along the lines:

var flexApp:Object = (loader.content as Object).getChildAt(0);
trace(flexApp.hello);

That did the trick!

Wednesday, September 19, 2007

Populating a TextField before it exists

A friend of mine posted the following Flash problem the other day:

I tell a movie clip to go to a frame. I want to put something in text fields on that frame, or set some property of some movie clip on that frame. But if I gotoAndStop, and then on the next line of AS try to set something, I get an error. I need to wait for the frame to start, or the objects on the frame don't exist yet. So I have to put a function call on the frame to call a second function to do the setting later on.

The is quite messy. Surely there has to be a better way.

I came up with the following solution, which I think is fairly elegant. You make a symbol with a TextField in it. Set the symbol to extend from a class which has a public static variable you can set, then when the symbol is instantiated later it uses that class variable in the constructor. This works because the class is loaded when you reference it, it doesn't matter that an instance of the class does not yet exist.

The static variable could be an object so you can better identify what value should be populated. You can get the instance name in the constructor to determine which property of the object in the class variable to use. Here's an example of the class:
package {
import flash.display.MovieClip;
import flash.text.TextField;
public class JRNTextField extends MovieClip{
// should use a getter/setter
public static var mytext:Object = new Object();
public function JRNTextField(){
textInSym.text = JRNTextField.mytext[this.name];
}
}
}

In frame 1:
JRNTextField.mytext.asdf = "hello";
JRNTextField.mytext.qwer = "goodbye";
In frame 2:
stop();

Frame 2 has two instances in the timeline of a symbol that extends the JRNTextField class.

The symbol contains a dynamic TextField that is named "textInSym".

The instances on frame 2 are named "asdf" and "qwer". As hoped, they get
populated with "hello" and "goodbye", respectively.

Sunday, September 16, 2007

Painter Perseverance

After getting the previous post (rant) off my chest, I've been thinking about and working with Painter. As I stated in an earlier post, Painter is not Photoshop. Photoshop is a great program. It is very stable and works well for editing photos or even creating art from scratch. While Corel is trying to dip into the huge photography market with Painter's Auto-painting features, it is still a tool for creating from scratch. One of the things that has drawn me back to Painter (pun intended), is that they have with few deviations, maintained their focus on natural media. The Painter toolbox is ideal for illustrators, far more so than Photoshop's.

Today I was working on an illustration where I did some initial work in Illustrator, brought that into Photoshop, then brought it into Painter. I found myself popping back and forth between Photoshop and Painter for different techniques. Painter does not have Photoshop's very handy Layer Effects and when it comes to manipulating pixels, Photoshop is hard to beat. But when I needed to create parts from scratch and work without thinking too technically about layers, channels, masks, etc I find Painter more enjoyable. I love being able to turn the image in Painter to get a better angle to make brush strokes or creating just the right brush to work with for the moment. Little things like having my own easily created brushes palette, or having the brush tracker, make a big difference in the creative workflow, and the color palette (which I think has been around since the beginning) is brilliant.


Corel needs to make Painter more stable. Users shouldn't have to worry about the silent, unexpected crashes, the corruption of workspaces, or the annoyance of redraw errors. It's just too good a program to let such solvable problems tarnish it.

Wednesday, September 12, 2007

Corel Painter Instability

This is only the second time I'm using this blog to rant, normally I like to stay positive. I sent a letter to Corel this morning, Painter's instability really made me mad. It crashes significantly more than my any of the other professional caliber programs I use. My eight-year-old has been interested in Painter and started learning it. He started a painting and spent twenty minutes on it and Painter crashed. He had not saved it and was crushed. I'm a veteran of over 20 years of computer use and I still find it unsettling to lose work. Nothing like your child being affected to really get you going.

This reminds me of some years ago when my daughter was interested in learning 3d. I had been giving Animation:Master another shot, but it was still unstable, it crashed frequently. The company said that there were a variety of things that could cause problems because of all the programs that run in the background in Windows. I liked it enough that I even asked the company what kind of system do they use, I was willing to buy a computer and configure it just for its use. They never gave me a configuration. I remember one person from the company even telling me how Photoshop crashes more than Animation:Master. Photoshop crashing is so rare and in the 17 years I've used it, I've never had it corrupt a file. In the meantime, my daughter decided she didn't like crashing and losing stuff so often and moved on to other programs like Photoshop and Premiere. My boy may end up going the Photoshop route as well.

Now Painter does not crash as much as Animation:Master but it is still a significant problem for a program that is supposed to be a program for professionals. I know my workflow is not pressing CTRL-S every minute or two, especially when I'm drawing or painting (time seems to fly when you're in the "right brain" mode). I'd really like Corel to spend some effort in this direction, I've been able to use Painter more and more lately and I'd like to continue to.

So I get a response from Corel saying I need to call in to deal with this problem. After 20 minutes on hold, someone picks up. The support person has me check my driver version of my tablet (it's up to date). He tells me I should reset Painter completely via %APPDATA%, saying the work environment can become corrupt. I tell him that I have experienced this problem before customizing Painter. I'm told that Painter is stable and that it must be something on my system causing the problem (same thing the Animation:Master folks used to say). I mention to him that I use Painter at work with an entirely different configuration and experience the same behavior. He tells me it must be something I'm doing. I mention that in a Painter class I took other folks were familiar with Painter suddenly quitting. He says there is nothing he can do. I suggest he communicate to engineering or whomever that QA needs to be bumped up a notch.

I use Photoshop, Illustrator, Flash, Dreamweaver, Visual Studio, and more and I don't have these sudden crashes no error message(though Adobe's CS3 Suite was hellish to install, the programs run smoothly). Having programming in a variety of languages on multiple platforms over the years, I have an idea of the complexity involved in a product like Painter, but I also know other companies are able to make solid products. Even something as simple as throwing up a dialog box with some info when there is a fatal error might be helpful.

I like Painter, I'd hate to give up on it. Especially after all the time and money I've spent getting into it over the last year! It is a great tool when it is working. The crashing is the worst, but I've noticed other problems. If I use following commands:
Zoom In
Zoom Out
Zoom To Fit

I get horrible redraw problems. Very frustrating. But.. If I use the Magnifier tool, I don't get the redraw errors. I don't think these problems are new, as I was watching a video where the user was working with a version of Painter from 3 years ago and it show some redrawing problems.

Workspaces are another problem. Apparently they get corrupted often enough that they are the first things tech support wants to whack when you contact them with any problem. While this is an irriation, the crashing is the worst. No... I think writing and then calling about their crashing product only to have them blame your system(s) is the worst. Corel's net promoter score dropped quite a few points in my book today.

Saturday, September 08, 2007

Code-behind and States in Flex 2

I've always liked the .NET way of developing web pages, where you have your code separated from your layout. Someone just referred me to this post on using Flex in a .NET code-behind style (thanks Steve!). It's very similar to .NET, you just extend the Application class and use it in your MXML file.

It is very cool but there's a minor error where the package name is left off the screenshot (though the instructions are correct). One of the comments on the post noted that in order to use states with this approach you needed to make a small change from "mx.states" to "app.states" where "app" is the namespace of your application.

I thought I'd post a version of this approach that included the states issue. I hilited where you need to change "mx" to "app" and where you need to add "app" as the namespace. The shots below are of code done in FlashDevelop 3 (beta 3).


UPDATE: September 14, 2007 1:07 PM I've had additional troubles with using the code-behind and states. I'm afraid for now it's best to hold off on using the approach.


Sunday, September 02, 2007

Drawing Limit on Sprites

I learning something new this weekend. When drawing on a Sprite in ActionScript 3, I assumed you were just drawing on it like you would a graphics port and the result was just changed pixels in memory. Ah, but after some pain (and a SWF freezing at exactly the same time each time I ran it) I found it keeps track of the number of things you've drawn on it.

How many items does it keep track of? The nice computer-y number 65536, aka 2^16 or 0x00FFFF. Before you reach that limit you should call the clear() function of the graphics object of your sprite, ie:
   mySprite.graphics.clear();
But now with that past, I've got the beginnings of a nice 2d terrain generator.