Posts Tagged ‘physics’

Gravity and lighting

Saturday, February 6th, 2010

I added some basic lighting and…. quite frankly it looks terrible, but lighting isn’t the point of the exercise. It’s enough to have a point light that visually aids the 3d perception of the spheres.

The end idea is that a number of ballsĀ need to bounce around a box, colliding off each other and off walls until they come to rest. A few of my prototypes in order…

  • Display a Sphere in the world.
  • Gave the Spheres concept of velocity. The Sphere would move down (y-axis) forever.
  • Added a ‘ground’ stopping point. If the Sphere’s y position was 0, it would stop. This does not take into account different sphere radii.
  • Inverted the Sphere’s velocity when it hit ground. Now it would drop, bounce, and fly upwards forever.
  • Time for gravity! Add a 9.81 velocity every second to the Sphere (spread out over frames of course). The Sphere would now accelerate towards the ‘ground’, and slow its ascend.
  • Modelling this as an inelastic collision, some energy will be lost. To keep the model simple, the Sphere rebounds with 80% of its initial velocity.
  • As another test, started the Sphere with an initial velocity of 0. That is, it will fall to the earth naturally through gravity.

It’s proving to be a fun model so far. Next, going to put some primitive planes in place so that the box will be visible and allow it to bounce off each one.