Hi again,
I've actually got a plugin now that takes FSX / P3D output (via fsuipc) and drives the Outerra engine via the OT_API.... almost.
Everything is almost ok around the equator but I've got some kind of weird problem with pitch being wrong the further I move away from the equator..either North or South.
I don't think it's my code creating the issue because even if I hard code ECEF values as per the example igc_plugin.dll and rotate the heading from 0 to 2PI (0-360 degs) it seems like its not rotating around a 'normal' to the planet surface. Am I missing something? Do I need to compensate in my code for this change in position?
Code:
void llaToWorld(double lat, double lon, double alt)
{
double rad = 6378137; // radius
lat = lat * (M_PI / 180.0);
lon = lon * (M_PI / 180.0);
double f = 0.0; //flattening
double ls = atan(pow((1.0 - f), 2) * tan(lat)); // lambda
double x = rad * cos(ls) * cos(lon) + alt * cos(lat) * cos(lon);
double y = rad * cos(ls) * sin(lon) + alt * cos(lat) * sin(lon);
double z = rad * sin(ls) + alt * sin(lat);
ecef[0] = x;
ecef[1] = y;
ecef[2] = z;
}
then later:
startPos = double3(ecef[0], ecef[1], ecef[2] );
double dtr = M_PI / 180.0;
quat startRot = set_heading_pitch_roll(startPos, float3((playerHeading*dtr), (dtr*playerPitch), (dtr*playerBank)));
this->set_pos(startPos, startRot);
this shows the effect:
startPos = double3(-2286686.1965365410,-3734648.0835802061,4638811.4431277402);
quat startRot = set_heading_pitch_roll(startPos, float3(0, 0, 0));
this->set_pos(startPos, startRot);
Any clues or even a link to a clue would be really appreciated.
Thanks,
Langdon