Nobien A nerd blog about nerdy things by … nerdy guys?

13Nov/080

Papervision3D Beta 1 Cube.destroy() bug?

So I've been working with Papervision3D quite a bit lately for a project at work. I've been creating controllable boxes and using Cube's with a depth of zero as the panels for the box. I used this technique in order to apply different materials to opposite sides of each box panel.

Eventually it came time to destroy these boxes, so I did a big sweep of all the PV3D objects and made sure to remove them from the scenes and destroy their materials. Eventually I got down to the box panels (cubes) and at first glance noticed the Cube.destroy() method. So taking for granted that this is still a beta version of PV3D, I assumed all would be hunky doory and the materials would be destroyed.

Now it was time to check the memory usage. Immediately I noticed the memory usage just kept going up each time I created a scene and/or boxes. For the longest time I had no idea what was causing this. After hours of banging my head, I ended up adding a method to PV3D's MaterialManager class to loop through the materials dictionary and see if anything was still left in it after my own destroy methods. Come to find out, the materials for all the box panels (cubes) we still lingering behind, even after calling the cube's destroy method. So I had to change my own destroy() method to remove the materials manually by doing the following:

_cube.materials.getMaterialByName( "all" ).destroy();
_cube.materials.getMaterialByName( "front" ).destroy();
_cube.materials.getMaterialByName( "back" ).destroy();
_cube.materials.getMaterialByName( "right" ).destroy();
_cube.materials.getMaterialByName( "left" ).destroy();
_cube.materials.getMaterialByName( "top" ).destroy();
_cube.materials.getMaterialByName( "bottom" ).destroy();

At any rate, I hope this helps anyone out there that may be experiencing any memory problems and using cubes!

15Oct/083

Mipmapping in Flash Player, Unbeknownst Until Now!

The other day I was messing around with Papervision3D for a prototype at work. I'm no Papervision expert by any means so I was doing all sorts of Google searches to try and find any information relating to what I was trying to achieve. At one point I stumbled across Tinic Uro's post on how the Flash Player uses mipmaps. I didn't even read the whole post and at the time I thought to myself, "What the hell is this? I don't need to know this." I honestly thought it was just some nerding out about how to use mipmapping to achieve a nicely scaled down image.

That was until today! My co-worker, Faisal, at ROKKAN was having a hard time getting a relatively large PNG image to scale down smoothly with nice aliasing. The image was of a product that has a relatively fine texture on it in certain areas. So when the image was scaled down relatively small, the bitmap data was appearing to be very sharpened. No big deal really, in my opinion, but the client was going crazy about how the image should scale smoothly like it does in Photoshop.

At this point I remembered Tinic's blog post, so I quickly went back to it and read the entire thing. To my surprise there was no programming needed! All we had to do was change the dimensions of the PNG to friendly mipmapping dimensions. That meant either n^2 or n^8. If you do this the Flash Player will automatically use mipmapping when scaling it down. Totally bad ass. Here's an example that shows the difference in aliasing of two images that only differ in dimension by 1 pixel.

26Aug/086

Looking for Fuel Industries old Library Items Flash Extension

So...way back in the day, Julian Dolce from Fuel Industries used to have this totally awesome extension for the Flash IDE that would let you change the properties more than one library item at a time. So today, I'm on my new computer at work, and realize I could really, really use this extension.  I search the Google for it over and over with all sorts of search terms, but can't find it anywhere. Weird.

So I realized I have it on my old computer. I go to my old computer and try to open a path to a shared folder on my new computer so I can copy it over. And as the computer is trying to access my new computer, KABOOOM! Blue Screen of Death. Except this particular BSOD said something about a memory dump at the end. Awesome. So I restart...nothing. Power down and power up again. Nothing. Awesome! I'm guessing the MB is dead as the BIOS doesn't even load up. Wonderful.

I don't have the time to pull out the hard drive and try and salvage the files, so my question to any and all of you out there that use the Flash IDE, do you have this extension? I'm desperate! I'm not sure what I will do in return if you have this extension, but I'll try and think of something.

Filed under: Flash 6 Comments
17Jul/081

“I’m not a kid anymore, Dad!” said ActionScript 3.

Boy has there been a lot of buzz around Colin Moock's article lately. Its quite interesting to read the very outspoken comments as well. Everyone seems to have a strong opinion about it and now its time for me to chime in.

14May/087

Duplicate a DisplayObject as a BitMap

In working on a project, I created a simple utility class that has this public static method. This basically takes a DisplayObject, copies it, and adds it to a new Sprite which is then returned to the caller. Simple enough. I'm sure this can be refined or done a different way, so have at it.

public static function duplicateImageAsSprite( original:DisplayObject ):Sprite
{
    var bitmapData:BitmapData = new BitmapData( original.width , original.height ,
        true , 0x000000 );
    bitmapData.draw( original as IBitmapDrawable );

    var bitmap:Bitmap = new Bitmap( bitmapData );

    var returnSprite:Sprite = new Sprite();
    returnSprite.addChild( bitmap as DisplayObject );

    return returnSprite;
}
12May/087

More Than Two Simultaneous Key Presses and KeyboardEvent.KEY_DOWN Woes

I'm rather annoyed right now. For whatever reason, I didn't think that determining if the user has 3 keys pressed at once would be so difficult. Attempt to press all the arrow keys that correspond to the arrows being displayed...

Sometimes it works, sometimes it doesn't and I can't understand why or find a pattern to the malfunction. But basically whats happening is at some point the KEY_DOWN event just isn't dispatched for a particular arrow key once two of the other arrow keys have been pressed. Does anyone have any freaking idea why this is happening?