Báo cáo môn đồ họa máy tính (Mô phỏng hoạt động một số đồ chơi bằng gỗ trẻ em)

22 40 3
Báo cáo môn đồ họa máy tính (Mô phỏng hoạt động một số đồ chơi bằng gỗ trẻ em)

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

TRƯỜNG ĐẠI HỌC CÔNG NGHIỆP HÀ NỘI KHOA CÔNG NGHỆ THƠNG TIN - - BÀI TẬP NHĨM HỌC PHẦN ĐỒ HỌA MÁY TÍNH ĐỀ TÀI: MƠ PHỎNG HOẠT ĐỘNG MỘT SỐ ĐỒ CHƠI BẰNG GỖ CỦA TRẺ EM Giảng viên hướng dẫn: Ths Vũ Minh Yến Nhóm: Sinh viên thực hiện: Trần Chí Luân Đào Hải Nam Nguyễn Văn Ninh Hà Nội – Năm 2021 Mục lục MỞ ĐẦU Đồ họa máy tính phương pháp công nghệ dùng việc chuyển đổi qua lại liệu hình ảnh máy tính Đồ họa máy tính lĩnh vực khoa học máy tính nghiên cứu tốn học, thuật toán kĩ thuật phép tạo, hiển thị điều khiển hình ảnh hình máy tính Đồ họa máy tính có liên quan nhiều đến số lĩnh vực đại số, hình học giải tích, hình học họa hình, quang học, kĩ thuật máy tính, đặc biệt chế tạo phần cứng (các loại hình, thiết bị xuất, nhập, vỉ mạch đồ họa ) Ngày nay, Đồ họa máy tính ứng dụng rộng rãi nhiều lĩnh vực khoa học, kỹ thuật, nghệ thuật, kinh doanh, quản lí, … Các ứng dụng đồ họa đa dạng, phong phú phát triển liên tục khơng ngừng Là sinh viên chúng em tìm hiểu làm quen với số kĩ thuật đồ họa máy tính thơng qua tài liệu, giảng cô giáo Vũ Minh Yến giảng dạy Với kiến thức học tìm hiểu chúng em định chọn đề tài: Mô hoạt động số đồ chơi gỗ trẻ em theo OpenGL đại CHƯƠNG MƠ TẢ BÀI TỐN 1.1 Giới thiệu đề tài Đồ chơi gỗ đồ vật chơi trẻ em hoạt động giải trí, giúp cho trẻ em rèn luyện nhiều kĩ phát triển Đồ chơi gỗ thường có nét tiêu biểu dạng khái quát, tái hoạt động tương ứng đồ vật Ví dụ đồn tàu gỗ, chong chóng, máy bay trực thăng gỗ, … Đồ chơi gỗ vật dụng quen thuộc phổ biến với trẻ em Do nhóm chúng em định chọn đồ chơi gỗ trẻ em gồm có: Đồn tàu gỗ, chong chóng, máy bay gỗ xe tăng gỗ để thực đề tài 1.2 Mơ tả mơ hình kịch 1.2.1 Đồn tàu gỗ Hình 1-1 Đồn tàu gỗ - Mơ hình đồn tàu gỗ: +Toa 1: Đầu tàu, buồng lái, ống khói, khung tàu, bánh xe +Toa 2: Khung tàu, buồng chở khách, bánh xe +Toa 3: Khung tàu, buồng chở khách, bánh xe - Mơ hoạt động: Cả đồn tàu chuyển động phía trước (theo chiều -Ox) phía sau (theo chiều +Ox) - Ý tưởng dụng mơ hình: Ta dựng mơ hình đồn tàu từ hình học đơn giản +Dùng hình lập phương để làm buồng lái, khung tàu +Dùng hình trụ trịn để làm bánh xe, ống khói +Dùng hình bán trụ để làm đầu tàu 1.2.2 Chong chóng Hình 1-2 Chong chóng gỗ - Mơ hình chong chóng gỗ: +Thân: trụ đúng, trụ ngang đỡ cánh quạt +Quạt: cánh - Mơ hoạt động: Quạt chong chóng quay (theo trục Oz) chiều kim đồng hồ - Tồn phận chong chóng dùng hình lập phương để xây dựng 1.2.3 Máy bay gỗ Hình 1-3 Máy bay gỗ - Mơ hình máy bay gỗ: +Thân: hình trụ trịn +Đi: gồm hình lăng trụ tam giác ghép với thân +Cánh: hình lập phương ghép với hình trụ trịn +Bánh: làm từ hình trụ trịn +Cánh quạt: làm từ hình lập phương ghép vào thân trục quay - Chuyển động: Máy bay chạy phía trước theo trục Ox, đồng thời cánh quát quay 360 độ theo chiều kim đồng hồ 1.2.4 Xe tăng gỗ Hình 1-4 Xe tăng gỗ - Mơ hình xe tăng gỗ + Thân xe: làm từ hình lập phương + Bánh xe: gồm bánh xe làm từ hình trụ trịn + Pháo: làm từ hình trụ trịn ghép với khối lập phương quay 360 độ - Chuyển động: Xe tăng chạy phía trước đồng thời nịng pháo quay quanh trục Oy 360 độ 1.2.5 Điều khiển - Khi nhấn phím “c” tất đối tượng bắt đầu chuyển động đồng thời - Để điều khiển góc nhìn camera, sử dụng phim: “x”, “X”, “y”, “Y”, “z”, “Z” CHƯƠNG MỘT SỐ KỸ THUẬT ĐIỂN HÌNH PHÁT TRIỂN CHƯƠNG TRÌNH 2.1 Thiết kế cài đặt: Đồn tàu gỗ 2.1.1 Mơ hình phân cấp 2.1.2 Kỹ thuật cài đặt mat4 instance_tau; GLfloat vitri_tau = -0.5; void toa_1() { mat4 instance; //Gam xe instance = Translate(-0.5+vitri_tau, 0.0, 0.0 + vitri_tau)*Scale(0.5, 0.2, 0.3); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_tau*instance); glDrawArrays(GL_TRIANGLES, 0, Index); //buong lai instance = Translate(-0.375 + vitri_tau, 0.2, 0.0 + vitri_tau)*Scale(0.25, 0.25, 0.3); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_tau*instance); glDrawArrays(GL_TRIANGLES, 0, Index); //dau xe instance = Translate(-0.6 + vitri_tau, 0.1, 0.0 + vitri_tau)*Scale(0.5, 0.45, 0.5); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_tau*instance); glDrawArrays(GL_TRIANGLES, Index_Trutron, Index_bantru Index_Trutron); //ong khoi instance = Translate(-0.6 + vitri_tau, 0.325, 0.0 + vitri_tau)*Scale(0.2, 0.5, 0.2); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_tau*instance); glDrawArrays(GL_TRIANGLES, Index, Index_Trutron - Index); //banh xe instance = Translate(-0.65 + vitri_tau, -0.1, 0.175 + vitri_tau)*RotateX(90)*Scale(0.4, 0.1, 0.4); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_tau*instance); glDrawArrays(GL_TRIANGLES, Index, Index_Trutron - Index); instance = Translate(-0.35 + vitri_tau, -0.1, 0.175 + vitri_tau)*RotateX(90)*Scale(0.4, 0.1, 0.4); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_tau*instance); glDrawArrays(GL_TRIANGLES, Index, Index_Trutron - Index); instance = Translate(-0.65 + vitri_tau, -0.1, -0.175 + vitri_tau)*RotateX(90)*Scale(0.4, 0.1, 0.4); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_tau*instance); glDrawArrays(GL_TRIANGLES, Index, Index_Trutron - Index); instance = Translate(-0.35 + vitri_tau, -0.1, -0.175 + vitri_tau)*RotateX(90)*Scale(0.4, 0.1, 0.4); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_tau*instance); glDrawArrays(GL_TRIANGLES, Index, Index_Trutron - Index); } void toa_2() { mat4 instance; //Mối nối Toa instance = Translate(-0.2 + vitri_tau, 0.0, 0.0 + vitri_tau)*RotateZ(90)*Scale(0.2, 0.2, 0.2); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_tau*instance); glDrawArrays(GL_TRIANGLES, Index, Index_Trutron - Index); //gam xe instance = Translate(0.05 + vitri_tau, 0.0, 0.0 + vitri_tau)*Scale(0.5, 0.2, 0.3); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_tau*instance); glDrawArrays(GL_TRIANGLES, 0, Index); //toa instance = Translate(0.05 + vitri_tau, 0.2, 0.0 + vitri_tau)*Scale(0.4, 0.2, 0.3); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_tau*instance); glDrawArrays(GL_TRIANGLES, 0, Index); //banh xe instance = Translate(-0.1 + vitri_tau, -0.1, 0.175 + vitri_tau)*RotateX(90)*Scale(0.4, 0.1, 0.4); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_tau*instance); glDrawArrays(GL_TRIANGLES, Index, Index_Trutron - Index); instance = Translate(0.2 + vitri_tau, -0.1, 0.175 + vitri_tau)*RotateX(90)*Scale(0.4, 0.1, 0.4); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_tau*instance); glDrawArrays(GL_TRIANGLES, Index, Index_Trutron - Index); instance = Translate(-0.1 + vitri_tau, -0.1, -0.175 + vitri_tau)*RotateX(90)*Scale(0.4, 0.1, 0.4); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_tau*instance); glDrawArrays(GL_TRIANGLES, Index, Index_Trutron - Index); instance = Translate(0.2 + vitri_tau, -0.1, -0.175 + vitri_tau)*RotateX(90)*Scale(0.4, 0.1, 0.4); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_tau*instance); glDrawArrays(GL_TRIANGLES, Index, Index_Trutron - Index); } void toa_3() { mat4 instance; //moi noi instance = Translate(0.35 + vitri_tau, 0.0, 0.0 + vitri_tau)*RotateZ(90)*Scale(0.2, 0.2, 0.2); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_tau*instance); glDrawArrays(GL_TRIANGLES, Index, Index_Trutron - Index); //gam xe instance = Translate(0.6 + vitri_tau, 0.0, 0.0 + vitri_tau)*Scale(0.5, 0.2, 0.3); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_tau*instance); glDrawArrays(GL_TRIANGLES, 0, Index); //buong lai instance = Translate(0.6 + vitri_tau, 0.2, 0.0 + vitri_tau)*Scale(0.4, 0.2, 0.3); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_tau*instance); glDrawArrays(GL_TRIANGLES, 0, Index); //banh xe instance = Translate(0.45 + vitri_tau, -0.1, 0.175 + vitri_tau)*RotateX(90)*Scale(0.4, 0.1, 0.4); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_tau*instance); glDrawArrays(GL_TRIANGLES, Index, Index_Trutron - Index); instance = Translate(0.75 + vitri_tau, -0.1, 0.175 + vitri_tau)*RotateX(90)*Scale(0.4, 0.1, 0.4); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_tau*instance); glDrawArrays(GL_TRIANGLES, Index, Index_Trutron - Index); instance = Translate(0.45 + vitri_tau, -0.1, -0.175 + vitri_tau)*RotateX(90)*Scale(0.4, 0.1, 0.4); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_tau*instance); glDrawArrays(GL_TRIANGLES, Index, Index_Trutron - Index); instance = Translate(0.75 + vitri_tau, -0.1, -0.175 + vitri_tau)*RotateX(90)*Scale(0.4, 0.1, 0.4); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_tau*instance); glDrawArrays(GL_TRIANGLES, Index, Index_Trutron - Index); } // Thông số chuyển động cho đoàn tàu GLfloat tau_chay = 0; GLfloat x_tau = 0, y_tau = 0, z_tau = 0; //Biến dùng cho keyboard void Doantau() { instance_tau = Translate(tau_chay, 0.0, 0.0) *RotateY(40)*RotateX(x_tau)*RotateY(y_tau)*RotateZ(z_tau); toa_1(); toa_2(); toa_3(); } 10 2.2 Thiết kế cài đặt: Chong chóng 2.2.1 Mơ hình phân cấp 2.2.2 Kỹ thuật cài đặt mat4 instance_chongchong; GLfloat vitri_chongchong = 1.0; GLfloat h = 0.5, w = 0.05; GLfloat dai = 0.25, rong = 0.05, day = 0.01; void than_chongchong() { mat4 instance; instance = Translate(0.0, 0.5*h, 0.0 + vitri_chongchong)*Scale(w, h, w); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_chongchong*instance); glDrawArrays(GL_TRIANGLES, 0, Index); instance = Translate(0.0, h, 0.25*h + vitri_chongchong)*Scale(w, w, 0.5*h); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_chongchong*instance); glDrawArrays(GL_TRIANGLES, 0, Index); } void quat_chongchong() { //canh tren mat4 instance; instance = Translate(0.0, 0.5*dai, 0.5*h + vitri_chongchong)*Scale(rong, dai, day); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_chongchong*instance); glDrawArrays(GL_TRIANGLES, 0, Index); 11 instance = Translate(0.5*dai - 0.5*w, -w, 0.5*h + vitri_chongchong)*RotateZ(-30)*Scale(dai, rong, day); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_chongchong*instance); glDrawArrays(GL_TRIANGLES, 0, Index); instance = Translate(-0.5*dai + 0.5*w, -w, 0.5*h + vitri_chongchong)*RotateZ(30)*Scale(dai, rong, day); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_chongchong*instance); glDrawArrays(GL_TRIANGLES, 0, Index); } // Các thông số chuyển động cho chong chóng GLfloat quat_chongchong_quay = 0; GLfloat x_chong = 0, y_chong = 0; //Biến dùng cho keyboard void Chongchong() { instance_chongchong = RotateY(45) *RotateX(x_chong)*RotateY(y_chong); than_chongchong(); instance_chongchong *= Translate(0.0, h, 0.0)*RotateZ(quat_chongchong_quay); quat_chongchong(); } 12 2.3 Thiết kế cài đặt: Máy bay gỗ 2.3.1 Mơ hình phân cấp 2.3.2 Kỹ thuật cài đặt mat4 instance_maybay; GLfloat vitri_maybay = -0.5; void than_maybay() { mat4 instance; instance = Translate(0.0, 0.0 + vitri_maybay, 0.0)*RotateZ(- 90); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_maybay*instance); glDrawArrays(GL_TRIANGLES, Index_bantru, Index_chopcut Index_bantru); instance = Translate(-0.6, 0.0 + vitri_maybay, 0)*RotateZ(90)*Scale(0.25, 0.5, 0.25); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_maybay*instance); glDrawArrays(GL_TRIANGLES, Index, Index_Trutron - Index); //Canh duoi instance = Translate(-0.25, -0.25 + vitri_maybay, 0.0)*Scale(0.3, 0.02, 1.7); 13 glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_maybay*instance); glDrawArrays(GL_TRIANGLES, 0, Index); //Canh tren instance = Translate(-0.25, 0.25 + vitri_maybay, 0.0)*Scale(0.3, 0.02, 1.7); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_maybay*instance); glDrawArrays(GL_TRIANGLES, 0, Index); // Khung đỡ cánh instance = Translate(-0.15, 0.0 + vitri_maybay, 0.5)*Scale(0.1, 1.0, 0.1); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_maybay*instance); glDrawArrays(GL_TRIANGLES, Index, Index_Trutron - Index); instance = Translate(-0.35, 0.0 + vitri_maybay, 0.5)*Scale(0.1, 1.0, 0.1); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_maybay*instance); glDrawArrays(GL_TRIANGLES, Index, Index_Trutron - Index); instance = Translate(-0.15, 0.0 + vitri_maybay, -0.5)*Scale(0.1, 1.0, 0.1); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_maybay*instance); glDrawArrays(GL_TRIANGLES, Index, Index_Trutron - Index); instance = Translate(-0.35, 0.0 + vitri_maybay, -0.5)*Scale(0.1, 1.0, 0.1); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_maybay*instance); glDrawArrays(GL_TRIANGLES, Index, Index_Trutron - Index); //Đuôi máy bay instance = Translate(0.6, 0.25 + vitri_maybay, 0.0)*Scale(0.7, 0.7, 1.0); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_maybay*instance); glDrawArrays(GL_TRIANGLES, Index_chopcut, Index_tamgiac - 1); instance = Translate(0.37, 0.0 + vitri_maybay, 0.2)*RotateY(225)*RotateX(270)*Scale(1.2, 1.2, 1.0); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_maybay*instance); glDrawArrays(GL_TRIANGLES, Index_chopcut, Index_tamgiac - 1); //2 khung xe sau instance = Translate(0.3, -0.2 + vitri_maybay, 0.0)*Scale(0.15, 0.45, 0.15); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_maybay*instance); glDrawArrays(GL_TRIANGLES, Index, Index_Trutron - Index); 14 instance = Translate(0.3, -0.3 + vitri_maybay, 0.0)*RotateX(90)*Scale(0.15, 0.45, 0.15); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_maybay*instance); glDrawArrays(GL_TRIANGLES, Index, Index_Trutron - Index); //khung xe truoc instance = Translate(-0.5, -0.3 + vitri_maybay, -0.1)*RotateZ(10)*RotateX(40)*Scale(0.15, 0.6, 0.15); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_maybay*instance); glDrawArrays(GL_TRIANGLES, Index, Index_Trutron - Index); instance = Translate(-0.5, -0.3 + vitri_maybay, 0.1)*RotateZ(10)*RotateX(-40)*Scale(0.15, 0.6, 0.15); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_maybay*instance); glDrawArrays(GL_TRIANGLES, Index, Index_Trutron - Index); } void banh_xe_sau1() { mat4 instance; instance = RotateX(90)*Scale(0.35, 0.15, 0.35); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_maybay*instance); glDrawArrays(GL_TRIANGLES, Index, Index_Trutron - Index); } void banh_xe_sau2() { mat4 instance = RotateX(90)*Scale(0.35, 0.15, 0.35); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_maybay*instance); glDrawArrays(GL_TRIANGLES, Index, Index_Trutron - Index); } void banh_xe_truoc1() { mat4 instance = RotateX(90)*Scale(0.5, 0.15, 0.5); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_maybay*instance); glDrawArrays(GL_TRIANGLES, Index, Index_Trutron - Index); } void banh_xe_truoc2() { mat4 instance = RotateX(90)*Scale(0.5, 0.15, 0.5); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_maybay*instance); glDrawArrays(GL_TRIANGLES, Index, Index_Trutron - Index); } void quat_maybay() 15 { mat4 instance; instance = Translate(0.0, 0.0, 0.0)*RotateX(45)*Scale(0.02, 1.0, 0.25); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_maybay*instance); glDrawArrays(GL_TRIANGLES, 0, Index); } // Các thông số chuyển động cho máy bay GLfloat maybay_chay = 0; GLfloat banh_maybay_quay = 0, quat_maybay_quay = 0; void Maybay() { instance_maybay = Translate(maybay_chay, 0.0 + vitri_maybay, 0.0)*RotateY(30)*RotateZ(-10); than_maybay(); instance_maybay *= Translate(0.35, -0.3 + vitri_maybay, 0.1)*RotateZ(banh_maybay_quay); banh_xe_sau1(); instance_maybay *= Translate(0.0, 0.0, -0.2)*RotateZ(banh_maybay_quay); banh_xe_sau2(); instance_maybay = Translate(maybay_chay, 0.0 + vitri_maybay, 0.0)*RotateY(30)*RotateZ(-10); instance_maybay *= Translate(-0.5, -0.4 + vitri_maybay, 0.2)*RotateZ(banh_maybay_quay); banh_xe_truoc1(); instance_maybay *= Translate(0.0, 0.0, -0.4)*RotateZ(banh_maybay_quay); banh_xe_truoc2(); instance_maybay = Translate(maybay_chay, 0.0 + vitri_maybay, 0.0)*RotateY(30)*RotateZ(-10); instance_maybay *= Translate(-0.7, 0.0 + vitri_maybay, 0.0)*RotateX(quat_maybay_quay); quat_maybay(); } 16 2.4 Thiết kế cài đặt: Xe tăng gỗ 2.4.1 Mô hình phân cấp 2.4.2 Kỹ thuật cài đặt mat4 instance_xe; GLfloat vitri_xe = 1.5; void than_xe() { mat4 instance; instance = Translate(0.0 + vitri_xe, 0.0, 0.0 vitri_xe)*RotateX(180)*RotateY(90)*Scale(1.5, 1.5, 3.5); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_xe*instance); glDrawArrays(GL_TRIANGLES, Index_Trutron, Index_bantru Index_Trutron); instance = Translate(0.0 + vitri_xe, 0.0, 0.0 - vitri_xe)*Scale(1.0, 0.4, 0.5); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_xe*instance); glDrawArrays(GL_TRIANGLES, 0, Index); } void than_quay() { mat4 instance; instance = Scale(0.5, 0.4, 0.35); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_xe*instance); glDrawArrays(GL_TRIANGLES, 0, Index); } void sung() { //sung mat4 instance; 17 instance = Translate(-0.5,0.0,0.0)*RotateZ(90)*Scale(0.25, 2.0, 0.25); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_xe*instance); glDrawArrays(GL_TRIANGLES, Index, Index_Trutron - Index); } void banh_xt_truoc1() { mat4 instance; instance = RotateX(90)*Scale(0.7, 0.25, 0.7); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_xe*instance); glDrawArrays(GL_TRIANGLES, Index, Index_Trutron - Index); } void banh_xt_truoc2() { mat4 instance; instance = RotateX(90)*Scale(0.7, 0.25, 0.7); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_xe*instance); glDrawArrays(GL_TRIANGLES, Index, Index_Trutron - Index); } void banh_xt_sau1() { mat4 instance; instance = RotateX(90)*Scale(0.7, 0.25, 0.7); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_xe*instance); glDrawArrays(GL_TRIANGLES, Index, Index_Trutron - Index); } void banh_xt_sau2() { mat4 instance; instance = RotateX(90)*Scale(0.7, 0.25, 0.7); glUniformMatrix4fv(model_loc, 1, GL_TRUE, model*instance_xe*instance); glDrawArrays(GL_TRIANGLES, Index, Index_Trutron - Index); } // Các thông số chuyển động cho xe tăng GLfloat xx = 0; GLfloat dau_quay = 0, banh_xt_quay = 0; void Xe() { instance_xe = Translate(xx + vitri_xe, 0.0, 0.0-vitri_xe); than_xe(); instance_xe *= Translate(0.0 + vitri_xe, 0.4, 0.0 vitri_xe)*RotateY(dau_quay); than_quay(); 18 instance_xe = Translate(xx + vitri_xe, 0.0, 0.0 - vitri_xe); instance_xe *= Translate(0.0 + vitri_xe, 0.4, 0.0 vitri_xe)*RotateY(dau_quay); sung(); instance_xe = Translate(xx + vitri_xe, 0.0, 0.0 - vitri_xe); instance_xe *= Translate(-0.35 + vitri_xe, -0.3, 0.45 vitri_xe)*RotateZ(banh_xt_quay); banh_xt_truoc1(); instance_xe = Translate(xx + vitri_xe, 0.0, 0.0 - vitri_xe); instance_xe *= Translate(-0.35 + vitri_xe, -0.3, -0.45 vitri_xe)*RotateZ(banh_xt_quay); banh_xt_truoc2(); instance_xe = Translate(xx + vitri_xe, 0.0, 0.0 - vitri_xe); instance_xe *= Translate(0.35 + vitri_xe, -0.3, 0.45 vitri_xe)*RotateZ(banh_xt_quay); banh_xt_sau1(); instance_xe = Translate(xx + vitri_xe, 0.0, 0.0 - vitri_xe); instance_xe *= Translate(0.35 + vitri_xe, -0.3, -0.45 vitri_xe)*RotateZ(banh_xt_quay); banh_xt_sau2(); } 2.5 Thiết lập điều khiển phép chiếu, camera GLfloat x = 0, y = 0, z = 2; void display( void ) { glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT ); vec4 eye(x, y, z, 1); vec4 at(0, 0, 0, 1); vec4 up(0, 1, 0, 1); mat4 view = LookAt(eye, at, up); glUniformMatrix4fv(model_view_loc, 1, GL_TRUE, view); mat4 projection = Frustum(-1.5, 1.5, -1.5, 1.5, 1, 10); glUniformMatrix4fv(projection_loc, 1, GL_TRUE, projection); glViewport(0, 0, 640, 640); Doantau(); Chongchong(); Maybay(); Xe(); glutSwapBuffers(); } 19 CHƯƠNG KẾT QUẢ CHƯƠNG TRÌNH 3.1 Mô tả kết - Kết gồm sản phẩm: + Đồn tàu di chuyển + Chong chóng quay + Máy bay chạy quạt quay + Xe tăng chạy pháo súng quay - Khi nhấn phím “c” đối tượng bắt đầu chuyển động đồng thời - Camera có điều khiển 3.2 Các hình ảnh kết Hình 3-5 Kết chạy chương trình 20 Hình 3-6 Kết điều khiển camera Hình 3-7 Nhìn từ xuống 21 KẾT LUẬN Bằng kiến thức cô Vũ Minh Yến giảng dạy tài liệu mà cô cung cấp, chúng em tìm hiểu hồn thành đề tài đạt kết mong muốn ban đầu, kết không thực đẹp giống với sản phẩm mẫu Trong q trình nghiên cứu thực đề tài, nhóm chúng em hiểu kỹ thuật ứng dụng OpenGL đồ họa máy tính Điều giúp chúng em nắm vững thêm kiến thức áp dụng nhiều lĩnh vực khác sử dụng đồ họa máy tính Bài làm chúng em có nhiều sai sót, mong nhận góp ý, nhận xét từ giáo bạn Nhóm chúng em xin chân thành cảm ơn! TÀI LIỆU THAM KHẢO - Các tài liệu Vũ Minh Yến cung cấp - Các hình ảnh sản phẩm (Hình 1-1, 1-2, 1-3, 1-4) lấy Internet 22 ... tài Đồ chơi gỗ đồ vật chơi trẻ em hoạt động giải trí, giúp cho trẻ em rèn luyện nhiều kĩ phát triển Đồ chơi gỗ thường có nét tiêu biểu dạng khái quát, tái hoạt động tương ứng đồ vật Ví dụ đồn... gỗ, chong chóng, máy bay trực thăng gỗ, … Đồ chơi gỗ vật dụng quen thuộc phổ biến với trẻ em Do nhóm chúng em định chọn đồ chơi gỗ trẻ em gồm có: Đồn tàu gỗ, chong chóng, máy bay gỗ xe tăng gỗ. ..Mục lục MỞ ĐẦU Đồ họa máy tính phương pháp công nghệ dùng việc chuyển đổi qua lại liệu hình ảnh máy tính Đồ họa máy tính lĩnh vực khoa học máy tính nghiên cứu tốn học, thuật toán

Ngày đăng: 07/12/2021, 21:05

Mục lục

  • CHƯƠNG 1. MÔ TẢ BÀI TOÁN

    • 1.1. Giới thiệu đề tài

    • 1.2. Mô tả mô hình và kịch bản

      • 1.2.1. Đoàn tàu bằng gỗ

      • 1.2.2. Chong chóng

      • 1.2.3. Máy bay bằng gỗ

      • 1.2.4. Xe tăng bằng gỗ

      • 1.2.5. Điều khiển

      • CHƯƠNG 2. MỘT SỐ KỸ THUẬT ĐIỂN HÌNH PHÁT TRIỂN CHƯƠNG TRÌNH

        • 2.1. Thiết kế và cài đặt: Đoàn tàu bằng gỗ

          • 2.1.1. Mô hình phân cấp

          • 2.1.2. Kỹ thuật cài đặt

          • 2.2. Thiết kế và cài đặt: Chong chóng

            • 2.2.1. Mô hình phân cấp

            • 2.2.2. Kỹ thuật cài đặt

            • 2.3. Thiết kế và cài đặt: Máy bay bằng gỗ

              • 2.3.1. Mô hình phân cấp

              • 2.3.2. Kỹ thuật cài đặt

              • 2.4. Thiết kế và cài đặt: Xe tăng bằng gỗ

                • 2.4.1. Mô hình phân cấp

                • 2.4.2. Kỹ thuật cài đặt

                • 2.5. Thiết lập và điều khiển phép chiếu, camera

                • CHƯƠNG 3. KẾT QUẢ CHƯƠNG TRÌNH

                  • 3.1. Mô tả kết quả

                  • 3.2. Các hình ảnh kết quả

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan