14 March 2006

Shield Rings


Here's a cool graphics effect I've been working on lately. When a projectile hits the shields on a ship it causes a subtle ripple effect at the point of collision. To do this I had to solve a few problems.



The first is how to store the collision point. The collision occurs at the projectile's world coordinates at impact. These points are converted to ship relative vector using the inverse rotation matrix of the ship. Apparently rotation matrixes are magical in that their inverse is just their transpose, which is nice because it's a lot easier. Then at render time the point is converted back to world relative coordinates using the latest ship rotation, so the the rings actually move/rotate with the ship, as if they're a temporary part of the shields. If you have any real world scientific data on the effects of motion on death ray particle shields, be sure to email it to me.

The second problem is finding the angle to display the rings at. I decided I wanted the rings to always move outward perpendicular to the center of the ship. To do this I compute the vector from the center of the ship to the collision point, normalize it and find a perpendicular angle using this:

Vector perp(out.y - out.z, out.z - out.x, out.x - out.y);

I find the third perpendicular vector by taking the cross product of these two angles.
Vector perp2 = perp.cross(out);

Now I can use perp and perp2 as the two directions to stretch my ring into. Rocking good times.

0 Comments:

Post a Comment

<< Home