Braco Robotico em OpenGL
Publicado por Michael 25/12/2005 (última atualização em 13/09/2022)
[ Hits: 18.645 ]
Download bracoFix.c (versão 2)
Este programa mostra como é utilizado matrizes no meio da computação grafica. É tulizado linguagem C com funções em Opengl, ele foi compilado no Dev C++ mais roda perfeitamente no ambiente Linux, basta fazer as configurações certa
Boa Sorte
Versão 2 - Enviado por Samuel Leonardo em 12/09/2022
Changelog: Bug fix:
Para compilar:
1-instale o opengl:
sudo apt install freeglut3-dev libgl1-mesa-dev libglu1-mesa-dev build-essential
2-compilando
2.1-salve o bracoFix.c numa pasta
2.2-abra um terminal na pasta do bracoFix.c
2.3-execute o comando:
gcc -o bracoFix bracoFix.c -lGL -lGLU -lglut
3-executando
Apenas rode o comando:
./bracoFix
/*Programa usado para estudar matriz em meio 3D Desenvolvido por : Michael D. Borges */ //#include <glut.h> #include <gl/glut.h> //Declaração de variáveis float ang0=0, ang1=0 , ang2=0 ,vy=-1, ty=1; // Objecto Quadric (gluCilinder, gluDisk) GLUquadricObj *planet; void Desenha(void) { glClear(GL_COLOR_BUFFER_BIT); glColor3f(0.0,0.0,1.0); glBegin(GL_QUADS); glVertex2f(-12,-2); glVertex2f(-12,0); glVertex2f(12,0); glVertex2f(12,-2); glEnd(); glPushMatrix(); glRotatef(ang0, 0.0, 0.0, 1.0); glColor3f(1.0,1.0,0.0); gluDisk(planet, 0, 2, 16, 1); glBegin(GL_QUADS); glVertex2f(0,-0.5); glVertex2f(0,0.5); glVertex2f(6,0.5); glVertex2f(6,-0.5); glEnd(); glPushMatrix(); glTranslatef(6.0, 0.0, 0.0); glRotatef(ang1, 0.0, 0.0, 1.0); glColor3f(1.0,0.0,0.0); gluDisk(planet, 0, 0.8, 16, 1); glBegin(GL_QUADS); glVertex2f(0,-0.3); glVertex2f(0,0.3); glVertex2f(3,0.3); glVertex2f(3,-0.3); glEnd(); glPushMatrix(); glTranslatef(3.0, 0.0, 0.0); glRotatef(ang2, 0.0, 0.0, 1.0); glColor3f(0.0,0.0,1.0); glBegin(GL_QUADS); glVertex2f(0,-0.3); glVertex2f(0,0.3); glVertex2f(2,0.3); glVertex2f(2,-0.3); glEnd(); gluDisk(planet, 0, 0.8, 10, 1); glPushMatrix(); glTranslatef(1., 0.0, 0.0); glColor3f(0.0,0.0,1.0); glBegin(GL_QUADS); glVertex2f(1,-1); glVertex2f(1,1); glVertex2f(1.5,1); glVertex2f(1.5,-1); glEnd(); glBegin(GL_QUADS); glVertex2f(1.5,ty-0.5); glVertex2f(1.5,ty); glVertex2f(3,ty); glVertex2f(3,ty-0.5); glEnd(); glBegin(GL_QUADS); glVertex2f(1.5,vy); glVertex2f(1.5,vy+0.5); glVertex2f(3,vy+0.5); glVertex2f(3,vy); glEnd(); glPopMatrix(); glPopMatrix(); glPopMatrix(); glPopMatrix(); glFlush(); } void TeclasEspeciais(int key, int x, int y) { switch (key) { case GLUT_KEY_DOWN: if (vy>=-0.9 & vy<=-0.4) vy=vy-0.1; if (ty>=0.4 & ty<=0.9)ty=ty+0.1; break; case GLUT_KEY_UP: if (vy>=-1.1 & vy<=-0.5) vy=vy+0.1; if (ty>=0.5 & ty<=1.1)ty=ty-0.1; break; case GLUT_KEY_HOME: ang0=ang0+5.0; break; case GLUT_KEY_END: ang0=ang0-5.0; break; case GLUT_KEY_PAGE_UP: ang1=ang1+7.0; break; case GLUT_KEY_PAGE_DOWN: ang1=ang1-7.0; break; case GLUT_KEY_LEFT: ang2=ang2+9.0; break; case GLUT_KEY_RIGHT: ang2=ang2-9.0; break; } glutPostRedisplay(); } void Inicializa (void) { glClearColor(0.0f, 0.0f, 0.0f, 1.0f); gluOrtho2D(-13.0,13.0,-13.0,13.0); } int main(void) { glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutCreateWindow("Braço robótico"); planet=gluNewQuadric(); glutDisplayFunc(Desenha); glutSpecialFunc(TeclasEspeciais); Inicializa(); glutMainLoop(); }
gerador automatico de Makefiles
AA linux kernel modificado por minhe
Tipos de Dados Abstrato - TDA - Números Complexos
Atualizar o macOS no Mac - Opencore Legacy Patcher
Crie alias para as tarefas que possuam longas linhas de comando - bash e zsh
Criando um gateway de internet com o Debian
Configuração básica do Conky para mostrar informações sobre a sua máquina no Desktop
Aprenda a criar músicas com Inteligência Artificial usando Suno AI
Instalando Zoom Client no Ubuntu 24.04 LTS
Instalando Zoom Client no Fedora 40
Instalando Navegador Firefox no Debian 12
Bloqueando propagandas no Youtube e outros sites com o uBlocker Origin
Sistema da Coréia do Norte - Red Star OS (59)
Comando interno CD não funciona (16)
Dificuldade em ler binário (12)
Em que pasta/arquivo ficam as configurações das janelas em derivados d... (2)