当前位置: 首页>>代码示例>>C++>>正文


C++ ofPolyline::hasChanged方法代码示例

本文整理汇总了C++中ofPolyline::hasChanged方法的典型用法代码示例。如果您正苦于以下问题:C++ ofPolyline::hasChanged方法的具体用法?C++ ofPolyline::hasChanged怎么用?C++ ofPolyline::hasChanged使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ofPolyline的用法示例。


在下文中一共展示了ofPolyline::hasChanged方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: draw

void ropeMesh::draw(ofPolyline stroke){

    if (stroke.hasChanged()) {
        
        mesh.clear();
        
        mesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
        
        vector < ofPoint > pts = stroke.getVertices();
        
        for (int i = 0; i < pts.size(); i++){
            
            int i_m_1 = MAX(i-1,0);
            int i_p_1 = MIN(i+1, pts.size()-1);
            
            ofPoint pta = pts[i_m_1];
            ofPoint ptb = pts[i];
            ofPoint ptc = pts[i_p_1];
            
            ofPoint diff = ptc - pta;
            
            float angle = atan2(diff.y, diff.x);
            
            angle += PI/2;
            
            float width = 3; //diff.length();
            
            ofPoint offsetA;
            offsetA.x = ptb.x + width * cos(angle);
            offsetA.y = ptb.y + width * sin(angle);
            
            ofPoint offsetB;
            offsetB.x = ptb.x - width * cos(angle);
            offsetB.y = ptb.y - width * sin(angle);
            
            ofSetColor(123,94,65);
          
            ofLine(offsetA, offsetB);
            
            mesh.addVertex(offsetA);
            mesh.addVertex(offsetB);
        }
    
        ofSetColor(197,155,108);
        ofFill();
        mesh.draw();
        ofSetRectMode(OF_RECTMODE_CENTER);
        if (stroke.size()>0) {
             top[num].draw(stroke.getVertices()[stroke.size()-1], width, height);
        }
    }
    
}
开发者ID:bestpaul1985,项目名称:Thesis2013,代码行数:53,代码来源:ropeMesh.cpp


注:本文中的ofPolyline::hasChanged方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。