Upgrade to Pro — share decks privately, control downloads, hide ads and more …

SER431 Lecture 06

SER431 Lecture 06

Advanced Graphics
Programming Activity 02
(201809)

Javier Gonzalez-Sanchez
PRO

September 03, 2018
Tweet

More Decks by Javier Gonzalez-Sanchez

Other Decks in Programming

Transcript

  1. jgs
    SER 431
    Advanced Graphics
    Lecture 06: Quiz 02
    Javier Gonzalez-Sanchez
    [email protected]
    PERALTA 230U
    Office Hours: By appointment

    View Slide

  2. Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 1
    jgs
    Quiz 01 Solution

    View Slide

  3. Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 2
    jgs
    texture.h
    § #include ”noise.h”
    § void codedTexture(UINT textureArray[], int n, int type)
    § float t_scale(float x)
    § Vec3f marbleMap(float a)
    § Vec3f skyMap(float a)
    § // ACTIVITY 1: add the lava/fire effect color-mapping
    § void loadBMP_custom(GLuint textures[], char *img_path, int n);

    View Slide

  4. Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 3
    jgs
    noise.h
    § #include
    § class ImprovedNoise {
    § double perlinMarble(float x, float y)
    § double perlinMultiscale(float x, float y)
    § // ACTIVITY 2: add the lava/fire ecuation
    § double noise(double x, double y, double z)
    }

    View Slide

  5. Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 4
    jgs
    mesh.h
    § struct Mesh
    § Mesh* loadFile(const char* file)
    § Mesh* createCube()
    § Mesh* createSkyBox(int w)
    § Mesh* createPlane(int width, int depth, int cell)
    § void calculateNormalPerFace(Mesh* m)
    § void calculateNormalPerVertex(Mesh* m)

    View Slide

  6. Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 5
    jgs
    mesh.h | cube vs skybox vertex

    View Slide

  7. Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 6
    jgs
    mesh.h | cube texture

    View Slide

  8. Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 7
    jgs
    mesh.h | skybox texture

    View Slide

  9. Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 8
    jgs
    render.h
    § GLuint meshToDisplayList(Mesh* mesh, int id, int texture)
    § glNewList(listID, GL_COMPILE);
    § glEnable(GL_TEXTURE_2D);
    § glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    § glBindTexture(GL_TEXTURE_2D, texture);
    § glBegin(GL_TRIANGLES);
    § for (/* for each triangle in a mesh */){
    § // normal
    § // texture
    § // color
    § }
    § glEnd();
    § glDisable(GL_TEXTURE_2D);
    § glEndList();

    View Slide

  10. Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 9
    jgs
    controls.h
    § float camera_x = 0.0;
    § float camera_y = 300.0;
    § float camera_z = 320.0;
    § float camera_viewing_x = 0.0;
    § float camera_viewing_y = 301.0;
    § float camera_viewing_z = 0.0;
    § float total_moving_angle = 0.0;
    // gluLookAt( camera_x, camera_y, camera_z,
    // camera_viewing_x, camera_viewing_y, camera_viewing_z,
    // 0.0f, 1.0f, 0.0f
    // );

    View Slide

  11. Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 10
    jgs
    Moving the Camera as a First Person Walk
    § Look up and down
    § Rotate Left or Right
    § Move forward or Backward

    View Slide

  12. Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 11
    jgs
    Up and Down
    § Look UP camera_viewing_y += (10);
    § Look DOWN camera_viewing_y -= (10);

    View Slide

  13. Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 12
    jgs
    Rotate Left and Rotate Right
    § Move LEFT total_moving_angle += -0.01;
    rotate_point(-0.01);
    § Move RIGHT total_moving_angle += 0.01;
    rotate_point(0.01);

    View Slide

  14. Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 13
    jgs
    Front and Back
    § Move FRONT camera_x += (10) * sin(total_moving_angle);
    camera_z += (10) * -cos(total_moving_angle);
    camera_viewing_x += (10)* sin(total_moving_angle);
    camera_viewing_z += (10)* -cos(total_moving_angle);

    View Slide

  15. Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 14
    jgs
    Quiz 01 Solution

    View Slide

  16. Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 15
    jgs
    Quiz 02
    § // Lava / fire texture around the space to avoid get closed to the walls
    § // Terrain at the center. Add altitude to the pain with stone texture
    § // What about making a cube able to move (rotate or something).
    // But, the terrain will not be plain (it is a non-flat surface)

    View Slide

  17. jgs
    SER431 Advanced Graphics
    Javier Gonzalez-Sanchez
    [email protected]
    Fall 2018
    Disclaimer. These slides can only be used as study material for the class SER431 at ASU. They cannot be
    distributed or used for another purpose.

    View Slide