============================
Would it at all be possible to take a closer look at the box2d setup for your Lotto Mixer app?
============================
If you mean a closer look at the RUBE file, I think I will keep that closed source for now
![Smile :)](./images/smilies/icon_e_smile.gif)
But I can give you an overview of how the whole thing works though, see the attached image to see what I'm talking about here:
-------------------------------
- The two sets of five ball bodies in the feeder are deleted after loading, they are only used to find the positions where the balls should start. Balls will be positioned in a line between the two corresponding locations in each row.
- The large sensor surrounding the feeder is used to detect when balls leave the feeder (EndContact) to make sure that all balls have fallen into the mixer before closing the door.
- The feeder door is just a semi-circular body which rotates around the center of the mixer on a revolute joint. The revolute joint has limits, so the door can be opened and closed just by changing the joint motor speed (direction), and checking whether the door is closed can be done by checking the joint position.
- The mixing paddles are also just rotating around the center of the mixer. They are quite heavy compared to the balls.
- The trapdoor is one body on a prismatic joint, but it has two fixtures so they move in perfect unison. The fixtures are placed so that at one end of the slide the bottom trapdoor is closed but the top is open, and at the other end of the slide the openings are opposite. The prismatic joint has limits so this one can also be controlled just by changing the joint speed. The top fixture has a sloped upper edge to lift up the ball sitting on top of the one that fell into the trapdoor area, when the door closes.
- The small sensor inside the trapdoor area detects when a ball has fallen in, so the trapdoor can be closed. There is a weak point in the design in that a ball can actually fall down into the trapdoor area and bounce back out again quickly, and this sensor will think there is still a ball there. But that's ok because...
- The large sensor surrounding the 'winners pedestal' at the bottom counts how many balls are in that area, so the drawing will continue until the right number of balls are in that area for more than a few seconds.
- For all balls in the pedestal area which have a very low linear velocity (ie. not moving), a small torque is applied to turn them around so that the number is facing the right way up. There is no check to see if the number is already up the right way, this torque is simply applied continuously.
- The single ball inside the mixer is the template ball. This ball will be destroyed after loading, but the characteristics of it (density, friction, restitution etc) will be copied first. These characteristics will then be used to make the actual balls used for the draw. This just lets me play with the ball in the editor to get the right feel, rather than coding stuff by hand.
- The edge fixtures around the outside are just there as a guide to judge how big the mixer will look on an iPhone screen.
-------------------------------
I believe that's the main gist of it. Hope that helps!