Name: Anonymous 2011-11-27 5:27
How do I convert 2d isometric sprite into a 3d model?
/|
/ |
/ |
/ |
/ |
/ |
/| |
/ | |
*--|-----|(cx,0)
`\|(x,y)|
\|\ |
\ `\ |
\ `\|
\ |(cx,cy)
\ |
\ |
\|
d = \sqrt((cx)^2 + (cy)^2 + c^2)
d^2 = (cx)^2 + (cy)^2 + c^2
d^2 = (x^2 + y^2 + 1)c^2
c^2 = (d^2)/(x^2 + y^2 + 1)
c = \sqrt((d^2)/(x^2 + y^2 + 1))
c = d/\sqrt(x^2 + y^2 + 1)
z = d/sqrt((x/z)^2 + (y/z)^2 + 1) You do that. Scale it z. now (x/z, y/z, 1) be like (x, y, z). Back to original! But original no exist! It only in head! you see?
(define (map-to-view xy)
(let ([x (vector-ref xy 0)]
[y (vector-ref xy 1)])
(vector (- (* x (/ tile-w 2)) (* y (/ tile-w 2)))
(- (* x (/ tile-h 2)) (* y (/ tile-h 2))))))
(define (view-to-map xy)
(let ([x (vector-ref xy 0)]
[y (vector-ref xy 1)])
(vector (/ (+ (* y tile-w) (* x tile-h))
(* tile-w tile-h))
(/ (- (* y tile-w) (* x tile-h))
(* tile-w tile-h)))))