1 Replies - 2933 Views - Last Post: 11 November 2012 - 06:42 AM Rate Topic: -----

#1 briddell  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 14-June 12

Generating a planet-esque surface to walk on - using C++ OpenGL

Posted 10 November 2012 - 10:28 PM

Hello! My dilemma is simple; I a making a game and am stuck. I have been programming C++ for ~1 year and just recently got into OpenGL. My game would be based around planets (small - not anything realistically sized - think Super Mario Galaxy planet sized) but I have no idea how to make a planet. So far, I can generate 3D spheres and things of that nature but I need, for when the character jumps, for the character to fall down to the curvature of the planet accordingly. How would I bind the player to the origin of the sphere so that this happens? I also am having troubles with my camera system. My current viewport system does not curve with the character's movement. If you could provide code or links to where I could learn such skills/techniques, that would be greatly appreciated. Thank you for your time.

-Brennan Riddell

Is This A Good Question/Topic? 0
  • +

Replies To: Generating a planet-esque surface to walk on - using C++ OpenGL

#2 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: Generating a planet-esque surface to walk on - using C++ OpenGL

Posted 11 November 2012 - 06:42 AM

Quote

for when the character jumps, for the character to fall down to the curvature of the planet accordingly


The curvature of the planet? How large is your character relative to the planet, and how high is he jumping??

From a jumping perspective, curvature of planet is irrelevant, really. You have a plane that represents the ground, and you simply accelerate your character toward the plane.

Quote

My current viewport system does not curve with the character's movement.
Is it because you attempted to write this in, and the net result is incorrect? Or do you not know what to do here at all?

You need to transform your eye view appropriately to look at an object. In a 2D view, that's just you positioning the view appropriately. In a 3D view, you need to rotate the camera. If you think of your camera as resting on a plane, with the plane tilted towards the object, then you have keep retilting this plane. You can do this by using cross products to recalculate the plane normal.

You can look at gluLookAt implementations online, or just google for how to point a camera at something. If you understand the matrix operations involved, then the math should make sense.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1