Braco Robotico em OpenGL
Publicado por Michael 25/12/2005 (última atualização em 13/09/2022)
[ Hits: 19.403 ]
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();
}
3 EP - Poli USP - Angry Birds (angry bixos)
Listando processos via /proc/PID
Tipos de Dados Abstrato - TDA - Vetor
Monitorando o Preço do Bitcoin ou sua Cripto Favorita em Tempo Real com um Widget Flutuante
IA Turbina o Desktop Linux enquanto distros renovam forças
Como extrair chaves TOTP 2FA a partir de QRCODE (Google Authenticator)
Como realizar um ataque de força bruta para desobrir senhas?
Como usar Gpaste no ambiente Cinnamon
Atualizando o Fedora 42 para 43
ERRO: LAZARUS 4.2 64 no Linux MINT não entra mais apos ajustar desktop... (0)
Pergunta: Meu teclado não está respondendo direito como e consertar? (2)
Secure boot, artigo interessante, nada técnico. (6)
SQLITE não quer funcionar no LINUX LMDE6 64 com Lazaruz 4.2 64bit (n... (0)









