Beispiel #1
0
void GLWidget::paintGL()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glPushMatrix();
    glRotated(xRot / 16.0, 1.0, 0.0, 0.0);
    glRotated(yRot / 16.0, 0.0, 1.0, 0.0);
    glRotated(zRot / 16.0, 0.0, 0.0, 1.0);

    drawGear(gear1, -3.0, -2.0, 0.0, gear1Rot / 16.0);
    drawGear(gear2, +3.1, -2.0, 0.0, -2.0 * (gear1Rot / 16.0) - 9.0);

    glRotated(+90.0, 1.0, 0.0, 0.0);
    drawGear(gear3, -3.1, -1.8, -2.2, +2.0 * (gear1Rot / 16.0) - 2.0);

    glPopMatrix();
}
Beispiel #2
0
void GuiGear::draw(){
    
    if ( !bPrint ){
        
        if ( bSelected ){
            ofPushStyle();
            ofSetColor(255,50);
            drawGear(true);
            ofPopStyle();
        } else {
            drawGear(false);
        }
        
        ofPushMatrix();
        ofPushStyle();
        ofTranslate(x, y);
    
        ofRotate(ofRadToDeg(angle), 0, 0, 1);
        if ( bSelected ){
            ofSetColor( 255,255 );
        } else {
            ofSetColor( ofGetStyle().color , 200);
        }
        
        ofPopStyle();
        ofPopMatrix();
        
        if ( (getSpeed() > 0.0) && bUpdating ){
            ofPushStyle();
            
            float ra = radius+15;
            float a1 = 90+15;
            float a2 = 90+30;
            float a3 = 90-30;
            float a4 = 90-15;
            
            ofSetLineWidth(0.3);
            ofSetColor( 255 , 100);
            
            ofPolyline arrow;
            arrow.arc(x, y, ra,ra, a1,a2, 60);
            arrow.draw();
            arrow.clear();
            arrow.arc(x, y, ra,ra, a3, a4, 60);
            arrow.draw();
            
            float   diff = angle - prevAngle;
            float   arrowAngle = ofDegToRad( (diff >= 0.0)? a2 : a3 );
            ofPoint arrowHead = ofPoint(x,y);
            arrowHead.x += cos( arrowAngle ) * ra;
            arrowHead.y += sin( arrowAngle ) * ra;
            
            ofPushMatrix();
            ofTranslate(arrowHead);
            ofRotate( ofRadToDeg(arrowAngle) + ((diff >= 0.0)? 180 : 0) , 0, 0, 1.0);
            ofFill();
            
            ofBeginShape();
            ofVertex(0, 0);
            ofVertex(3, 6);
            ofVertex(-3, 6);
            ofEndShape();
            
            ofPopMatrix();
            
            ofDrawBitmapString( ofToString(getSpeed(),2), ofPoint(x-15,y+ra+5));
            ofPopStyle();
        }
    } else {
        ofPushStyle();
        ofSetColor(0);
        drawGear(false);
        ofPopStyle();
    }
    
    bUpdating = false;
}