Easy viewport transformations!

Discuss issues specific the Java port of Box2D
toucansam
Posts: 356
Joined: Mon Jun 08, 2009 12:21 pm
Contact:

Easy viewport transformations!

Postby toucansam » Thu Jul 23, 2009 11:41 pm

I noticed that the whole overriding transformation methods in debug draw was rather dirty and very awkward, especially if you're trying to maintain your own viewport transformations in your own program. So instead I make DebugDraw use an IViewportTransform interface, which has all necessary functions for any generic drawing transformations, yet staying detached from the drawing itself. I also included an OBBViewportTransform, which uses an OBB to transform world coordinates to the screen (and back). This also means you can do slightly more crazy stuff, like rotations (uses a Mat22, so nothing too crazy).

The great thing about the interface is that you can make your own transformation class and do whatever types of transforms you want (like messing with 3x3 or 4x4 matrices), and have the debugdraw do all the correct rendering :D .

DebugDraw still includes it's old methods transformation methods (which use the new ViewportTransform), so it shouldn't be that big of a deal to update your code.

Return to “Java”



Who is online

Users browsing this forum: No registered users and 1 guest