Sphere

Hi all,

I was wondering if I would be able to request a sphere geometry to be put into place.



Thanks

Yes, you are able to request it. Now, will we honor the request… that’s the question. Sphere is on the to-do list. :slight_smile:

thx mojomonkey

Here’s some code to display a sphere. No texture coordinates, I’m afraid, but I’m sure you can work out the math [beyond my level, though :(]. Grr. If I had more time, I’d translate this into jME for you, but I’m kinda pressed at the moment. (One more test and I’m gonna lose it…) Anyhow,



protected static void drawSphere(int theta, int phi, float radius) {
    float dT = (float) Math.PI / theta * 2;
    float dP = (float) Math.PI / phi;
    float tmp, x, y, z;

    for (int i = 0; i < phi; i++) {
        GL.glBegin(GL.GL_QUAD_STRIP);
        for (int j = 0; j <= theta; j++) {
            tmp = (float) Math.sin(i * dP) * radius;
            x = tmp * (float) Math.cos(j * dT);
            y = (float) Math.cos(i * dP) * radius;
            z = tmp * (float) -Math.sin(j * dT);
            GL.glVertex3f(x, y, z);

            tmp = (float) Math.sin((i + 1) * dP) * radius;
            x = tmp * (float) Math.cos(j * dT);
            y = (float) Math.cos((i + 1) * dP) * radius;
            z = tmp * (float) -Math.sin(j * dT);
            GL.glVertex3f(x, y, z);
        }
        GL.glEnd();
    }
}

thx eric. I found a way to display a sphere with textures, il post it when I get home. :slight_smile:



It isn’t integrated into jME yet, but we’l see how I can get on.



Anything I can get of you eric? to lighten the load.

Both LWJGL and JOGL already have the ability to draw Spheres, why not use that capability in our renderer and simply define the mathmatical properties of a sphere in our lib?

Nevermind, mojo tells me that we shouldn’t rely on the implementation of the underlying lib. Me done.

Sphere is now part of jME. There’s a TestSphere to go along with it.



Enjoy!

brilliant, now I can add a shield to my game! :smiley: