#161316 - 3dfx - Fri Aug 01, 2008 2:05 am
I'm trying to port my 3d game-ish/engine to the DS. At first I used floats because it made more sense to me but my frame rate started taking a nose dive so I converted everything to fixed point. Everything seems to work all right except my models. The interpolation between keyframes with them are screwed up big time using fixed point but are fine with floats. Here's how I have the interpolation:
^^ Works fine. Using fixed points,
The model animates fine when I don't interpolate (albeit jerkily as it should).
Can anyone see what I'm doing wrong?
Code: |
//model->timeStep is how far from 0.0f to 1.0f the model has been animated //model->end and model->begin are int values of what frame our current animation begins and ends at //old way float fraction = (model->timeStep - (float)(start - model->begin) / (float)(model->end - model->begin + 1)) * (model->end - model->begin + 1); VERTEX3 one, two, pt; one.x = model->frames[start].vertices[vertex].position.x; one.y = model->frames[start].vertices[vertex].position.y; one.z = model->frames[start].vertices[vertex].position.z; two.x = model->frames[end].vertices[vertex].position.x; two.y = model->frames[end].vertices[vertex].position.y; two.z = model->frames[end].vertices[vertex].position.z; //my new vertex pt.x = one.x * (1 - fraction) + two.x * fraction; pt.y = one.y * (1 - fraction) + two.y * fraction; pt.z = one.z * (1 - fraction) + two.z * fraction; |
^^ Works fine. Using fixed points,
Code: |
float fraction = (model->timeStep - (float)(start - model->begin) / (float)(model->end - model->begin + 1)) * (model->end - model->begin + 1); v16 cFrac = floattov16(fraction); VERTEX3F one, two, pt; one.x = model->frames[start].vertices[vertex].position.x; one.y = model->frames[start].vertices[vertex].position.y; one.z = model->frames[start].vertices[vertex].position.z; two.x = model->frames[end].vertices[vertex].position.x; two.y = model->frames[end].vertices[vertex].position.y; two.z = model->frames[end].vertices[vertex].position.z; //my new vertex pt.x = one.x * (floattov16(1.0f) - cFrac) + two.x * cFrac; pt.y = one.y * (floattov16(1.0f) - cFrac) + two.y * cFrac; pt.z = one.z * (floattov16(1.0f) - cFrac) + two.z * cFrac; |
The model animates fine when I don't interpolate (albeit jerkily as it should).
Can anyone see what I'm doing wrong?