Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

share|improve this question
    
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? –  bummzack Mar 6 '12 at 17:32
    
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. –  as3isolib Mar 6 '12 at 19:50
    
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. –  bummzack Mar 6 '12 at 20:56
add comment

1 Answer

up vote 2 down vote accepted

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.

share|improve this answer
    
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. –  as3isolib Mar 6 '12 at 17:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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