3
I implemented all the commands of a crane, only lacked the inclination of it around its axis on top, only that I can not reproduce this inclination, because it seems that I have to make translational effects and scale at the same time to adjust, but it doesn’t seem to be the best way to do it, look at the problem generated:
It wasn’t supposed to go off the rails?
Code I made: http://pastebin.com/JkEQ3un7
//Base do guindaste é fixa
glPushMatrix();
glScalef(2.0, 0.5, 1.0);
cubo();
glPopMatrix();
glRotatef( angGiro, 0.0, 1.0, 0.0 );
{
//Base cilindrica de cima da base
// ...
//Base vertical longa ou Haste vertical
// ...
// inclinacao
//Parte cilindrica na ponta de cima da base vertical longa
// ...
glRotatef( angInclinacao, 0, 0, 1 );
{
//Cubo horizontal longo ou Viga
glPushMatrix();
glTranslatef(2-deslViga, 2.75, 0); // deslViga é o deslocamento da viga e diminui metade do que e aumenta/diminui a metade do que o comprimento da viga para poder fazer a relacao de translacao e escala ficarem corretos
glScalef( compViga, 0.3, 0.15);
cubo();
glPopMatrix();
//Parte cilindrica na ponta direita da base horizontal
glPushMatrix();
glTranslatef( compViga, 2.75, -0.0375);
glScalef( 0.2, 0.2, 0.075);
cilindro();
glPopMatrix();
//Parte vertical longa e fina no final da parte cilindrica direita
// ...
I forgot to post the code: http://pastebin.com/JkEQ3un7
– Jonathas Moreira
Welcome to Stack Overflow, Jonathas! When asking a question, please place the relevant code snippets (where applicable) in the question itself, even if accompanied by a link to the full code. I edited your question with an example of how this can be done.
– mgibsonbr
Oops, really new, sorry and thank you.
– Jonathas Moreira
Corrected version of the problem for those who are curious, has been corrected thanks to the help of our friend mgibsonbr. http://pastebin.com/QQ6C2MRK, Thank you.
– Jonathas Moreira