elastolab a physics playground for kids david buck simberon inc
TRANSCRIPT
History
• Started as a Master’s thesis – 1990 Smalltalk
• Re-wrote in C++ (1993)• Close to release (1996)• Rewrote in Smalltalk (1998)• Released for sale (2001)• Physics re-written in Smalltalk
(2002)
Physics
• How do you simulate physics?• Easy:
– Calculate the forces on each particle.– a = F/m– Add a bit of the acceleration to the
velocity– Add a bit of the velocity to the
position– Repeat– Euler’s method
Better
• But really strong springs still explode.• Solution: Adaptive Runge Kutta• Adapt step size according to error
between single and double steps.
Umm… Problem
• Springs explode and rigid bodies don’t spin.
• Solution: Step forward to the time of collision then apply an impulse to the particle
What time is the collision?
• How do we know what time the particle hit?
• What if many particles hit around the same time – which hit first?
Resting Contact?
• What happens if the particle is sitting on the barrier? Collision time is almost zero.
Dynamic Constraints
• Detect resting contacts and add a dynamic constraint force.
• The constraint force is a force just strong enough to prevent the particle from penetrating the barrier.
Net Force
Constraint Force
Multiple resting contacts
• What happens if a particle is in resting contact with two or more barriers?
Solution
• Use Quadratic Programming or Baraff [94]
• <uncle>• Ok, just stop the particle and
hope nobody notices.
User Interface
• Every physics object has a corresponding “Display” object.
• A “Camera” defines the transformation from world to display and back.
• Clipping implemented for lines and polygons.
Interfacing to Sound
• Smalltalk calls a C DLL I wrote• The C DLL calls the COM
interface to access the DirectX 8 sound facilities.
Source Code Management
• For C++, I just made copies of the source files.
• Smalltalk: StORE using a Postgres database.
• ElastoLab consists of 2 bundles, 15 packages, 300 classes.
Making it Fast
• Displaying bitmaps works much faster if you use convertForGraphicsDevice: and cache the result.
• High level optimizations better than low level optimizations
Packaging
• Runtime Packager used for stripping image.
• ResHacker used to create one executable.
• InstallShield Express used to install.
Message Board
• Online message board runs on Web Toolkit.
• SSL pages link to Smalltalk servlets
• Small app (4 classes)