Space-Shooter project, four days to go

Published February 23, 2011
Advertisement
Today I actually managed to force myself into starting on physics right away! I ported my quick n' dirty RigidBody component, which was my entirely scripted physics logic, to C++. I also integrated angular physics.

So today I feel like I've really been a good student for a change... Angular physics turned out to be rather simple to implement, well, for solid sphere anyway :P The inertia tensor for a solid sphere i symmetrical and follows the simple formula

I = (2/5) * M * R^2



or in proper C++ code:


float inertia = (2.0f/5.0f) * body->mass *body-> radius * body-> radius;
body->inertia_tensor = CL_Mat3f::identity();
body->inertia_tensor[0] *= inertia;
body->inertia_tensor[4] *= inertia;
body->inertia_tensor[8] *= inertia;
body->inertia_tensor.inverse();



I inverse at the end there, since it's only the inverse we use during calculations.

But, of course, the response from asteroids when I shoot them, when the mass distribution acts as though it's a solid sphere, isn't realistic. It's a lot better than nothing for a class that focus on physics and collision detection/response in game/simulator development, but it's not sufficient to achieve anywhere near believable angular behavior when I shoot at my asteroids. I guess I'll have to go ahead and calculate a tetrahedron-based inertia tensor from the mesh.

I also fixed some long-time bugs I had laying around from some old experiments in my shaders. They now calculate stuff in tangent-space, like they should due to tangent-space bumpmap textures, and I fixed my specular calculation.

Tomorrow I'll have to work on collision detection with "simulator" precision, plus look at doing engine flame particle effect.
screen0025.png
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement