PDA

View Full Version : Drawing Isometric Projections



LevelFour
13th January 2010, 14:10
Greetings,

I am trying to draw a number of primitive objects with various isometric projections. I've reviewed the documentation relating to transforms as well as the affine example, but oddly the results are not as expected. Usually for a isometric projection, an object is sheared 30 degrees and rotated 30 degrees (for example). I would therefore expect the code to be quite simple such as:

p->shear(0,30)
p->rotate(30)

However this does not produce the anticipated results. Forgive the ignorance, but has anyone worked with creating isometric projections and can you offer any advice.

Thanks!

high_flyer
13th January 2010, 16:39
can you show a screenshot?
What do you mean by primitive objects exactly? (to make sure we speak on the same thing)

LevelFour
14th January 2010, 10:33
Yes, below is a graphic of the mock-up. By primitive objects you will see that they are rectangles. The idea is that such a graphic can be created where a "node" is selected and a button is clicked to set the isometric projection (e.g. -30 degrees, plus 30, etc.)

4130

Thanks for the help.

high_flyer
14th January 2010, 13:46
This indeed should be possible with a similar code that you posted.
Can you show a screenshot of what you are getting as a result?

LevelFour
14th January 2010, 15:14
Well, I'd post the screen shot but it is an abolute mess. The graphics are twisted beyond recognition using:

p->shear(0,30)
p->rotate(30)

Oddly, when I play with the numbers and try p->shear(0.0.6) it is the closed to the expected representation. Maybe I missing something and the expected values for shear are not degrees?

Thanks for your help.

ChrisW67
14th January 2010, 22:43
I would guess the parameters to shear() are where the points (0, 1) and (1, 0) get transformed to by the shear. They map to (0, sx) and (sy, 0). For a 30 degree shear on the y-axis try sy = 0.5 (sine(30 deg)).

Typical 2D shear transformations would build a transform matrix like:


X' = | 1 sx 0 | | x |
| sy 1 0 | | y |
| 0 0 1 | | 1 |

so

x' = x + sx * y
y' = y + sy * x