Part of the Khronos Group
OpenGL.org

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

Hybrid View

  1. #1
    Intern Contributor uwi2k2's Avatar
    Join Date
    Mar 2011
    Posts
    98

    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 ??

    thanx
    uwi2k2
    uwi2k2 - OpenGL Trainer: www.opengl-trainer.com
    ---------------------------------------------------------
    Free Programming Helpline: www.programming-hotline.com
    ---------------------------------------------------------
    A Friday Night Programmer: www.uwiworld.net

  2. #2
    Junior Member Newbie
    Join Date
    May 2012
    Posts
    17
    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
  •