Just a short and sweet post on the progress of my game. This demo shows off basic character and camera controls, as well as interaction with the world. You can toggle gravity using ‘g’, as well as the forces that cause the particles to flock to various shapes using ‘c’. The player moves using standard wasd keys, with ‘q’ and ‘e’ moving the character forward and backward. Holding the left mouse button will fire small “bullets” while clicking the right mouse button will fire larger “bullets”. The player moves within a bounded plane. The statistics display has also been updated to show relevant graphics and physics information.

You can download the executable here: tech_demo_1.zip
Note that you will need to install the June 2010 DirectX and the Visual C++ 2010 runtimes if this is your first time running the software. These should not need to be installed again to run any of my future demos, unless otherwise noted.

Enjoy!

April 28, 2011 Games, Physics

It only took two weeks, but I sorted out (almost) all the kinks with bullet physics. Check it out:

Read More…

February 24, 2011 Graphics, Physics

I just wanted to post a quick sneak peek of what I’ve been working on this past week: integrating bullet physics. Below is just a test, it doesn’t use the full particle system yet (so the framerate suffers greatly due to the naive method used for drawing cubes).

Check out the physics library here: http://bulletphysics.org

February 16, 2011 Graphics, Physics

This update adds the ability to create shapes using a particle collector. The physics for each particle is calculated independently for individual destinations; they do not need to have the same destination. This allows me to specify any number of destinations, which can be moved independently. Because the physics system takes care of tweening between positions, the collector destinations can jump from place to place, and the physics will result in a fluid animation.

Read More…

February 8, 2011 Graphics, Physics

Well, it turns out I was able to guarantee the destination of particles by a deadline. This requires a little bit of cheating; as the lifetime of the particle advances, the velocity vector dictated by the physics is blended with a velocity vector of the same magnitude pointing directly at the destination. This, in combination with a maximum velocity can virtually guarantee that the particle will hit its destination by a specific time. If the velocity vector is blended to point directly at the destination by half the lifetime, and the forces acting on the particle only contribute to increase the velocity towards the destination regardless of its position, then the particle is guaranteed to hit the destination by the end of its life.

Read More…

February 4, 2011 Graphics, Physics

Attempt number 2 at getting particles to stick to a collector: apply gravitational pull to the collector. The ideal is simple; the closer a particle gets to the collector, the greater the force of gravity acting on the particle towards that collector. In this case, I used the inverse of the distance squared. This produces an “Ideal” orbital pattern as shown below:

D3DXVECTOR3 Collector::GetIdealOrbitalForce(const D3DXVECTOR3& magVector,
                                            const float& magLength)
{
    float grav = 1000.0f;
    D3DXVECTOR3 force = magVector * grav;
    if(magLength > 1)
    {
        force /= (magLength * magLength);
    }
    return force;
}

Read More…

January 27, 2011 Graphics, Physics

I saw a video online recently of several cubes flying into the scene and stacking up to form a larger cube. A pretty simple yet powerful effect. The effect was achieved using Particle Flow, so the movement of the particles are entirely animated. Check it out below:

After seeing this, I immediately wanted to try it, but with a more general solution. So, off I went to write a physics system for my particle engine. Now, there are a lot of challenges in getting a particle rocketing through 3D space to land in exactly the right position with physics alone. There are a few options. With physics, we can exponentially increase a force on the particle in the direction of the destination with relation to the distance from the destination. Another possibility is merging a pure physics system with a pure spline animation to allow a random initial velocity, but a guaranteed stopping point.

My first step however, is developing some way to attract the particles to their destination. I decided to start with a spring system. Although the system will exert forces on the particles to aim the particles at the destination, it is very unlikely that they will pass directly through a predetermined point, and instead orbit around the destination.

For those interested, here’s the nice little gem used to compute the spring force. I modified this algorithm from a cloth simulator used in the book “Physics for Game Developers”.

D3DXVECTOR3 Collector::GetForce(Particle particle)
{
    D3DXVECTOR3 forceVector = GetVector(particle);    // From particle to destination
    float length = D3DXVec3Length(&forceVector);
    float k = 1;    // tensile constant
    float d = 1;    // damping constant
    float dot = D3DXVec3Dot(&particle.m_velocity, &forceVector);
    D3DXVECTOR3 force = (k * length + d * (dot / length)) * (forceVector / length);
    return force;
}

January 16, 2011 Graphics, Physics