OtagoOpenSource / GamesRepo

This is the repo for the games team.
4 stars 6 forks source link

Ability to move around a planet #12

Open lechszym opened 11 years ago

grimtastic commented 11 years ago

I have started this and anybody who checks out the code can try this out by pressing the P key to toggle it and using the W key to move the "player" sphere forward. Unfortunately it doesn't move in the direction of the camera at the moment. Making this work properly is pushing my abilities to the limit, I believe, so if there is anybody better suited, that would be great. Otherwise, I can just bite the bullet, push forward and learn what I'm doing.

lechszym commented 11 years ago

Is anyone working on this at the moment? If not, I might give it a try. Is the problem mostly quaternion related?

timatooth commented 11 years ago

I don't know how to do this but I will work on #13 and GUI for changing avatars.

It will be a simple model rigged with arms and legs that will have some animation sequences such as "walk" and "jump" which need to get fired upon key presses. I can set an origin of the model so that rotations are made about that origin - perhaps the feet or body/pelvis.

I think this might be helpful for someone to implement a 'chase camera' around the character for 3rd person. http://jmonkeyengine.org/wiki/doku.php/jme3:advanced:making_the_camera_follow_a_character

grimtastic commented 11 years ago

I was working on it, but I'm a bit busy now and not sure how much further I can go with it. My problem, which involved quaternions, was that I wasn't the player's view to stay fixed as the planet moved. So, for example, if the player is looking at the sun while the planet he or she is on rotates around it, the camera will always be looking at the sun. At the moment, the player is always looking in a direction, meaning when they have rotated 180 degrees around the sun, they will no longer be looking at the sun, but rather away from it.

The plan that I had was to use the "lookAt" method of the planet to "look at" the sun, so the planet was always looking in a direction relative to its orbit around the sun. Then, I would track the movement of the mouse and use it to create a rotation that could be added to the planet's rotation. Basically, if the mouse wasn't moved, the camera would always be facing the same direction as the planet, which would be towards the sun.

The problem I came up against was that setting the rotation of the camera requires using quaternions, which I didn't know how to use. Experimenting, I got really weird results. I don't know how well I have explained this.

Nevertheless, if you wish to take this task upon yourself, feel free.

grimtastic commented 11 years ago

Oh, wait. You are talking about movement. Movement didn't require quaternions at all. I have movement working. The only problem at the moment is that it's not completely obvious to me yet how to move in the direction the camera is facing. Because of this, the player doesn't move straight ahead, but rather in some other direction.

I think the code I have there is probably fine for movement, especially if moving from one planet to another is done by grappling hook. The main concerns would be:

  1. Having the camera's rotation be relative to the planet's orbit around the sun,
  2. Having the player move "forward" relative to the direction the camera is facing, and
  3. Preventing the camera from slipping through the planet. (And player, if that becomes an issue.)