I am just diving into the Stage3D APIs for Flash Player 11. I am trying to figure out a simple way to display isometric 2D content that gets blitted from a sprite sheet onto a 3D cube. The idea being that then the isometric content can be split into the appropriate quads of the cube and handed over to the GPU.

I found this post 2D sprites in 3D space? but I don't understand if the billboard method would split the content properly to ensure depth sorting of the quads.

Are there algorithms for basically projecting the image into the respective quads?

Addition Info (added 2012.03.06 @ 1124 GMT -6)

If you were to overlay a 3D box projected isometrically on top of a 2D isometric sprite (say a crate), the faces of the box (i.e. the top, left & right) should line up roughly with the perceived edges of the 2D sprite. I want to chop up the 2D sprite along those edges and apply them to the 3 quads (again the top, left and right faces of the 3D cube).

I'd assume there is some pretty gnarly translations to skew the 2D content to fit that quads yet maintain their perspective when viewed via an iso camera in 3D.

  • \$\begingroup\$ Your edit doesn't make things much clearer. The way I'm interpreting it is, that you want to project an image of an isometrically drawn crate on an actual 3d cube? \$\endgroup\$ – bummzack Mar 6 '12 at 17:32
  • \$\begingroup\$ correct, such that the perceived faces of the 2D content get attached to the 3D cube so that faces can be properly sorted. I will try to find a way to illustrate this and post a link in the meantime. \$\endgroup\$ – as3isolib Mar 6 '12 at 19:50
  • \$\begingroup\$ Quite honestly, that doesn't seem to make much sense. For a crate it would be simpler to just model and texture a 3D cube. Other objects (eg. a tree or similar) won't work at all with this "project to cube" approach. \$\endgroup\$ – bummzack Mar 6 '12 at 20:56

You need to learn about UV mapping. For that you'll have to provide UV coordinates with your vertex data. This introduction to stage3D also covers how to use textures and specify UV coordinates (at about 2/3 of the page).

To map a portion of a sprite-sheet to a quad, you have to calculate the UV coordinates for that portion. Imagine your texture is 256 x 256 and you wish to map a sprite with the dimensions of 32 x 32, located at 32, 64 to a quad. Since the texture width and height always maps to 0..1, you calculate the coordinates as follows:

  U: 1 / 256 * 32, V: 1 / 256 * 64
|          |
|          |
|          |   U: 1 / 256 * 64, V: 1 / 256 * 96
|          | / 

So the UV coordinate for the top-left vertex would be 0.125, 0.25 and 0.25, 0.375 for bottom right. Knowing this, it should be simple to calculate the UVs for all the vertices (assuming you're just dealing with simple quads). Calculating good UVs for arbitrary meshes can of course be very complicated, that's why UV coordinates are usually generated by artists when the "unwrap" a model in a 3D modelling package.

| improve this answer | |
  • \$\begingroup\$ Thank you for the detailed response. I think I failed to convey a crucial part of what I am trying to do regarding the skewing. I post up above as a comment to my original post. \$\endgroup\$ – as3isolib Mar 6 '12 at 17:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.