Posts Tagged ‘sprite’

Z-Sorted Sprites in 3d

Monday, October 6th, 2008

Sprite3D Z-Sorting

On a recent job, I had a need for a 3d scene with lots of sprites. I decided to use Papervision3d but couldn't find an easy way of having an interactive sprite in the scene. There are classes for billboard planes, but that seemed like too much calculation. This means you can do anything you would normally do with a sprite, but in 2.5d.

The solution turned out to be pretty simple. Just use the screen.x, y and z variables in the DisplayObject3D class to align some sprites to their projected 3d locations, and then z-sort the whole lot of them.

  • Works with Papervision3D 2.0 (GreatWhite)
  • The z-sorting for each SpriteGroup3D completely circumvents papervision's internal sorting so this won't work in conjunction with other types of scene objects (like polygons)

Hopefully someone will find them useful =) View the rest of this post for the code.