Braco Robotico em OpenGL
Publicado por Michael 25/12/2005 (última atualização em 13/09/2022)
[ Hits: 19.478 ]
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();
}
Rotina para controle de portas paralelas em C.
Cirurgia para acelerar o openSUSE em HD externo via USB
Void Server como Domain Control
Modo Simples de Baixar e Usar o bash-completion
Monitorando o Preço do Bitcoin ou sua Cripto Favorita em Tempo Real com um Widget Flutuante
Jogar games da Battle.net no Linux com Faugus Launcher
Como fazer a Instalação de aplicativos para acesso remoto ao Linux
Como fazer a instalação do Samba
Como fazer a conversão binária e aplicar as restrições no Linux
Duas Pasta Pessoal Aparecendo no Ubuntu 24.04.3 LTS (19)
Formas seguras de instalar Debian Sid (13)
Malware encontrado em extensões do Firefox. (0)
Fiz uma pergunta no fórum mas não consigo localizar [RESOLVIDO] (21)









