Final Grade

비밀번호 중간고사 기말고사 출석 (20%) 중간고사 (30%) 기말고사 (30%) 실습1 실습2-0 실습2 실습3 실습총점20 실습 (20%) TOTAL
1001 25 42 19.667 7.5 12.6 10 2 3 0 5 10 49.767
1777 22 30 15.667 6.6 9 10 1 3 0 4.6667 9.3333 40.6
6062 12 20 17 3.6 6 0 0 0 0 0 0 26.6
1036 0 18 16.333 0 5.4 0 0 0 0 0 0 21.733
830 19 13 18.667 5.7 3.9 0 0 0 0 0 0 28.267
4290 65 54 20 19.5 16.2 10 2 10 8 10 20 75.7
1302 50 55 20 15 16.5 10 2 3 0 5 10 61.5
1932 41 56 20 12.3 16.8 10 2 10 10 10.667 21.333 70.433
9376 27 29 18.667 8.1 8.7 0 2 0 0 0.6667 1.3333 36.8

Final Exam

기말고사

일시: 2016년 12월 16일 (금) 10:00-12:00

장소: 2공 521호

범위: 중간고사문제 포함 – 중간고사 이후 배운데까지 (수업블로그와 예제 중심으로)

 

Billboarding & AlphaBlendTextures

Billboarding & AlphaBlendTextures

lab16-BillboardingTextureShadedQuad2

 

yaw
Look

// create a axis-aligned billboard matrix
void buildAxisAlignedBillboardMatrix(glm::mat4& m, glm::vec3& axis)
{
// calculate “-yaw” angle from View matrix (Look.x, Look.z)
float theta = -atan2f(m[0][2], m[2][2]);

float ct = cosf(theta);
float st = sinf(theta);

// normalize
axis = glm::normalize(axis);

// clear out the view matrix passed in
m = glm::mat4(1.0f);

//———————————————
// R = uu’ + cos(theta)*(I-uu’) + sin(theta)*S
//
// S =  0  -z   y    u’ = (x, y, z)
//     z   0  -x
//    -y   x   0
//———————————————
// calculate “Rotation” matrix using “axis” & “theta”
m[0][0] = axis[0] * axis[0] + ct*(1 – axis[0] * axis[0]) ;
m[0][1] = axis[0] * axis[1] + ct*(0 – axis[0] * axis[1]) + st*(-axis[2]);
m[0][2] = axis[0] * axis[2] + ct*(0 – axis[0] * axis[2]) + st*axis[1];

m[1][0] = axis[1] * axis[0] + ct*(0 – axis[1] * axis[0]) + st*axis[2];
m[1][1] = axis[1] * axis[1] + ct*(1 – axis[1] * axis[1]) ;
m[1][2] = axis[1] * axis[2] + ct*(0 – axis[1] * axis[2]) + st*(-axis[0]);

m[2][0] = axis[2] * axis[0] + ct*(0 – axis[2] * axis[0]) + st*(-axis[1]);
m[2][1] = axis[2] * axis[1] + ct*(0 – axis[2] * axis[1]) + st*axis[0];
m[2][2] = axis[2] * axis[2] + ct*(1 – axis[2] * axis[2]) ;
}

Billboard가 활성화가 되지 않은 상태 (카메라의 시점이 회전된 상태에 따라 알파텍스쳐 나무가 원래 위치한대로 그대로 유지함)

nobillboard

 

Billboard가 활성화된 상태 (카메라의 시점이 회전된 상태라 해도 알파텍스쳐 나무가 내 시점을 향하여 바라보는 상태를 유지함)

billboard

 

 

Blending Filter

Blending filter

lab16-BlendFilterTextureShadedQuad2

glEnable(GL_BLEND);
if (g_filter == 0) // Default (no blending) = Cs*1
glBlendFunc(GL_ONE, GL_ZERO);
else if (g_filter == 1) // Draw background only = Cd*1
glBlendFunc(GL_ZERO, GL_ONE);
else if (g_filter == 2) // Cs*1 + Cd*1
glBlendFunc(GL_ONE, GL_ONE);
else if (g_filter == 3) // Alpha blending (back-to-front) = Cs*As + Cd*(1-As)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
else if (g_filter == 4) // brighten the scene = Cs*As + Cd*1
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
else if (g_filter == 5) // Modulate blending = Cd*Cs
glBlendFunc(GL_ZERO, GL_SRC_COLOR);
else if (g_filter == 6) // darken the scene = Cd*As
glBlendFunc(GL_ZERO, GL_SRC_ALPHA);
else if (g_filter == 7) // Invert all the colors = Cs*(1-Cd)
glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO);
Default (no blending)
noblending

Draw background only

backgroundonly

Add blending

addblending

Alpha blending

alphablending

Brighten the scene

additiveblending

Modulate blending

modulateblending

Darken the scene

darken

Invert all the colors

invert

lab14-TextureShadedQuad-FilteringWrappingAnimation

lab14-TextureShadedQuad-FilteringWrappingAnimation

animatedTexture (flipbook animation)

animatedTexture

texture filtering
// LL mag nearest – min nearest
// LR mag linear – min linear
// UL mag linear – min linear – mipmap nearest
// UR mag linear – min linear – mipmap linear

textureFiltering

texture wrapping – texCoords LL(-1, -1), LR(3, -1), UL(-1, 3), UR(3, 3)
// LL CLAMP
// LR CLAMP_TO_EDGE
// UL REPEAT
// UR MIRRORED_REPEAT
textureWrapping

lab13-textureShadedGeometryCone

Cone class (다각뿔 클래스)

lab13-TextureShadedGeometry-Pyramid2

Pyramid

void Cone::init()
{
numVertices = 0;
glm::vec3 n(0.0f, 0.0f, 0.0f);
float xTexCoord = 0.0f;
float dslice = 1.0f / slices;

float theta = (float)(2 * M_PI / slices);
for (int i = 0; i < slices; i++)
{
glm::vec3 v1, v2, v3;
// V1
v1[0] = p[0];
v1[1] = p[1] + height;
v1[2] = p[2];
// V2
v2[0] = p[0] + radius * cosf(theta * i);
v2[1] = p[1];
v2[2] = p[2] + radius * sinf(theta * i);
// V3
v3[0] = p[0] + radius * cosf(theta * ((i + 1) % slices));
v3[1] = p[1];
v3[2] = p[2] + radius * sinf(theta * ((i + 1) % slices));
// Normal
glm::vec3 n = glm::cross((v2-v1), (v3-v1));
n = glm::normalize(n);
printf(“V1: %f %f %f\n”, v1[0], v1[1], v1[2]);
printf(“V2: %f %f %f\n”, v2[0], v2[1], v2[2]);
printf(“V3: %f %f %f\n”, v3[0], v3[1], v3[2]);
printf(“N: %f %f %f\n\n”, n[0], n[1], n[2]);

// V1
vbo.addData(&v1, sizeof(glm::vec3)); // vertex position
vbo.addData(&glm::vec2(xTexCoord + dslice * 0.5f, 1.0f), sizeof(glm::vec2)); // vertex texture coordnate (TopCenter)
vbo.addData(&n, sizeof(glm::vec3)); // vertex normal
// V2
vbo.addData(&v2, sizeof(glm::vec3)); // vertex position
vbo.addData(&glm::vec2(xTexCoord, 0.0f), sizeof(glm::vec2)); // vertex texture coordnate
vbo.addData(&n, sizeof(glm::vec3)); // vertex normal
// V3
vbo.addData(&v3, sizeof(glm::vec3)); // vertex position
vbo.addData(&glm::vec2(xTexCoord + dslice, 0.0f), sizeof(glm::vec2)); // vertex texture coordnate
vbo.addData(&n, sizeof(glm::vec3)); // vertex normal

xTexCoord += dslice; // increment texCoord
numVertices += 3;
}

createVAO();
isLoaded = true;
}