Tony Polinelli
Tarwin Stroh-Spijer

contact [at]

6/25 Easey Street
Collingwood, 3066
Vic, Australia

+61 3 8060 5321

Archive for November, 2008

Friday, November 28th, 2008

Apparantly drawing each frame of an animation to a single bitmap and then selecting a region to display is better for memory and speed than keeping each frame in its own bitmapData object.

The issue i’ve had is that for larger animations a sprite sheet of 2880×2880 is a little restrictive. To counter this ive modified bit101′s BigAssCanvas to allow a copyPixels of a rect, in order to get our frame data from a BIG Sprite sheet. This makes the test a little unfair, but small spritesheets are not an option for us.

The results are as follows:

uncached:  ~16fps
cached as frames: ~120fps
cached on spritesheet: ~70fps

memory usage:

frames: 249 856
spritesheet: 270 336

so caching each frame seems the way to go for us. There doesnt seem to be any advantage in the spritesheet. It might run faster if it was a single bitmapData object and direct coptyPixels – but who’s to say :P

Friday, November 28th, 2008

We needed to copy out the BitmapData from a BigAssCanvas so i added this to bit101s class. It doesnt really work like BitmapData's copyPixels - as that copys pixel INTO the bitmap object, so i've named it copyPixelsOut and it returns a new bitmapData of the rect.

You will notice the red lines at 2880 when you move the viewable region over them the data you are given is atually sourced from 2 bitmapData objects (inside the BigAssBitmap).

PS: Thanks to Jonno from Something Splendid for helping me when my maths brain had disappeared.

Its basically :

  1. public function copyPixelsOut(rect:Rectangle, transparent:Boolean=true, fillColor:uint=0xff000000 ):BitmapData
  2. {
  3. var bitmapData:BitmapData = new BitmapData(rect.width, rect.height, transparent, fillColor);
  5. for(var i:int = 0; i <_bitmaps.length; i++)
  6. {
  7. var bmp:Bitmap = _bitmaps[i] as Bitmap;
  8. var temp:Rectangle = rect.clone();
  9. temp.x -= bmp.x;
  10. temp.y -= bmp.y;
  12. if(temp.intersects(new Rectangle(0,0,2880,2880))){
  13. bitmapData.copyPixels(bmp.bitmapData, temp, new Point());
  14. }
  15. }
  17. return bitmapData;
  18. }

Wednesday, November 26th, 2008

Almost a year ago I was reading about how normal mapping works (on Wikipedia I think) and it struck me that this would be a great way to define a useful height map for games, maybe a mini golf game as an example.

My understanding is that normal maps work by encoding the X and Y angle difference from a flat surface (generally a polygon). That is the difference between a larger polygon from a low count polygon model, and the multiple polygons that made up a high count polygon model. This is normally saved as red and green channels. The blue channel (from what I could work out) was used in some way for height (or Z).

Our Friends:

Powered by haXe / poko cms | Copyright 2008-09 TouchMyPixel