コード例 #1
0
ファイル: testApp.cpp プロジェクト: decebel/drawing-examples
//--------------------------------------------------------------
void testApp::draw(){

    
    
    ofMesh meshy;
    meshy.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
    
    
    float widthSmooth = 10;
    float angleSmooth;
    
    for (int i = 0;  i < line.getVertices().size(); i++){
        
        
        int me_m_one = i-1;
        int me_p_one = i+1;
        if (me_m_one < 0) me_m_one = 0;
        if (me_p_one ==  line.getVertices().size()) me_p_one =  line.getVertices().size()-1;
        
        ofPoint diff = line.getVertices()[me_p_one] - line.getVertices()[me_m_one];
        float angle = atan2(diff.y, diff.x);
        
        if (i == 0) angleSmooth = angle;
        else {
            
            angleSmooth = ofLerpDegrees(angleSmooth, angle, 1.0);
            
        }
        
        
        float dist = diff.length();
        
        float w = ofMap(dist, 0, 20, 40, 2, true);
        
        widthSmooth = 0.9f * widthSmooth + 0.1f * w;
        
        ofPoint offset;
        offset.x = cos(angleSmooth + PI/2) * widthSmooth;
        offset.y = sin(angleSmooth + PI/2) * widthSmooth;
        
        
        
        meshy.addVertex(  line.getVertices()[i] +  offset );
        meshy.addVertex(  line.getVertices()[i] -  offset );
        
        
        
    }
    
    ofSetColor(0,0,0);
    meshy.draw();
    ofSetColor(100,100,100);
    meshy.drawWireframe();
    
                                
            
    
}
コード例 #2
0
//--------------------------------------------------------------
void Particle::update(){
    float rot;
    if (mbIdle) {
         rot = mIdleRotation;
    } else {
        ofVec3f distVec = target - current;
        rot = atan2( target.y - current.y, target.x - current.x)/PI *180;
        //rot = (mIdleRotation*(1-mStrength) + rot*mStrength)/2.0;
        
        
    }
    rotation = ofLerpDegrees(rotation, rot, 1/mEase);

    //width = distVec.length();
}