# OpenGL I give up [Almost did] THANX EVERY1!!! esp thorin

This topic is 5047 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Thanks everyone 4 ur help. My verdict on openGL having only ever done java before is that it is a mind puzzle! but things are starting to make sense now :D slowley. Dont even want to thing about lighting lol! >I finally admit it ive been beaten :-( >rotating the moon around the earth.... I have been at it for >hours on end [16hours] and although its simple I cant figure >it out :-( the files are at. >http://www.nonlinea.co.uk/myOpenGL/earth.zip [Edited by - civrob on December 1, 2004 9:20:05 PM]

##### Share on other sites
think im posting in the wrong place?

##### Share on other sites
The basic set of transformations that need to happen are:
1) translate moon out from origin the distance it is from the earth
2) rotate moon
3) translate moon by the distance the earth is from the origin.

Rotations are always about the origin. So to get the moon to rotate about the earth you need to make the earth the origin. This is in essence what step one is trying to do. Then you rotate the moon about the origin the amount you want. After that you will have to translate the earth back to its location in the solar system along with the moon. This is done in step 3.

To really make this work well the best way to go, in my opinion, is to get/write a scene graph. This makes doing this type of rotation very easy.

Chris

##### Share on other sites
thanks for your reply. It makes sense that the origin needs to be the earth. I tried setting it so that it is the eart but it just carried on as it is?
not sure im changing the right value? Does not matter wich one i change it still rotates on it self

thetaSphere is the Earth
thetaMoon is the Moon

....................x.........y.....z...??
glRotatef(thetaSphere, 0.0, 0.0, 0.0);

##### Share on other sites
Here is how I would do it, the earth I have at some spot other than the origin.

glPushMatrix()
glTranslate (to the earth position)
glPushMatrix()
glpushMatrix()
glrotate(the earths spin)
//Draw earth here
glPopMatrix()
glTranslate(the distance from the earth to the moon)
glRotate(the rotation of the moon around the earth)
//Draw moon here
glPopMatrix()
glPopMatrix()

since you are translating you would draw the moon/earth as if they were at the origin where its commented to do so.

BTW when you post code put it in [ source] [ /source] tags and dont post the entire program.

##### Share on other sites
thanks for your reply it is still not going around the earth.. here is what i typed.

void drawTextureSphere(){    glPushMatrix();// EARTHS POSISTIONglTranslatef(0.0, 0.0, 1.0); glPushMatrix();glPushMatrix();// EARTHS SPINglRotatef(thetaSphere,0.0, 1.0, 0.0); //Draw earth hereglBindTexture(GL_TEXTURE_2D, 5);GLUquadricObj * object;object= gluNewQuadric();gluQuadricDrawStyle(object, GLU_FILL);gluQuadricTexture( object, GL_TRUE );gluSphere(object, 1.0, 50, 50);gluDeleteQuadric(object);glPopMatrix();//the distance from the earth to the moon glTranslatef(2.0, 0.0, 0.5);glRotatef(thetaSphere, 0.0, 1.0, 0.0);//Draw moon hereglBindTexture(GL_TEXTURE_2D, 6);GLUquadricObj * object1;object1= gluNewQuadric();gluQuadricDrawStyle(object, GLU_FILL);gluQuadricTexture( object, GL_TRUE );gluSphere(object1, 0.25, 10, 10);gluDeleteQuadric(object1);glPopMatrix(); glPopMatrix(); 		}

Been working on this for 12 hours and I really dont want to give up :-)

##### Share on other sites
glLoadIdentity();// EARTHS POSISTIONglTranslatef(0.0, 0.0, 1.0);  //go to earth position glPushMatrix(); //push position on the stack for later// EARTHS SPINglRotatef(thetaSphere,0.0, 1.0, 0.0); //make it spin//Draw earth hereglBindTexture(GL_TEXTURE_2D, 5);GLUquadricObj * object;object= gluNewQuadric();gluQuadricDrawstyle(object, GLU_FILL);gluQuadricTexture( object, GL_TRUE );gluSphere(object, 1.0, 50, 50);gluDeleteQuadric(object);glPopMatrix();  //get our earth position backglRotatef(angle, 0.0, 1.0, 0.0) //make moon rotate around earth//the distance from the earth to the moon glTranslatef(2.0, 0.0, 0.5);   //go to our moon positioglRotatef(thetaSphere, 0.0, 1.0, 0.0);   //make moon spin around it's own axis//Draw moon hereglBindTexture(GL_TEXTURE_2D, 6);GLUquadricObj * object1;object1= gluNewQuadric();gluQuadricDrawstyle(object, GLU_FILL);gluQuadricTexture( object, GL_TRUE );gluSphere(object1, 0.25, 10, 10);gluDeleteQuadric(object1);

dunno if that'll work.. been up for 36h :/

##### Share on other sites
doesnt work gives me a blank screen!!! I give up feel really gutted I mean how hard can drawing a stupid circle around another circle be?

[Edited by - civrob on December 1, 2004 7:50:44 PM]

1. 1
2. 2
3. 3
4. 4
Rutin
11
5. 5

• 12
• 19
• 10
• 14
• 10
• ### Forum Statistics

• Total Topics
632666
• Total Posts
3007720
• ### Who's Online (See full list)

There are no registered users currently online

×