nwenden Karte der Erde Textur eine Kug

Ich habe versucht, eine 3D-Animation in OpenGL (mit JOGL) eines Sonnensystems zu implementieren. Bisher habe ich 5 Planeten unterschiedlicher Größe, aber das Problem, das ich zu haben scheine, ist, dass ich keine Karte der Erdtextur auf einer Kugel hinzufügen kann Hilft mir jemand, wie es gemacht wird?

Dies ist der Code, den ich bisher in meiner Anzeigemethode habe:

@Override
public void display(GLAutoDrawable drawable) {
    GL2 gl = drawable.getGL().getGL2(); 
    GLU glu = new GLU();
    gl.glClear(GL.GL_COLOR_BUFFER_BIT);

    //make sure we are in model_view mode
    gl.glMatrixMode(GL2.GL_MODELVIEW);
    gl.glLoadIdentity();
    glu.gluLookAt(10,20,20,0,3,0,0, 20, 0);
    //gl.glMatrixMode(GL2.GL_PROJECTION);
    //glu.gluPerspective(45,1,1,25);

    //render ground plane
    gl.glPushMatrix();
    gl.glTranslatef(-10.75f, 3.0f, -1.0f);
    gl.glColor3f(0.3f, 0.5f, 1f);
    GLUquadric earth = glu.gluNewQuadric();
    glu.gluQuadricDrawStyle(earth, GLU.GLU_FILL);
    glu.gluQuadricNormals(earth, GLU.GLU_FLAT);
    glu.gluQuadricOrientation(earth, GLU.GLU_OUTSIDE);
    final float radius = 3.378f;
    final int slices = 89;
    final int stacks = 16;
    glu.gluSphere(earth, radius, slices, stacks);
    glu.gluDeleteQuadric(earth);

    Texture earths;
    try {
      earths = TextureIO.newTexture(new File("earth.png"), true);
    }
    catch (IOException e) {    
      javax.swing.JOptionPane.showMessageDialog(null, e);
    }        
    gl.glPopMatrix();
    //gl.glEnd();

    gl.glPushMatrix();
    gl.glTranslatef(2.75f, 3.0f, -0.0f);
    gl.glColor3f(0.3f, 0.5f, 1f);
    GLUquadric earth1 = glu.gluNewQuadric();
    glu.gluQuadricDrawStyle(earth1, GLU.GLU_FILL);
    glu.gluQuadricNormals(earth1, GLU.GLU_FLAT);
    glu.gluQuadricOrientation(earth1, GLU.GLU_OUTSIDE);
    final float radius1 = 3.378f;
    final int slices1 = 90;
    final int stacks1 = 63;
    glu.gluSphere(earth1, radius1, slices1, stacks1);
    glu.gluDeleteQuadric(earth1);
    gl.glPopMatrix();

    gl.glPushMatrix();
    gl.glTranslatef(3.75f, 6.0f, -7.20f);
    gl.glColor3f(0.3f, 0.5f, 1f);
    GLUquadric earth3 = glu.gluNewQuadric();
    glu.gluQuadricDrawStyle(earth3, GLU.GLU_FILL);
    glu.gluQuadricNormals(earth3, GLU.GLU_FLAT);
    glu.gluQuadricOrientation(earth1, GLU.GLU_OUTSIDE);
    final float radius3 = 1.878f;
    final int slices3 = 89;
    final int stacks3 = 16;
    glu.gluSphere(earth3, radius3, slices3, stacks3);
    glu.gluDeleteQuadric(earth3);
    gl.glPopMatrix();   

    gl.glPushMatrix();
    gl.glTranslatef(12.75f, 2.0f, -7.20f);
    gl.glColor3f(0.3f, 0.5f, 1f);
    GLUquadric earth4 = glu.gluNewQuadric();
    glu.gluQuadricDrawStyle(earth4, GLU.GLU_FILL);
    glu.gluQuadricNormals(earth4, GLU.GLU_FLAT);
    glu.gluQuadricOrientation(earth4, GLU.GLU_OUTSIDE);
    final float radius4 = 1.078f;
    final int slices4 = 89;
    final int stacks4 = 16;
    glu.gluSphere(earth4, radius4, slices4, stacks4);
    glu.gluDeleteQuadric(earth4);

    gl.glPopMatrix(); 

    gl.glPushMatrix();
    gl.glTranslatef(2.75f, -6.0f, -0.0f);
    gl.glColor3f(0.3f, 0.5f, 1f);
    GLUquadric earth5 = glu.gluNewQuadric();
    glu.gluQuadricDrawStyle(earth5, GLU.GLU_FILL);
    glu.gluQuadricNormals(earth5, GLU.GLU_FLAT);
    glu.gluQuadricOrientation(earth5, GLU.GLU_OUTSIDE);
    final float radius5 = 3.778f;
    final int slices5 = 90;
    final int stacks5 = 63;
    glu.gluSphere(earth5, radius5, slices5, stacks5);
    glu.gluDeleteQuadric(earth5);
    gl.glPopMatrix();        

}

Antworten auf die Frage(2)

Ihre Antwort auf die Frage