views:

461

answers:

1

I am writing an Android AR application and have my engine working but it contains a strange behaviour that I can't seem to get fix. I am overlaying an OpenGL surface on the camera image and am placing 3D objects in the view accordingly. If I use dummy data for the location of my AR objects, i.e. LAT 10 LON 10 become x=10 y=10 on the OpenGL surface, then the overlay works perfectly. However, if I use direct GPS coordinates for my LAT and LON (e.g. LAT 12.34567890 LON 100.23456789) then all my objects either move around their location or don't appear at all. I know there are issues around using floating points and the OpenGL framework, but I've been reading around and am still having trouble stopping this behaviour. Has anyone else had this problem? Should I be using a scaling factor between my GPS and openGL surface, if so what values are good? I tried scaling my LAT and LON by 1000000 to eliminate the floating point, but it didn't help and the performance was terrible.

I'm so close to getting this working, that any help would be much appreciated.

Thanks

+1  A: 

Figure out which 1x1 or 0.5x0.5 degree 'box' your raw coordinates are in and then subtract out that box, so your coordinates are now relative to the 'box' instead of the whole world.

So LAT 12.34567890 LON 100.23456789 is in box (12,100), with coordinates (0.34567890, 0.23456789). You'll want to pass in the (0.34567890, 0.23456789) to OpenGL.

Getting ~1m accuracy from a float with +/-180.0 degree range is kinda sketchy at best, and once you start doing all of OpenGL's matrix operations things start jittering around pretty bad.

genpfault
Hi genpfaultThanks for the reply. You got me thinking along a different line. I started thinking the renderer was screwing things up, but then I remembered the golden rule, 'it's not their code, it's mine'. After taking a more methodical approach I discovered the rotational value I'm using was introducing the jitter, so I need to filter it some more. Hopefully I'm nearly past this and can get it released...
Snowwire