250

# SER431 Lecture 06

Programming Activity 02
(201809)

## Javier Gonzalez-SanchezPRO

September 03, 2018

## Transcript

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

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

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);

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)
}

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

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

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

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

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();

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
// );

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

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

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);

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);

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

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)

17. jgs