I\'m developing a turn-by-turn navigation software and I\'m using the following solution to make my lines of roads into 2.5D or 3D View
Draw 2.5D or 3D Map with C# f
The problem with the equation is that it allows the projected x value to cross the mid-line (w/2
). This is not desirable when trying to model a perspective transform since lines should approach, but do not cross, a vanishing point. Also, because of the way the equation is written, this crossing happens in front of the camera instead of behind, which leads to unnecessary artifacts. Try something like this instead:
halfW = w/2 dx = (x - halfW) dy = (h - y) // y increases downwards // tune these constants to taste. top = 1.25 bottom = 0.75 lowerBound = 0.1 // Avoids divide by zero and perspective lines crossing midline x_ = (dx / max(lowerBound, (bottom + ((dy / h) * (top - bottom))))) + w/2