0% found this document useful (0 votes)
27 views2 pages

The Matrices For The Perspective

The document discusses the matrices used for perspective and viewing transforms in 3D graphics. It defines functions for calculating the perspective matrix P based on near and far clipping planes, as well as matrices C and V to represent the camera and viewing transforms based on the eye, up, and view vectors.

Uploaded by

Jose Rodriguez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views2 pages

The Matrices For The Perspective

The document discusses the matrices used for perspective and viewing transforms in 3D graphics. It defines functions for calculating the perspective matrix P based on near and far clipping planes, as well as matrices C and V to represent the camera and viewing transforms based on the eye, up, and view vectors.

Uploaded by

Jose Rodriguez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

The matrices for the perspective

Prototype functionality
1. Throw object
1. velocity
2. angle
3. ball can knock over elements
4. ball can miss elements
2. Roll object

1. velocity
2. angle
3. ball can knock over elements
4. ball can miss elements
2. Any other core actions we want to support? 

1. Select environment
2. Upload avatar 
3. Unlock different objects to throw/roll
o Show leaderboard and the ability to invite friends

Perspective and viewing


The matrices for the perspective and viewing transforms and how using shaders could be
defined.

void idle (void) {  

    hBuffer->getFrame(hFrame);
    if (hFrame->goodH && hFrame->timeStamp != timeStamp) {
        timeStamp = hFrame->timeStamp;
        std::cout << "(" << hFrame->eye.x << ", " <<
                    hFrame->eye.y << ", " <<
                    hFrame->eye.z << ") \n";

        eye = vec3(hFrame->eye.x, hFrame->eye.y, hFrame->eye.z);

        d_near = eye.z;
        d_far = eye.z + 50;
        P = mat4((2.0*d_near)/(right-left), 0, (right+left)/(right-left),
0, 
                 0, (2.0*d_near)/(top-bottom), (top+bottom)/(top-bottom),
0,
                 0, 0, -(d_far+d_near)/(d_far-d_near), -
(2.0*d_far*d_near)/(d_far-d_near),
                 0, 0, -1.0, 0);

        d_x = -(dot(eye, u));


        d_y = -(dot(eye, v));
        d_z = -(dot(eye, n));

        C = mat4(1.0, 0.0, 0.0, eye.x,


                 0.0, 1.0, 0.0, eye.y,
                 0.0, 0.0, 1.0, 0.0,
                 0.0, 0.0, 0.0, 1.0);

        V = mat4(u.x, u.y, u.z, d_x,


                 v.x, v.y, v.z, d_y,
                 n.x, n.y, n.z, d_z,
                 0.0, 0.0, 0.0, 1.0);

        MV = C * V;
        //MV = V;

        glutPostRedisplay();
    }
}

You might also like