Zoom and panning a map with OpenGL-ES2 on Android

I have created a map of real world property boundaries. I can zoom and pan around fine, until it gets to a certain level of zoom and then my panning is not so smooth.

For zooming in and out I scale the model using Matrix.scaleM() and translateM() to the new correct spot, this is working well. For panning so far I have just been translating the model around.

I keep all my shifts and scale factor in double precision variables for accuracy, casting them last second for OpenGL-ES2. All my data is held in vbo’s

I know the reason for the jump whilst panning, at this level of zoom floating point data types cannot handle the subtle shifts. This is at a scale factor of about 18000.

I have an idea that could possibly work but am unsure how to implement it.

I was thinking that because I am scaling and translating the model, I still have the eye that I could potentially manipulate. I could work out the difference between the double and float values, then maybe use that to adjust the eye via setLookAtM(). So the panning resolution that is lost in the model translate is made up for in a subtle eye shift, similar to the following.

//Gets called through touch event MotionEvent.ACTION_MOVE
public void pan(double x, double y){
        modelXShift = modelXShift + (x / screen_vs_map_horz_ratio);
        modelYShift = modelYShift - (y / screen_vs_map_vert_ratio);
        //Work out difference
        //Only adjusting along the x plane for now
        viewXShiftDiff = modelXShift - (float)modelXShift;
        double eyeAdjustmentX = eyeX - viewXShiftDiff;
        Matrix.setLookAtM(mViewMatrix, 0, (float)eyeAdjustmentX, (float)eyeY, eyeZ, (float)lookX, (float)lookY, lookZ, upX, upY, upZ);
        Matrix.translateM(mModelMatrix, 0, (float)modelXShift, (float)modelYShift, 0f);

Unfortunately this does not work it chops the map approximately in half, only the left side renders.

I would really appreciate help with either getting this idea working or any other possible solutions.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.