home :: about :: development guides :: irc :: forums :: search :: paste :: links :: contribute :: code dump

-> Click here to learn how to get live help <-

New Paste :: Recent Pastes:: Add Line Numbers

view always gets bigger by daveyand
Here is the biut where io check to see if i am in a hill:

    //check to make sure the camera is not inside the hills
    if( cam_pos.y < heightMapArray[(int)cam_pos.x][(int)cam_pos.z] + 10){

        float tmpYpos, var;
        printf("cam_pos.x = %d\n",(int)cam_pos.x);
        printf("cam_pos.y = %d\n",(int)cam_pos.y);
        printf("cam_pos.z = %d\n",(int)cam_pos.z);
        printf("Height at that point: %d\n", (int)heightMapArray[(int)cam_pos.x][(int)cam_pos.z] );

        tmpYpos = ( heightMapArray[(int)cam_pos.x][(int)cam_pos.z] ) + 20;

        printf("tmpYpos = %d\n",(int)tmpYpos);

        //make sure the view wont go to funky when i change this
        var = tmpYpos - cam_pos.y;

        //set the view to the var
        cam_view.y += var;
        printf("Cam_view.y: %d\n",(int)cam_view.y);

        //redisplay the camera
        gluLookAt(cam_pos.x, tmpYpos ,cam_pos.z,cam_view.x,cam_view.y,cam_view.z,0,1,0);

    }else{//if camera


This bit is the camera function which changes the view and position of the camera when i zoom

// v-- zoom camera moves the camera and viewing position towards or away.

void camera_zoom(float speed){
    float normaled;
    COORDS look;
    //work out where the camera is looking, same calculation as the distance from the sun
    //only using the camera position and view coords
    look.x = cam_view.x - cam_pos.x;
    look.y = cam_view.y - cam_pos.y;
    look.z = cam_view.z - cam_pos.z;
    //normalise the increment, this is to avoid massive increase or decrese in zoom
    normaled = math_calcMag(look);
    look.x /= normaled;
    look.y /= normaled;
    look.z /= normaled;

    //move the x and z position of camera, but check against the heightmap array to get the right height
    cam_pos.x += look.x * speed;
    cam_pos.y += look.y * speed;
    cam_pos.z += look.z * speed;

    //move the x and z view of camera aswell to create a stable view
       cam_view.x += look.x * speed;
    cam_view.y += look.y * speed;
    cam_view.z += look.z * speed;    

// ^-- zoom camera moves the camera and viewing position towards or away.