Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Viewer::filler_skybox(Mesh& m, float startX, float startY)
- {
- const float sizeX = 1 / 4.0;
- const float sizeY = 1 / 3.0;
- m.normal(0, 0, 1);
- m.texcoord(startX, startY);
- m.vertex(-1, -1, 0);
- m.texcoord(startX + sizeX, startY);
- m.vertex(1, -1, 0);
- m.texcoord(startX, startY + sizeY);
- m.vertex(-1, 1, 0);
- m.texcoord(startX + sizeX, startY + sizeY);
- m.vertex(1, 1, 0);
- }
- void Viewer::init_skybox()
- {
- for (int i = 0; i < 6; i++)
- {
- m_skybox[i] = Mesh(GL_TRIANGLE_STRIP);
- m_skybox[i].color(Color(1, 1, 1));
- }
- m_skybox_texture = read_texture(0, "data/cubemap/skybox.png");
- filler_skybox(m_skybox[0], 0, 1/3.0); // Gauche
- filler_skybox(m_skybox[1], 1/4.0, 0); // Bas
- filler_skybox(m_skybox[2], 1 / 2.0, 1 / 3.0); // Droite
- filler_skybox(m_skybox[3], 1 / 4.0, 2 / 3.0); // Haut
- filler_skybox(m_skybox[4], 1 / 4.0, 1 / 3.0); // Avant
- filler_skybox(m_skybox[5], 3 / 4.0, 1 / 3.0); // Arrière
- }
- void Viewer::render_skybox()
- {
- gl.lighting(true);
- gl.texture(m_skybox_texture);
- gl.model(Translation(0, 5, -10)*Scale(10, 10, 1));
- gl.draw(m_skybox[4]); // Avant
- gl.texture(m_skybox_texture);
- gl.model(Translation(10, 5, 0)*RotationY(270)*Scale(10, 10, 1));
- gl.draw(m_skybox[2]); // Droite
- gl.texture(m_skybox_texture);
- gl.model(Translation(-10, 5, 0)*RotationY(90)*Scale(10, 10, 1));
- gl.draw(m_skybox[0]); // Gauche
- gl.texture(m_skybox_texture);
- gl.model(Translation(0, -5, 0)*RotationX(270)*Scale(10, 10, 1));
- gl.draw(m_skybox[1]); // Bas
- gl.lighting(false);
- gl.texture(m_skybox_texture);
- gl.model(Translation(0, 5, 10)*RotationY(180)*Scale(10, 10, 1));
- gl.draw(m_skybox[5]); // Arriere
- gl.texture(m_skybox_texture);
- gl.model(Translation(0, 15, 0)*RotationX(90)*Scale(10, 10, 1));
- gl.draw(m_skybox[3]); // Haut
- }
- /*
- Dans le render: render_skybox();
- Dans le header:
- void filler_skybox(Mesh &m, float startX, float startY);
- void init_skybox();
- void render_skybox();
- Mesh m_skybox[6];
- GLuint m_skybox_texture;
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement