Hi there again. I have a little trouble with understanding how I would move a player with vectors. What I mean, where would I put what code in use to rotate and move into the desired direction?
I''ve rewritten a Camera class I once wrote, it uses the glLookAt function.. Now I want to put it use for my player.
I recon I would use glTranslatef and glRotatef to move and rotate, but as I said I''m not sure how I would figure this out.. Can somebody please help me out a little with this? any code example would be greatly appreaciated!
Thanks in advance
Kenneth Wilhelmsen
Try my little 3D Engine project, and mail me the FPS. WEngine
Or just visit my site
--------------------------
He who joyfully marches to music in rank and file has already earned my contempt. He has
been given a large brain by mistake, since for him the spinal cord would fully suffice. This
disgrace to civilization should be done away with at once. Heroism at command, senseless
brutality, deplorable love-of-country stance, how violently I hate all this, how despicable and ignoble war is; I would rather be torn to shreds than be a part of so base an action! It is my conviction that killing under the cloak of war is nothing but an act of murder
Playermovement.. and vectors
Correct me if I''m wrong, but your rendering method is something like :
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
my_camera.set_in world();
my_character.move();
my_character.draw_body();
...
you know what to write in my_camera.set_in_world() method (which uses gluLookAt).
you know what to write in my_character.draw_body() method.
and you would like to know what to write into my_character.move() method. is that right ?
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
my_camera.set_in world();
my_character.move();
my_character.draw_body();
...
you know what to write in my_camera.set_in_world() method (which uses gluLookAt).
you know what to write in my_character.draw_body() method.
and you would like to know what to write into my_character.move() method. is that right ?
Yes. that is pretty much what i want =)
I tried putting XY and Z coordinates into glTranslatef(X, Y, Z), from my player class.. but it always ended up with that my model always got sent away in one direction no matter what i tried to rotate it to.. and it was like speeding really fast in that direction too. I was really suprised of that result, never saw that one come.
it was something like this;
camerasetupandallthatbeforethis..
glTranslatef(playerX, playerY, playerZ);
Draw.playerModel();
...
playerModel''s coordinations is set to 0,0,0 by default.. because.. well, as you see.. it''s handled by glTranslatef
Kenneth Wilhelmsen
Try my little 3D Engine project, and mail me the FPS. WEngine
Or just visit my site
--------------------------
He who joyfully marches to music in rank and file has already earned my contempt. He has
been given a large brain by mistake, since for him the spinal cord would fully suffice. This
disgrace to civilization should be done away with at once. Heroism at command, senseless
brutality, deplorable love-of-country stance, how violently I hate all this, how despicable and ignoble war is; I would rather be torn to shreds than be a part of so base an action! It is my conviction that killing under the cloak of war is nothing but an act of murder
I tried putting XY and Z coordinates into glTranslatef(X, Y, Z), from my player class.. but it always ended up with that my model always got sent away in one direction no matter what i tried to rotate it to.. and it was like speeding really fast in that direction too. I was really suprised of that result, never saw that one come.
it was something like this;
camerasetupandallthatbeforethis..
glTranslatef(playerX, playerY, playerZ);
Draw.playerModel();
...
playerModel''s coordinations is set to 0,0,0 by default.. because.. well, as you see.. it''s handled by glTranslatef
Kenneth Wilhelmsen
Try my little 3D Engine project, and mail me the FPS. WEngine
Or just visit my site
--------------------------
He who joyfully marches to music in rank and file has already earned my contempt. He has
been given a large brain by mistake, since for him the spinal cord would fully suffice. This
disgrace to civilization should be done away with at once. Heroism at command, senseless
brutality, deplorable love-of-country stance, how violently I hate all this, how despicable and ignoble war is; I would rather be torn to shreds than be a part of so base an action! It is my conviction that killing under the cloak of war is nothing but an act of murder
X, Y and Z are world coordinates. You have to compute those coordinates every time the character moves.
> but it always ended up with that my model always got sent away in one direction no matter what i tried to rotate it to
You mean that your character is always facing, say, the North ?
If so, that is normal. You need to rotate the player around himself _after_ the translation.
> but it always ended up with that my model always got sent away in one direction no matter what i tried to rotate it to
You mean that your character is always facing, say, the North ?
If so, that is normal. You need to rotate the player around himself _after_ the translation.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement