Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
SER431 Lecture 04
Search
Javier Gonzalez-Sanchez
PRO
August 27, 2018
Programming
0
330
SER431 Lecture 04
Advanced Graphics
Skyboxes
(201808)
Javier Gonzalez-Sanchez
PRO
August 27, 2018
Tweet
Share
More Decks by Javier Gonzalez-Sanchez
See All by Javier Gonzalez-Sanchez
CSC305 Lecture 26
javiergs
PRO
0
140
CSC305 Lecture 25
javiergs
PRO
0
130
CSC509 Lecture 14
javiergs
PRO
0
140
CSC305 Lecture 24
javiergs
PRO
0
46
CSC509 Lecture 13
javiergs
PRO
0
170
CSC305 Lecture 23
javiergs
PRO
1
120
CSC305 Lecture 22
javiergs
PRO
0
61
CSC509 Lecture 12
javiergs
PRO
0
210
CSC305 Lecture 21
javiergs
PRO
0
190
Other Decks in Programming
See All in Programming
各クラウドサービスにおける.NETの対応と見解
ymd65536
0
170
なまけものオバケたち -PHP 8.4 に入った新機能の紹介-
tanakahisateru
1
130
命名をリントする
chiroruxx
1
450
Online-Dokumentation, die hilft: Strukturen, Prozesse, Tools
ahus1
0
100
テストコード文化を0から作り、変化し続けた組織
kazatohiei
2
1.5k
iOS開発におけるCopilot For XcodeとCode Completion / copilot for xcode
fuyan777
1
110
「とりあえず動く」コードはよい、「読みやすい」コードはもっとよい / Code that 'just works' is good, but code that is 'readable' is even better.
mkmk884
3
750
선언형 UI에서의 상태관리
l2hyunwoo
0
190
PHPとAPI Platformで作る本格的なWeb APIアプリケーション(入門編) / phpcon 2024 Intro to API Platform
ttskch
0
300
わたしの星のままで一番星になる ~ 出産を機にSIerからEC事業会社に転職した話 ~
kimura_m_29
0
200
Webエンジニア主体のモバイルチームの 生産性を高く保つためにやったこと
igreenwood
0
340
MCP with Cloudflare Workers
yusukebe
2
230
Featured
See All Featured
Navigating Team Friction
lara
183
15k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7k
Optimising Largest Contentful Paint
csswizardry
33
3k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
32
2.7k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
520
The Invisible Side of Design
smashingmag
298
50k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Music & Morning Musume
bryan
46
6.2k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
48
2.2k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
170
Transcript
jgs SER 431 Advanced Graphics Lecture 04: Skyboxes Javier Gonzalez-Sanchez
[email protected]
PERALTA 230U Office Hours: By appointment
Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 1 jgs
Previously
Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 2 jgs
A box
Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 3 jgs
A box // create a triangulated cube Mesh* createCube() { Mesh *mesh = new Mesh; // Define 8 Vertexes mesh->dot_vertex.push_back(Vec3<GLfloat>( 0.0, 32.0, 32.0)); mesh->dot_vertex.push_back(Vec3<GLfloat>( 32.0, 32.0, 32.0)); mesh->dot_vertex.push_back(Vec3<GLfloat>( 32.0, 0.0, 32.0)); mesh->dot_vertex.push_back(Vec3<GLfloat>( 0.0, 0.0, 32.0)); // .. // Define 6 Faces; 2 triangles each mesh->face_index_vertex.push_back(0); mesh->face_index_vertex.push_back(3); mesh->face_index_vertex.push_back(1); mesh->face_index_vertex.push_back(1); mesh->face_index_vertex.push_back(3); mesh->face_index_vertex.push_back(2); // continue in the next slide 3 2 1 0
Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 4 jgs
// Define 8 Vertexes and Define 6 Faces; 2 triangles each // Define texture vertex mesh->dot_texture.push_back(Vec2<GLfloat>(0.0, 1.0)); mesh->dot_texture.push_back(Vec2<GLfloat>(1.0, 1.0)); mesh->dot_texture.push_back(Vec2<GLfloat>(1.0, 0.0)); mesh->dot_texture.push_back(Vec2<GLfloat>(0.0, 0.0)); // Define texture faces for (int t = 0; t<6; t++) { mesh->face_index_texture.push_back(0);//0 mesh->face_index_texture.push_back(2);//1 mesh->face_index_texture.push_back(1);//2 mesh->face_index_texture.push_back(0);//0 mesh->face_index_texture.push_back(3);//2 mesh->face_index_texture.push_back(2);//3 } return mesh; } A Texture Outside the Box
Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 5 jgs
What about inside the box?
Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 6 jgs
Load Textures // Create texture from a DIB or BMP file void texture_from_file(GLuint *textureArray, const char * file) { BITMAPINFO *bitmapInfo; // Bitmap information GLubyte *bitmapBits; // Bitmap data if (!file) { cout << "texture file not found!" << endl; return;} // load image bitmapBits = load_bmp_file(file, &bitmapInfo); // setup texture glGenTextures(1, textureArray); glBindTexture(GL_TEXTURE_2D, *textureArray); glPixelStorei(GL_UNPACK_ALIGNMENT, 1);// must set to 1 for compact data gluBuild2DMipmaps(GL_TEXTURE_2D, 3, bitmapInfo->bmiHeader.biWidth, bitmapInfo->bmiHeader.biHeight, GL_BGR_EXT, GL_UNSIGNED_BYTE, bitmapBits ); }
Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 7 jgs
A Texture for the Horizon
Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 8 jgs
A texture for a Room https://www.facebook.com/asuphotos/photos/a.1636426986668999/1691991784445852/?type=3&theater
Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 9 jgs
Texture Sources § Azimuth Chrome Plugin https://chrome.google.com/webstore/detail/azimuth-download-facebook/ https://www.360toolkit.co § Skyboxes Textures http://www.custommapmakers.org/skyboxes.php
Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 10 jgs
Add a Texture to a Box void init() { // CREATE MESH DATA STRUCTURES mesh_cube = createCube(); // TEXTURES (Lecture 23 in SER 332) GLuint texture_array[6]; texture_from_file(&texture_array[0], "../../bmp files/top.bmp"); texture_from_file(&texture_array[1], "../../bmp files/left.bmp"); // ... // DISPLAY LIST skybox= meshToDisplayList(1, mesh_cube, texture_array); // CONFIGURE LIGHT }
Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 11 jgs
GLuint meshToDisplayList(int id, Mesh* m, GLuint texture) { GLuint listID = glGenLists(id); glNewList(listID, GL_COMPILE); glEnable(GL_TEXTURE_2D); // Other options: GL_TEXTURE_1D, GL_TEXTURE_3D, GL_TEXTURE_CUBE_MAP glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glBindTexture(GL_TEXTURE_2D, texture); glBegin(GL_TRIANGLES); // PER VERTEX NORMALS // TEXTURES if (!m->dot_texture.empty() && !m->face_index_texture.empty()) { glTexCoord2fv(&m->dot_texture[m->face_index_texture[i]].x); } // COLOR // VERTEX glEnd(); glDisable(GL_TEXTURE_2D); glEndList(); return listID; } Add a Texture to a Box
Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 12 jgs
Texture inside a Box
Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 13 jgs
Texture inside a Box https://www.facebook.com/asuphotos/photos/a.1636426986668999/1691991784445852/?type=3&theater
Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 14 jgs
Quiz 1 § Work with your team § Create a Skybox § Submit your source code on Blackboard. Due: August 29, 11:59 PM
Javier Gonzalez-Sanchez | SER431 | Fall 2018 | 15 jgs
Test Yourselves Combine a sky box and a terrain. Allow the camera to be moved.
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.