Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Viewer::init_cylindre()
- {
- m_cylindre = Mesh(GL_TRIANGLE_STRIP);
- m_cylindre.color(1, 1, 1);
- int div = 25;
- float rota = M_PI * 2 / div;
- for (int i = 0; i <= div; i++)
- {
- float alpha = rota * i;
- m_cylindre.normal(Vector(cos(alpha), 0, sin(alpha)));
- m_cylindre.vertex(Point(cos(alpha), 0, sin(alpha)));
- m_cylindre.normal(Vector(cos(alpha), 0, sin(alpha)));
- m_cylindre.vertex(Point(cos(alpha), 2, sin(alpha)));
- }
- }
- void Viewer::init_couvercle()
- {
- m_couvercle = Mesh(GL_TRIANGLE_FAN);
- m_couvercle.color(1, 1, 1);
- int div = 25;
- float rota = M_PI * 2 / div;
- m_couvercle.vertex(Point(0, 0, 0));
- m_couvercle.normal(Vector(0, 1, 0));
- for (int i = 0; i <= div; i++)
- {
- float alpha = rota * i;
- m_couvercle.vertex(Point(cos(alpha), 0, sin(alpha)));
- }
- }
- void Viewer::init_cone()
- {
- m_cone = Mesh(GL_TRIANGLE_FAN);
- m_cone.color(1, 1, 1);
- int div = 25;
- float rota = M_PI * 2 / div;
- m_cone.vertex(Point(0, 1, 0));
- m_cone.normal(Vector(0, 1, 0));
- for (int i = 0; i <= div; i++)
- {
- const float alpha = rota * i;
- m_cone.vertex(Point(cos(alpha), 0, sin(alpha)));
- }
- }
- int Viewer::render()
- {
- /* ... */
- //Cylindre
- gl.model(Translation(0, 0, 0));
- gl.draw(m_cylindre);
- gl.model(-1 * Translation(0, 2, 0)); // Face Haut
- gl.draw(m_couvercle);
- gl.model(Translation(0, 0, 0)); // Face Bas
- gl.draw(m_couvercle);
- // Cone -- J'ai mis en coordonnées de base 2,0,0 pour qu'il soit à coté du cylindre
- gl.model(-1*Translation(2, 0, 0));
- gl.draw(m_cone);
- gl.model(Translation(-2, 0, 0)); // Face Bas, -2 ici car on fait -1* translation pour le m_cone
- gl.draw(m_couvercle);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement