Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Walking on a sphere

  1. #1
    Junior Member Regular Contributor uwi2k2's Avatar
    Join Date
    Mar 2011

    Walking on a sphere

    hi all,

    i did some games where you are walking around a map.
    but the map was always somehow flat + some ups and downs.

    but now i started to think about walking on a sphere and my head starts to burn..
    i canīt even get the right idea how to start.

    for the flat land i normally do:
    Code :
    //walking forward
        yrotrad = (yrot / 180 * 3.141592654f);
        xrotrad = (xrot / 180 * 3.141592654f);
        xpos += float(sin(yrotrad))/8 ;
        zpos -= float(cos(yrotrad))/8 ;
    /// camera looking ahead
        if( xrot > 90 ) xrot = 90;
        if( xrot < -90 ) xrot = -90;
        yrotrad = (yrot / 180 * 3.141592654f);
        xrotrad = (xrot / 180 * 3.141592654f);
        gluLookAt(  xpos, ypos, zpos,
                    xpos+float(sin(yrotrad)*1.0), ypos-float(sin(xrotrad)*1.0)*yMultiplyer, zpos-float(cos(yrotrad)*1.0), 
                    0.0, 1.0, 0.0 );

    but how would i need to do this for wlaking on a shpere ??

    uwi2k2 - OpenGL Trainer:
    The OpenGL and VULKAN Podcast ( OpenGL2GO ) : OpenGL & Vulkan Podcast
    --------------------------------------------------------- - Indie TeamUp

  2. #2
    Intern Newbie
    Join Date
    May 2012
    Movement is always projected along a straight line, flat or curved.
    I would calculate the tangent at the current position and move along that.
    If you're jumping on a sphere, use a gravity vector pointed toward the center of the sphere to push you down.
    Since you're moving on a sphere, the gravity vector will need to be updated every frame.
    And restrict your position to the radius of the sphere if falling below it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts