Space sim collision - "movement preservation law" vectors

Started by
1 comment, last by ivucica 16 years, 1 month ago
Cheers, I'm working on a space sim. Simplified, I currently have a ship's rotation quaterion and velocity. Based on the quaternion, velocity and time since last update, I update the ship position. I've began work on collision detection and bumping. I've been speeding around in my physics schoolbook, and I found the "movement preservation law" (is this the correct name in English?):

// new speed:
//       (m1 - m2) * v1 + 2 m2v2
// v1' = ------------------------
//              m1 + m2
Of course, velocities are -- vectors. And, the rotation quaternion not only keeps the ship movement direction, it's also the cockpit direction. So if I converted velocities to vectors and then back to quaternions + scalars, the ship would start facing wrong direction. Instead the cockpit should keep facing the same direction, just the ship should move in opposite direction, and slowly the movement velocity vector should restore to the original one. If I were to introduce another vector (cockpit direction in addition to ship direction) that would complicate the rotation controls which currently have angular velocity, max angular velocity and angular acceleration, and I just update the quaternion accordingly. I'll eventually think of something (hopefully soon), but I thought it couldn't hurt asking. Asking might even speed up the process :) So -- any hints on how would you do it / how you did it? Note, I'm trying to duplicate behavior of X-BTF, X-Tension, and X^2 - The Threat. Please, no comments on correctness of the ship behavior as is. I'm not aiming for a simulation (despite the genre name), and the current behavior feels natural although it's incorrect. If it works for X, it will work for me.
Advertisement
Maybe you could have a deflection velocity that is separate from the direction of the cockpit and have another variable that goes from a 0 to 1 after a collision. That variable could select how much of each vector to derive a final velocity. At 1 it will go in the direction of the cockpit.

Vnet=Vdeflection*(1-t)+Vdirection*t
My current game project Platform RPG
Indeed, might be a good idea. Thanks! Haven't thought of that.

This topic is closed to new replies.

Advertisement