i'm working on vehicle physics in OpenGL, and all seems well, except for one problem. the glTranslatef(); function dosn't seem to be working. at all. either that, or theres somthing wrong with the physics code itself which is very, very possible.
vehicle.cpp (most of it. dosn't show includes and variable declarations):
from my render(); function:Code:void vphys::setup(float engine, float mass, float pos[2], float sdir[2]) { vd.epower = engine; vd.m = mass; //vd.p[2] = pos[2]; vd.dir[2] = sdir[2]; } void vphys::mainroutine() { //traction vd.tractionF[0] = vd.dir[0]*vd.epower; vd.tractionF[1] = vd.dir[1]*vd.epower; //drag vd.speed = sqrt(vd.v[0]*vd.v[0]+vd.v[1]*vd.v[1]); vd.dragF[0] = -dragC*vd.v[0]*vd.speed; vd.dragF[1] = -dragC*vd.v[1]*vd.speed; //roll resistance vd.rrF[0] = -rrC*vd.v[0]; vd.rrF[1] = -rrC*vd.v[1]; //total longtitudinal force float longF[2]; longF[0] = vd.tractionF[0]+vd.dragF[0]+vd.rrF[0]; longF[1] = vd.tractionF[1]+vd.dragF[1]+vd.rrF[1]; //acceleration vd.a[0] = longF[0]/vd.m; vd.a[1] = longF[1]/vd.m; //velocity vd.v[0] = vd.v[0]+dt*vd.a[0]; vd.v[1] = vd.v[1]+dt*vd.a[1]; //final position vd.p[0] = vd.p[0]+dt*vd.v[0]; vd.p[1] = vd.p[1]+dt*vd.v[1]; glTranslatef(0, 0, vd.p[1]); }
I really have no idea whats wrong. Although I havn't coded in 3.5 weeks, so i'm a little rusty. (more than I was to begin with :P).Code:glScalef(0.01, 0.01, 0.01); _peVphys->setup(900, 1000, startposition, startdirection); _peVphys->mainroutine(); pModel->draw();
-psychopath



LinkBack URL
About LinkBacks



.