Jump to content
  • Advertisement
Sign in to follow this  
civrob

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 POSISTION
glTranslatef(0.0, 0.0, 1.0);
glPushMatrix();
glPushMatrix();
// EARTHS SPIN
glRotatef(thetaSphere,0.0, 1.0, 0.0);
//Draw earth here
glBindTexture(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 here
glBindTexture(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 this post


Link to post
Share on other sites

glLoadIdentity();

// EARTHS POSISTION
glTranslatef(0.0, 0.0, 1.0); //go to earth position
glPushMatrix(); //push position on the stack for later

// EARTHS SPIN
glRotatef(thetaSphere,0.0, 1.0, 0.0); //make it spin

//Draw earth here
glBindTexture(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 back
glRotatef(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 positio
glRotatef(thetaSphere, 0.0, 1.0, 0.0); //make moon spin around it's own axis

//Draw moon here
glBindTexture(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 this post


Link to post
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]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!