A simple 3D graphics engine to combine with Box2D?

Discuss issues specific to the Flash/AS3 port of Box2D
0x00
Posts: 6
Joined: Wed Apr 13, 2011 9:05 am

A simple 3D graphics engine to combine with Box2D?

Postby 0x00 » Thu Jan 31, 2013 9:53 am

I hope this thread fits on this forum, I know it's not very related to Box2D. My apologies if it belongs somewhere else!

I'm using Box2D to make a top down game with a ball that moves around. The game is entirely 2D, but I'd love it if I could give the ball a 3D animation, so it really looks as if it's rolling around.

What would be the best way to do this? I'm thinking I could use a 3D engine to draw a ball, and apply Box2D's linear velocity as the balls rotation around one axis, and the angular velocity as rotation around another.

Would this work? Does anybody know a simple, lightweight engine I could use, that doesn't require the user to install a plugin (such as unity)?

Many thanks!
0x00

0x00
Posts: 6
Joined: Wed Apr 13, 2011 9:05 am

Re: A simple 3D graphics engine to combine with Box2D?

Postby 0x00 » Thu Jan 31, 2013 12:50 pm

Nevermind, found a neat way to do it with no engine. Here if anybody in the future needs it:

http://board.flashkit.com/board/showthr ... t-in-AS3.0

sketchbookgames
Posts: 564
Joined: Tue Feb 24, 2009 4:10 pm
Location: Michigan
Contact:

Re: A simple 3D graphics engine to combine with Box2D?

Postby sketchbookgames » Mon Feb 04, 2013 7:15 pm

You can slightly notice the lack of 3d perspective on Emanuele's sample.

anyway, for 3d rotation on a ball using 2d physics,
x rotation is determined by the change in x position divided by the circumference.
y rotation is determined by the change in y position divided by the circumference.
z rotation uses real 2d rotation. (keep in mind your degrees and radians translations.)

(actually the last time i implemented that; y and z were swapped, but that may have been due to the camera angle.)

good luck however you implement it.


Return to “Flash”



Who is online

Users browsing this forum: No registered users and 1 guest