MRSGT _GT
MRSGT _GT

Reputation: 256

Android 3D Surface Plot

My requirement is to create a 3d surface plot(should also display the x y z axis) from a list of data points (x y z) values.The 3d visualization should be done on ANDROID.

My Inputs : Currently planning on using open gl 1.0 and java. I m also considering Adore3d , min3d and rgl package which uses open gl 1.0. Good at java ,but a novice at 3d programming.
Time Frame : 2 months

I would like to know the best way to go about it? Is opengl 1.0 good for 3d surface plotting?Any other packages/libraries that can be used with Android?

Upvotes: 6

Views: 7301

Answers (2)

Re the second part of your question:

Any other packages/libraries that can be used with Android?

Yes, it's now possible to draw an Android 3D Surface Plot with SciChart.

Lots of configurations are possible including drawing wireframe, gradient colour maps, contours and real-time updates.

Android 3D Surface Plot

Disclosure, I'm the tech lead on the scichart team

Upvotes: 0

the swine
the swine

Reputation: 11031

Well, you can plot the surface using OpenGL 1.0 or OpenGL 2.0. All you need to do is to draw the axes as lines and draw the surface as triangles. If you have your heightfield data, you would do:

float[][] surface;
int width, height; // 2D surface data and it's dimensions

GL.glBegin(GL.GL_LINES);
GL.glVertex3f(0, 0, 0); // line starting at 0, 0, 0
GL.glVertex3f(width, 0, 0); // line ending at width, 0, 0
GL.glVertex3f(0, 0, 0); // line starting at 0, 0, 0
GL.glVertex3f(0, 0, height); // line ending at 0, 0, height
GL.glVertex3f(0, 0, 0); // line starting at 0, 0, 0
GL.glVertex3f(0, 50, 0); // line ending at 0, 50, 0 (50 is maximal value in surface[])
GL.glEnd();
// display the axes

GL.glBegin(GL.GL_TRIANGLES);
for(int x = 1; x < width; ++ x) {
    for(int y = 1; y < height; ++ y) {
        float a = surface[x - 1][y - 1];
        float b = surface[x][y - 1];
        float c = surface[x][y];
        float d = surface[x - 1][y];
        // get four points on the surface (they form a quad)

        GL.glVertex3f(x - 1, a, y - 1);
        GL.glVertex3f(x, b, y - 1);
        GL.glVertex3f(x, c, y);
        // draw triangle abc

        GL.glVertex3f(x - 1, a, y - 1);
        GL.glVertex3f(x, c, y);
        GL.glVertex3f(x - 1, d, y);
        // draw triangle acd
    }
}
GL.glEnd();
// display the data

This draws simple axes and heightfield, all in white color. It should be pretty straight forward to extend it from here.

Upvotes: 5

Related Questions