3D Computer Graphics Pipeline

Nov 28 2022 Computer Graphics Course Project C++ OpenGLUT

I read the files and complete the following instructions. There are many test data in the forder and many input commands in each test data. Otherwise, the program would delete the graphic that is backward from camera.

🔗 See more details here.

Operating instructions

  • The instruction is Width Height
    In the head of the files will give 2 integrals that represent the windows’ width and height respectively.

  • Comment:

    The instruction is # ......
    If # appears, skip the line. (i.e. You don’t need to execute the line which # appears.)

  • Reset:

    The instruction is reset
    Reset the transformation matrix.

  • Translate:

    The instruction is translate x y z
    x means moving along x-axis by x unit.
    y means moving along y-axis by y unit.
    z means moving along z-axis by z unit.

  • Scale:

    The instruction is scale x y z
    x means scaling along x-axis by x unit.
    y means scaling along y-axis by y unit.
    z means scaling along z-axis by z unit.

  • Rotate:

    The instruction is rotate x y z
    x means rotating along x-axis by x degree.
    y means rotating along y-axis by y degree.
    z means rotating along z-axis by z degree.
    The rotating part should be implement in the order of y-axis -> z-axis -> x-axis.

  • Clear data:

    The instruction is clearData
    Clear the objects that you read from .obj file.

  • Clear screen:

    The instruction is clearScreen
    Clear the screen.

  • Observe:

    The instruction is observe epx epy epz COIx COIy COIz Tilt Hither Yon Hav
    Set the camera’s parameter:

    1. epx epy epz are the x y z position of the camera.
    2. COIx COIy COIz are the point that the camera look at.
    forward = COI - ep
    
    1. Tilt is the angle that the camera tilt.
    2. Hither Yon are the near plane position and far plane position.
    3. Hav is field of view.
  • Viewport:

    The instruction is view vxl vxr vyb vyt
    Since the perspective divide, all graphic will lies in [-1, 1] X [-1, 1].
    -1 1 -1 1 means the left, right, botton, top boundary after perspective divide.
    vxl vxr vyb vyt means the left, right, botton, top boundary of viewport after perspective divide.

    In math words

      f(-1, 1) = (0, Width)
      f(-1, 1) = (0, Height)
    

    where it is a linear transformation.
    The objects outside the viewport boundary need to clipped.
    Need to display the graphic in display.

  • Object:

    The instruction is object **.obj
    The **.obj means the name of the files. Please load the document into your code and also slice square into triangles.

  • Display:

    The instruction is display
    Do the clearScreen when display is occured.
    Draw the boundary of objects with points and lines.
    Add fgetc(stdin); when display.

  • End:

    The instruction is end
    Destory the window.

Results