Ejemplo n.º 1
0
void cilindro(float raio,int fatias,float alt,int sep_cir,int sep_h){
    float angulo=(2*M_PI)/fatias,x,y=0,l_aux,h_aux1,h_aux2=0;
    
    circulo(raio, fatias, sep_cir, 0, 0);
    circulo(raio, fatias, sep_cir, alt, 1);
    
    alt=alt/sep_h;
    glBegin(GL_TRIANGLES);
    for(;sep_h>0;sep_h--){
        h_aux1=h_aux2;
        h_aux2+=alt;
        y=0;

        for (l_aux=0; l_aux<=fatias; l_aux++) {
            x=y;
            y+=angulo;
            
            glVertex3f(raio*sin(x), h_aux2, raio*cos(x));
            glVertex3f(raio*sin(x), h_aux1, raio*cos(x));
            glVertex3f(raio*sin(y), h_aux2, raio*cos(y));
            
            glVertex3f(raio*sin(x), h_aux1, raio*cos(x));
            glVertex3f(raio*sin(y), h_aux1, raio*cos(y));
            glVertex3f(raio*sin(y), h_aux2, raio*cos(y));
        }
    }
    glEnd();
}
Ejemplo n.º 2
0
void carro(){
  int i;
  /*LLantas*/
  glColor3f(0.0,0.0,0.0);
  circulo(height/32,7*width/16,3*height/16);
  glColor3f(1.0,1.0,1.0);
  circulo((height/32)-height/128,7*width/16,3*height/16);

  glColor3f(0.0,0.0,0.0);
  circulo(height/32,9*width/16,3*height/16);
  glColor3f(1.0,1.0,1.0);
  circulo((height/32)-height/128,9*width/16,3*height/16);
/*lineas*/
  for(i = 1 ; i <= 18 ; i++){
    glPushMatrix();
    glTranslatef(7*width/16,3*height/16,0);
    glRotatef(20*i,0.0,0.0,1.0);
    glTranslatef(-7*width/16,-3*height/16,0);
    glColor3f(0.0,0.0,0.0);
    glLineWidth(1);
    glBegin(GL_LINES);
    glVertex2f(7*width/16,7*height/32);
    glVertex2f(7*width/16,5*height/32);
    glEnd();

    glPopMatrix();
//  }
//  for(i = 1 ; i <= 18 ; i++){
    glPushMatrix();
    glTranslatef(9*width/16,3*height/16,0);
    glRotatef(20*i,0.0,0.0,1.0);
    glTranslatef(-9*width/16,-3*height/16,0);
    glColor3f(0.0,0.0,0.0);
    glLineWidth(1);
    glBegin(GL_LINES);
    glVertex2f(9*width/16,7*height/32);
    glVertex2f(9*width/16,5*height/32);
    glEnd();

    glPopMatrix();
  }
  /*Cuerpo*/
  glColor3f(1.0,0.0,0.0);
  glBegin(GL_POLYGON);
  glVertex2f(3*width/8,3*height/16);
  glVertex2f(5*width/8,3*height/16);
  glVertex2f(5*width/8,5*height/16);
  glVertex2f(3*width/8,5*height/16);
  glEnd();

}
void ChromaticCircle::circulo( int _pasos, int _pasosTotal, float _radio, float _rot, int _id, bool _trans, bool _stroke ){
    
    ofPushStyle();
    if ( _stroke ) {

        ofSetColor( rellenos[  _id  ] );
        ofFill();
        ofCircle(0, 0, _radio);
        
        ofSetColor( 0 );
        ofSetLineWidth( borde );
        ofNoFill();
        ofCircle(0, 0, _radio);
    }
    else {
        ofSetColor( rellenos[  _id  ] );
        ofFill();
        ofCircle(0, 0, _radio);
    }
    
    ofPopStyle();
    
    if (_pasos < _pasosTotal ) {
        if ( _trans ) {
            ofTranslate (20, 0);
            ofRotate(ofDegToRad(_rot));
        }
        circulo ( _pasos+1, _pasosTotal, _radio/2, _rot, _id+1, _trans, _stroke);
    
    }
  

}
void ChromaticCircle::draw(){
   
    ofPushMatrix();
    
    ofTranslate( x , y );
    
    circulo( 0, pasosTotal, radio, rot, indice, trans, stroke_);
    
    ofPopMatrix();

}
Ejemplo n.º 5
0
void PintaFun::desenha_circulo(const COORDENADA& x1, const COORDENADA& y1,
                               const COORDENADA& x2, const COORDENADA& y2,
                               MouseFun& mouse, MOUSE_EVENTO* evento)
{
  BOLEANO pinta = FALSO;
  COORDENADA antx, anty;
  ConversorFun conv;
  int raio;

  while (mouse.verifica(x1, y1, x2, y2) || pinta)
  {
    {
      COORDENADA ax = mouse.x(), ay = mouse.y();

      if (pinta)
      {
        double r, a;
        conv.converte(mouse.x(), mouse.y(), &a, &r, antx, anty);
        raio = (int) r;
      }

      setcolor(7);
      setlinestyle(1, 0, 0);
      setwritemode(XOR_PUT);

      line(ax, 0, ax, getmaxy());
      line(0, ay, getmaxx(), ay);

      if (pinta)
      {
        setcolor(10);
        setlinestyle(0, 0, 0);
        circulo(x1, y1, x2, y2, antx, anty, raio);
      }

      *evento = mouse.evento_pause();

      if (pinta)
        circulo(x1, y1, x2, y2, antx, anty, raio);

      setcolor(7);
      setlinestyle(1, 0, 0);
      line(ax, 0, ax, getmaxy());
      line(0, ay, getmaxx(), ay);

      setwritemode(COPY_PUT);
      setlinestyle(SOLID_LINE, 0, 0);
    }

    if (*evento == MOUSE_DOWN)
    {
      pinta = VERDADEIRO;
      antx = mouse.x();
      anty = mouse.y();
    }
    else
      if (*evento == MOUSE_UP)
      {
        if (pinta)
        {
          /*
          setcolor(15);
          setviewport(x1, y1, x2, y2, 1);*/
          //circle(antx - x1/*12*/, anty - y1/*26*/, raio);
          //setviewport(0, 0, getmaxx(), getmaxy(), 0);

          CirculoGrafico* cir = new CirculoGrafico(antx - this->x1() /* - 5*/,
                                                   anty - this->y1() /*- 20*/,
                                                   raio);
          c_lista.ins(cir);
          cir->exibe(this->x1(), this->y1(), this->x2(), this->y2());

          pinta = FALSO;
        }
      }
      else
        if (*evento == MOUSE_UP_DIREITO)
          return;
  }
}
Ejemplo n.º 6
0
void principal::on_pushButton_circulo_clicked()
{
    circulo();
}
Ejemplo n.º 7
0
void display(){

  int i;
  float angulo;

  glClear(GL_COLOR_BUFFER_BIT);

  /*Primero dibujo el piso*/

  glColor3f(0.22,0.49,0.01);
  glBegin(GL_POLYGON);
  glVertex2i(0,width/8);
  glVertex2i(0,0);
  glVertex2i(width,0);
  glVertex2i(width,height/8);
  glEnd();

  /*Dibujo la pista*/
  glColor3f(0.27,0.32,0.24);
  glBegin(GL_POLYGON);
  glVertex2i(0,height/4);
  glVertex2i(0,height/8);
  glVertex2i(width,height/8);
  glVertex2i(width,height /4);
  glEnd();

  /*Los cerros*/
  glColor3f(0.22,0.49,0.01);
  glBegin(GL_POLYGON);
  glVertex2i(0,height/4);
  glVertex2i(width,height/4);
  glVertex2i(width,5*height/16);
  glVertex2i(width*7/8,3*height/8);
  glVertex2i(width*3/4,5*height/16);
  glVertex2i(width/3,5*height/8);
  glVertex2i(width/3,height/4);
  glEnd();

  glColor3f(0.22,0.49,0.01);
  glBegin(GL_POLYGON);
  glVertex2i(0,height/4);
  glVertex2i(0,height*3/8);
  glVertex2i(width/8,height/2);
  glVertex2i(width/4,height/4);
  glEnd();


  /*Las lineas de la pista*/

  glColor3f(1.0,1.0,1.0);
  glBegin(GL_POLYGON);
  glVertex2i(0,3*height/16);
  glVertex2i(width,3*height/16);
  glVertex2i(width,13*height/64);
  glVertex2i(0,13*height/64);
  glEnd();

  /*Lineas del sol*/

  for(i = 0 ; i < 18 ; i++){
  //  angulo =
    glColor3f(1.0,1.0,0.0);
    glLineWidth(3);
    glBegin(GL_LINES);
    glVertex2f(3*width/4,4*height/5);
    glVertex2f( (3*width/4) + (width*cos(20*2*PI*i/360)/8),(4*height/5)
    + (width*sin(20*2*PI*i/360)/8));
    glEnd();
  }

  /* EL sol*/
  glColor3f(1.0,0.0,0.0);
  circulo(width/16,3*width/4,4*height/5);
  glColor3f(1.0,1.0,0.0);
  circulo(15*width/256,3*width/4,4*height/5);

  /*Las helices*/
  helices(width/16,3*height/8,3*height/4);
  helices(3*width/10,height/2,3*height/4);
  helices(width/2,5*height/16,3*height/4);
/*dibuja el carro*/
  carro();

  glutSwapBuffers();
  glFlush();
}
Ejemplo n.º 8
0
void EditorGarraFun::desenha_circulo(const COORDENADA& x1, const COORDENADA& y1,
                                     const COORDENADA& x2, const COORDENADA& y2,
                                     MouseFun& mouse, const pacova& t,
                                     MOUSE_EVENTO* evento)
{
  BOLEANO pinta = FALSO;
  COORDENADA antx, anty;
  ConversorFun conv;
  int raio;

  while (mouse.verifica(x1, y1, x2, y2) || pinta)
  {
    {
      COORDENADA ax = mouse.x(), ay = mouse.y();

      if (pinta)
      {
        double r, a;
        conv.converte(mouse.x(), mouse.y(), &a, &r, antx, anty);
        raio = (int) r;
      }

      setcolor(7);
      setlinestyle(1, 0, 0);
      setwritemode(XOR_PUT);

      line(ax, 0, ax, t.max_y);
      line(0, ay, t.max_x, ay);

      if (pinta)
      {
        setcolor(10);
        setlinestyle(0, 0, 0);
        circulo(x1, y1, x2, y2, antx, anty, raio);
      }

      *evento = mouse.evento_pause();

      if (pinta)
        circulo(x1, y1, x2, y2, antx, anty, raio);

      setcolor(7);
      setlinestyle(1, 0, 0);
      line(ax, 0, ax, t.max_y);
      line(0, ay, t.max_x, ay);

      setwritemode(COPY_PUT);
      setlinestyle(SOLID_LINE, 0, 0);
    }

    if (*evento == MOUSE_DOWN)
    {
      pinta = VERDADEIRO;
      antx = mouse.x();
      anty = mouse.y();
    }
    else
      if (*evento == MOUSE_UP)
      {
        if (pinta)
        {
          setcolor(15);
          setviewport(x1, y1, x2, y2, 1);
          circle(antx - 12, anty - 26, raio);
          setviewport(0, 0, t.max_x, t.max_y, 0);
          pinta = FALSO;
        }
      }
  }
}