🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
I have a space problem (about rotation).
Let say I have a Spaceship in space.
I also have a asteroid in the same space.
I want a to be able to rotate a camera around the ship.
I want to be able to rotate the ship, here is the big problem. When I rotate around the first axle (Let say X) the whole system rotates so when I later want to rotate around some other axle it have moved and the ship don’t rotate as I want.
Example:
I rotate 90 degrees around X this moves Y to where Z was and Z to where Y was.
If I now want to rotate around Z the ship will rotate around Y.
And that is NOT what I want! ! !
What I am trying to do is a Ship that:
Turn its Nose UP or Down (its own X) when key pressed, however it is turned in any way.
Rotates around its own Z when LEFT/RIGHT key is pressed
I realy need this!!
So please someone how to rotate around all axes in the same cordinate system.
Please help me...
me try this dont work:
glRotatef(rotX,1.0f,0.0f,0.0f);
glRotatef(rotY,0.0f,1.0f,0.0f); //wrong system
glRotatef(rotZ,0.0f,0.0f,1.0f); //even more wrong
DrawShip();
i want tha later 2 to rotate around the same as the first...
Help!!!!
So please someone how to rotate around all axes in the same cordinate system.
Please help me...
me try this dont work:
glRotatef(rotX,1.0f,0.0f,0.0f);
glRotatef(rotY,0.0f,1.0f,0.0f); //wrong system
glRotatef(rotZ,0.0f,0.0f,1.0f); //even more wrong
DrawShip();
i want tha later 2 to rotate around the same as the first...
Help!!!!
Sorry I don''t exactly understand what u want to do.. but I think what you SHOULD do, is make the camera translations using the projection matrix not the model matrix
and use the gluLookAt() function as u move the camera on the x axis around the ship (just make the LookAt() point to the spot where the ship is (5,2,6/x,y,z))
Tell me if that works
and use the gluLookAt() function as u move the camera on the x axis around the ship (just make the LookAt() point to the spot where the ship is (5,2,6/x,y,z))
Tell me if that works
![](tongue.gif)
How does gluLookAt(); work???
/******************************/
I have come to understand that the previous post was hard to understand so I will try to explain it more careful this time.
What I am trying to do:
- A spaceship simulator (mush like SpaceWars on NeHe’s Site witch by the way doesn’t work as I want either).
- Control the ship with the Arrow keys.
- The Arrow should represent the ship controls.
This means that if I pull back the controls (DOWN KEY), the ships nose should tilt UP.
And UP KEY should tilt the nose DOWN.
LEFT & RIGHT KEY should SPIN the ship.
- I want the camera to follow the ship.
- I want Asteroids to and they should rotate constantly in the same way.
Problems:
- If I use this for the ship it obviously don’t work.
And it doesn’t work better for the asteroids.
glPushMatrix();
glTranslate(shipXpos, shipYpos, shipZpos):
glRotatef(shipXrot, 1.0f, 0.0f, 0.0f);
glRotatef(shipYrot, 1.0f, 0.0f, 0.0f);
glRotatef(shipZrot, 1.0f, 0.0f, 0.0f);
DrawShip();
glPopMatrix();
Solutions:
- This is where I hoped you fill in.
Thanks you in advance…
/******************************/
I have come to understand that the previous post was hard to understand so I will try to explain it more careful this time.
What I am trying to do:
- A spaceship simulator (mush like SpaceWars on NeHe’s Site witch by the way doesn’t work as I want either).
- Control the ship with the Arrow keys.
- The Arrow should represent the ship controls.
This means that if I pull back the controls (DOWN KEY), the ships nose should tilt UP.
And UP KEY should tilt the nose DOWN.
LEFT & RIGHT KEY should SPIN the ship.
- I want the camera to follow the ship.
- I want Asteroids to and they should rotate constantly in the same way.
Problems:
- If I use this for the ship it obviously don’t work.
And it doesn’t work better for the asteroids.
glPushMatrix();
glTranslate(shipXpos, shipYpos, shipZpos):
glRotatef(shipXrot, 1.0f, 0.0f, 0.0f);
glRotatef(shipYrot, 1.0f, 0.0f, 0.0f);
glRotatef(shipZrot, 1.0f, 0.0f, 0.0f);
DrawShip();
glPopMatrix();
Solutions:
- This is where I hoped you fill in.
Thanks you in advance…
I think you should rotate then translate, but, IamQwerty, are you really doing you rotations as follows:
glRotatef(shipXrot, 1.0f, 0.0f, 0.0f);
glRotatef(shipYrot, 1.0f, 0.0f, 0.0f);
glRotatef(shipZrot, 1.0f, 0.0f, 0.0f);
Or, was that just a misprint? If it is the way you''re doing it, the correct way is as follows:
glRotatef(shipXrot, 1.0f, 0.0f, 0.0f);
glRotatef(shipYrot, 0.0f, 1.0f, 0.0f);
glRotatef(shipZrot, 0.0f, 0.0f, 1.0f);
Morgan
glRotatef(shipXrot, 1.0f, 0.0f, 0.0f);
glRotatef(shipYrot, 1.0f, 0.0f, 0.0f);
glRotatef(shipZrot, 1.0f, 0.0f, 0.0f);
Or, was that just a misprint? If it is the way you''re doing it, the correct way is as follows:
glRotatef(shipXrot, 1.0f, 0.0f, 0.0f);
glRotatef(shipYrot, 0.0f, 1.0f, 0.0f);
glRotatef(shipZrot, 0.0f, 0.0f, 1.0f);
Morgan
I have the same problem im making a Space Simulator too.
My code looks a little like this:
glLoadIdenity();
glRotatef(vert_angle,1,0,0);
glRotatef(hor_angle,0,1,0);
glTranslatef(xmove,ymove,zmove);
so heres the problem
if you start at a possition let say (0,0,10);
The rotation works like a charm...
Up is up and down is down, turning also works..
But when you move to lets say (0,0,0) and rotate 90 around the y axis...
The goddamn ships starts to roll instdead of climbing, but the turning works fine though...
gluLookAt is a pestersite to use if you ask me...
so if me and:
IamQwerty ask nicely maybe some guy with a big brain could help us nice guys!!
______________________________
ohh well what the heck lets try it?
My code looks a little like this:
glLoadIdenity();
glRotatef(vert_angle,1,0,0);
glRotatef(hor_angle,0,1,0);
glTranslatef(xmove,ymove,zmove);
so heres the problem
if you start at a possition let say (0,0,10);
The rotation works like a charm...
Up is up and down is down, turning also works..
But when you move to lets say (0,0,0) and rotate 90 around the y axis...
The goddamn ships starts to roll instdead of climbing, but the turning works fine though...
gluLookAt is a pestersite to use if you ask me...
so if me and:
IamQwerty ask nicely maybe some guy with a big brain could help us nice guys!!
______________________________
ohh well what the heck lets try it?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement