Creating an Hourglass

Topics: Developer Forum
Aug 17, 2010 at 1:16 PM


I want to create an hourglass where the edged of the hourglass is the world, and the sand can flow through the hourglass to the bottom. Is this something that's possible?


And also, where should I start?



Mark Monster

Aug 17, 2010 at 4:57 PM
If you use FPE 3.0, you can create static edges that makes up the hourglass. Inside this hourglass, you can add small fixtures that works like sand. Your biggest problem would be performance if you would like to have a lot of sand in the hourglass. But it is possible. You start by downloading the physics engine of your choice. I'm nearly ready to release version 3.0, so I would use that if I were you. You can get it from the "Source Code" tab at the top of the page. Once you have downloaded the engine, you can take a look at the samples to see how you use the engine. There will be a much simpler sample out soon (sort of a hello world) that shows you the very fundamentals in implementing the engine. When you have the engine up and running. You simple use the FixtureFactory.CreateEdge() method to create your hourglass. You also use the FixtureFactory to create the sand. And that is pretty much it.
Aug 18, 2010 at 1:57 PM
I would definitely use FP3 for this, as circle-circle collisions are more accurate (and possibly faster?) in FP3 than in FP2 (where circles are approximated by polygons). In FP2 you'll probably get a lattice going with all of the small polygon-circles pushing on each other and not a smooth flow down the hourglass. Is the hourglass itself going to be static? If so, you could also try a pixel-based solution (like the sand games you find on the internet). You can implement it in a pixel shader and get far better visual results and performance than with physics objects.