Here is something I made in about an hour while trying to understand Flash 8 transformation matrix: http://www.hot.ee/tonypa/skew.html
Flash8 only! Update the player if still using old one.
Click for focus then use arrow keys to move.
It has currently 16 movie clips and is set to 42 fps.
Its much easier then it looks, if someone finds it interesting, I will post the code (its pure AS).
Nice, too bad it really cannot be used to make 3d look cause lack of perspective.
edit:
Sorry, have to take it back.
Actually if you precalculate the perspective for the walls, you could manage to get "real" perspectice, at least moving camera only x- ja y-axis.
You're genious!
So, not making walls rectangle but making them have top wider than the bottom
Code:
_______
\ /
\___/
Last edited by TeroLebe; 03-14-2006 at 05:53 PM.
Reason: TonyPa, You're genious
Its beautiful! How do you sort the depths outward from the center? Do you calculate the distance and sort on that? Nice job... i d be interested to know if you find a way to do the perspective transformation on the texture by script .
is it just me or are the first and second examples identical?
The example one uses have some wall graphics (bitmaps) while first example is only colored rectangles.
Originally Posted by LeechmasterB
How do you sort the depths outward from the center? Do you calculate the distance and sort on that?
Yes, for each block distance from its center to the center of stage is found and then some unique number added to avoid same depth problem.
I have attached the code file. Include code or copy/paste it into your fla to see it. The basics: every block has 3 child mcs with rectangles in each of them. In skew function the top (roof) is moved, 2 walls are skewed and moved based on the distance from center of stage and height of block.
The example one uses have some wall graphics (bitmaps) while first example is only colored rectangles.
Yes, for each block distance from its center to the center of stage is found and then some unique number added to avoid same depth problem.
The code looks really nice and clean! You wrote it just so damn clean nice compared to my stuff.... also you pass the matrix values directly which i calculated through multiplying the matrixes, gotta clean up my stuff .
I knew that i should have sticked to using the distance from the center for z sorting... i did not dare to because of the "distance calculation" but if you think about it you have to calculate it once anyhow (hm or may be not i gotta look at my code hehe). Again... great job and thank you for the source, just for being able to have a look at nice written code, you make me feel like a fresh as noob again.
Isometric also has lack of perspective and some people still call it 3d and still can make interesting effects with it
Yep, but as you see, with same sized roof than the "floor" causes wierd effect, like buildings were pyramid-likes ( the pointy top chopped off ).
But if walls were pre-rendered/calculated to look like drawing i already "posted", and if the roof were bigger, it looked like "real 3d" with perspective and could use un-modified TonyPa's code. So i think it could be done with only changing gfx to get "real 3d" feeling.
Its not that easy, Tero, you still need to modify the move/skew code because walls in perspective do not line up at the edge. Of course it would be nice if you could create such example
I have examples already but they are messy written. Also some things are done differently.
The flash bitmap data max size is 2000x2000 pixels. So i used a 2000x1000 pix png for all textures. And thereby the max size ended up being 20 (with the use of 100x100 tiles). So since there are only 20 different heights i already have holders for each layer. I put the roofs into those holders and this way i can move all together and dont have to recalculate their position or the length to the center point. That way i can also just access the roofs x and y properties to scew the walls and dont need to calculate the distance again. Only for creating a new house / roof that is necessary. So this already makes it a lot messier... another thing is that i have premade wallclips so that i only use the matrix for scewing and dont have to rotate the walls all the time. But there are up to 4 walls instead of only 2 and a roof but it allowes 4 different textures with that method. So it all would look really really messy for an example. But the angle of the perspective scew on the walls is easy to do with photoshop's perspective scew tool. Just this method also lead me to the depth sorting problem.. so probably the distance needs to be calculated again just for that purpose.