• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ ofMesh类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: updateMesh

	void updateMesh(ofMesh& mesh)
	{
		float t = ofGetElapsedTimef();
		
		ofVec3f axis;
		axis.x = ofSignedNoise(1, 0, 0, t);
		axis.y = ofSignedNoise(0, 1, 0, t);
		axis.z = ofSignedNoise(0, 0, 1, t);
		axis.normalize();
		
		vector<ofVec3f>& verts = mesh.getVertices();
		vector<ofVec3f>& norms = mesh.getNormals();
		for (int i = 0; i < verts.size(); i++)
		{
			ofVec3f& v = verts[i];
			ofVec3f& n = norms[i];
			ofVec3f vv = v;
			
			float r = vv.y * fmodf(t, 10) * 0.1;
			
			vv.rotate(r, axis);
			n.rotate(r, axis);
			
			v = vv;
		}
	}
开发者ID:satoruhiga,项目名称:ofws20014,代码行数:26,代码来源:ofApp.cpp


示例2: updateMesh

//--------------------------------------------------------------
void ofxBulletTriMeshShape::updateMesh( btDiscreteDynamicsWorld* a_world, ofMesh& aMesh ) {
    if( aMesh.getNumVertices() != totalVerts || aMesh.getNumIndices() != totalIndices ) {
        ofLogWarning() << "updateMesh :: the verts or the indices are not the correct size, not updating";
        return;
    }
    
    auto& tverts = aMesh.getVertices();
    
    btVector3 aabbMin(BT_LARGE_FLOAT,BT_LARGE_FLOAT,BT_LARGE_FLOAT);
    btVector3 aabbMax(-BT_LARGE_FLOAT,-BT_LARGE_FLOAT,-BT_LARGE_FLOAT);
    
    for( int i = 0; i < totalVerts; i++ ) {
        auto& v = tverts[i];
        bullet_vertices[i].setValue( v.x, v.y, v.z );
        
        aabbMin.setMin( bullet_vertices[i] );
        aabbMax.setMax( bullet_vertices[i] );
    }
    
    btBvhTriangleMeshShape* triShape = (btBvhTriangleMeshShape*)_shape;
//    triShape->partialRefitTree( aabbMin, aabbMax );
    triShape->refitTree( aabbMin, aabbMax );
    
    //clear all contact points involving mesh proxy. Note: this is a slow/unoptimized operation.
    a_world->getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs( getRigidBody()->getBroadphaseHandle(), a_world->getDispatcher());
}
开发者ID:NickHardeman,项目名称:ofxBullet,代码行数:27,代码来源:ofxBulletTriMeshShape.cpp


示例3: pushVertex

void BGGraphics::pushCirclePart(ofMesh& mesh, ofVec2f position, float nodeRadius, float minAngle, float deltaAngle) {

    mesh.setMode(OF_PRIMITIVE_TRIANGLES);

    pushVertex(mesh, position.x, position.y, 1, 0, 0, 1, 0, 0);

    float innerRadius = nodeRadius - NETWORK_OFFSET;

    float internalOffsetY = .5;// innerRadius / nodeRadius;

    int samples = (int)(15 * deltaAngle / M_PI);
    samples = max(1, samples);

    for(int i=0; i<samples; ++i) {
        float angle = minAngle + deltaAngle * i / (float)(samples - 1);
        ofVec2f to(cosf(angle), sinf(angle));

        ofVec2f p1 = position + to * innerRadius;
        ofVec2f p2 = position + to * nodeRadius;

        //pushVertex(ofMesh & mesh, float x, float y, float z, float nx, float ny, float nz, float offsetX, float offsetY) 
        pushVertex(mesh, p1.x, p1.y, 1, 0, 0, 1, 0, internalOffsetY);
        pushVertex(mesh, p2.x, p2.y, 0, to.x, to.y, 0, 0, 1);

        if(i > 0) {
            int offset = 1 + 2 * i;
            mesh.addTriangle(0, offset - 2, offset);
            mesh.addTriangle(offset - 2, offset - 1, offset);
            mesh.addTriangle(offset - 1, offset, offset + 1);
        }
    }
}
开发者ID:guidosoetens,项目名称:visualtest,代码行数:32,代码来源:BGGraphics.cpp


示例4: updateMesh

//--------------------------------------------------------------
void ofxBulletSoftTriMesh::updateMesh( ofMesh& aMesh ) {
    
    int totalNodes = getNumNodes();
    auto& tverts = aMesh.getVertices();
    
    if( _cachedMesh.getMode() == OF_PRIMITIVE_TRIANGLES ) {
        
        if( tverts.size() != totalNodes ) {
            tverts.resize( totalNodes );
        }
        
        auto& tnormals = aMesh.getNormals();
        if( aMesh.getNumNormals() != totalNodes ) {
            tnormals.resize( totalNodes );
        }
        
        for( int i = 0; i < totalNodes; i++ ) {
            tverts[i].x = _softBody->m_nodes[i].m_x.x();
            tverts[i].y = _softBody->m_nodes[i].m_x.y();
            tverts[i].z = _softBody->m_nodes[i].m_x.z();
            
            tnormals[i].x = _softBody->m_nodes[i].m_n.x();
            tnormals[i].y = _softBody->m_nodes[i].m_n.y();
            tnormals[i].z = _softBody->m_nodes[i].m_n.z();
        }
        
    }
    
    _lastMeshUpdateFrame = ofGetFrameNum();
}
开发者ID:NickHardeman,项目名称:ofxBullet,代码行数:31,代码来源:ofxBulletSoftTriMesh.cpp


示例5: createMesh

void ofxPolyline::createMesh(ofMesh &mesh, int begin, int end) {
    
    if (end - begin == 1) {
        // If only two points, just make a line.
        mesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
        
        pair<ofVec2f, ofVec2f> joint = jointBegin((*this)[begin], (*this)[end], width);
        mesh.addVertex(joint.first);
        mesh.addVertex(joint.second);
        
        joint = jointEnd((*this)[begin], (*this)[end], width);
        mesh.addVertex(joint.first);
        mesh.addVertex(joint.second);
        return;
    } else if (end - begin == 0) {
        // Return no mesh
        return;
    }
    
    // More than two points
    if (strokeLinejoin == OFXSVG_STROKE_LINEJOIN_MITER) {
        createMeshMiterJoint(mesh, begin, end);
    } else if (strokeLinejoin == OFXSVG_STROKE_LINEJOIN_BEVEL) {
        createMeshBevelJoint(mesh, begin, end);
    } else if (strokeLinejoin == OFXSVG_STROKE_LINEJOIN_ROUND) {
        createMeshRoundJoint(mesh, begin, end);
    }
}
开发者ID:kokinomura,项目名称:SvgLineAnimation,代码行数:28,代码来源:ofxPath.cpp


示例6: ofBitmapStringGetMesh

ofMesh & ofBitmapStringGetMesh(const string & text, int x, int y){

	int len = (int)text.length();
	//float yOffset = 0;
	float fontSize = 8.0f;
	bool bOrigin = false;

	float sx = x;
	float sy = y-fontSize;

	ofDrawBitmapCharacterStart(text.size());

	for(int c = 0; c < len; c++){
		if(text[c] == '\n'){

			sy += bOrigin ? -1 : 1 * (fontSize*1.7);
			sx = x;

			//glRasterPos2f(x,y + (int)yOffset);
		} else if (text[c] >= 32){
			// < 32 = control characters - don't draw
			// solves a bug with control characters
			// getting drawn when they ought to not be
			ofDrawBitmapCharacter(text[c], (int)sx, (int)sy);

			sx += fontSize;
		}
	}
	//We do this because its way faster
	charMesh.getVertices().resize(vC);
	charMesh.getTexCoords().resize(vC);
	return charMesh;

}
开发者ID:AnnaKolla,项目名称:openFrameworks,代码行数:34,代码来源:ofBitmapFont.cpp


示例7: getClosestTripletOnMesh

int getClosestTripletOnMesh(const ofMesh& objectMesh,const ofMesh& imageMesh, float x, float y, float* distance) {
    
    float bestDistance = numeric_limits<float>::infinity();
    int bestChoice = 0;
    
    for(int i = 0; i < objectMesh.getNumIndices()/3; i++) {
        
		ofVec3f cur = ofVec3f(0,0,0);
        for (int j=0;j<3;j++) {
            cur+=imageMesh.getVerticesPointer()[objectMesh.getIndexPointer()[3*i+j]];
        }
        
        cur/=3.0;
        
		float dx = x - cur.x;
		float dy = y - cur.y;
        float dz = 0 - cur.z;
		float curDistance = dx * dx + dy * dy + dz * dz;
		if(curDistance < bestDistance) {
			bestDistance = curDistance;
			bestChoice = i;
		}
	}
    
    return bestChoice;
}
开发者ID:roikr,项目名称:openFrameworks007,代码行数:26,代码来源:ofxRKProCamToolkit.cpp


示例8: ofxScale

 void ofxScale(ofMesh &mesh, float x, float y, float z) {
     for (int i=0; i<mesh.getNumVertices(); i++) {
       mesh.getVertices()[i].x *= x;
       mesh.getVertices()[i].y *= y;
       mesh.getVertices()[i].z *= z;
     }
 }
开发者ID:companje,项目名称:ChineseFontTest,代码行数:7,代码来源:main.cpp


示例9: convertFromIndices

ofMesh convertFromIndices(const ofMesh& mesh) {
	ofMesh result;
	// have to do a const_cast because ofMesh::get*() is not const correct
	ofMesh& cmesh = const_cast<ofMesh&>(mesh);
	int vertices = mesh.getNumVertices();
	int colors = mesh.getNumColors();
	int normals = mesh.getNumNormals();
	int texcoords = mesh.getNumTexCoords();
	int indices = mesh.getNumIndices();
	for(int i = 0; i < indices; i++) {
		int cur = cmesh.getIndex(i);
		if(vertices > 0) {
			result.addVertex(cmesh.getVertex(cur));
		}
		if(colors > 0) {
			result.addColor(cmesh.getColor(cur));
		}
		if(normals > 0) {
			result.addNormal(cmesh.getNormal(cur));
		}
		if(texcoords > 0) {
			result.addTexCoord(cmesh.getTexCoord(cur));
		}
	}
	return result;
}
开发者ID:imclab,项目名称:facepp,代码行数:26,代码来源:useful.cpp


示例10: setMesh

//--------------------------------------------------------------
void ofVboByteColor::setMesh(const ofMesh & mesh, int usage){
	setVertexData(mesh.getVerticesPointer(),mesh.getNumVertices(),usage);
	setColorData(mesh.getColorsPointer(),mesh.getNumColors(),usage);
	setNormalData(mesh.getNormalsPointer(),mesh.getNumNormals(),usage);
	setTexCoordData(mesh.getTexCoordsPointer(),mesh.getNumTexCoords(),usage);
	setIndexData(mesh.getIndexPointer(), mesh.getNumIndices(), usage);
}
开发者ID:CLOUDS-Interactive-Documentary,项目名称:CLOUDS,代码行数:8,代码来源:ofVboByteColor.cpp


示例11: addCircle

//http://www.packtpub.com/sites/default/files/9781849518048_Chapter_07.pdf
//knotExample
void ofApp::addCircle( ofVec3f nextPoint, ofMesh &mesh ){
    float time = ofGetElapsedTimef();    //Time
    //Parameters – twisting and rotating angles and color

    ofFloatColor color( ofNoise( time * 0.05 ),
                       ofNoise( time * 0.1 ),
                       ofNoise( time * 0.15 ));
    color.setSaturation( 1.0 );  //Make the color maximally
    
    //Add vertices
    for (int i=0; i<circleN; i++) {
        float angle = float(i) / circleN * TWO_PI+(PI*0.25);
        float x = Rad * cos( angle );
        float y = Rad * sin( angle );
        ofPoint p =    nextPoint+ofVec3f(x ,y , 0);
        mesh.addVertex( p );
        mesh.addColor( color );
    }
    //Add the triangles
    int base = mesh.getNumVertices() - 2 * circleN;
    if ( base >= 0 ) {  //Check if it is not the first step
        //and we really need to add the triangles
        for (int i=0; i<circleN; i++) {
            int a = base + i;
            int b = base + (i + 1) % circleN;
            int c = circleN  + a;
            int d = circleN  + b;
            mesh.addTriangle(a,b,d);
            mesh.addTriangle(a, d, c);
        }
        //Update the normals
        setNormals( mesh );
    }
}
开发者ID:fishkingsin,项目名称:ribbonTunnel,代码行数:36,代码来源:ofApp.cpp


示例12: colorFaces

//--------------------------------------------------------------
void ofApp::colorFaces(ofMesh & mesh){
	for(int i = 0; i < mesh.getVertices().size(); i++){
		const ofVec3f & v = mesh.getVertices()[i];
		ofColor col;
		col.setHsb(ofMap(v.x + v.y, -1000, 1000, 0, 255), 255, 255);
		mesh.addColor(col);
	}
}
开发者ID:danielmorena,项目名称:OF_GenerativeTypography,代码行数:9,代码来源:ofApp.cpp


示例13: deformMesh

ofMesh ofxFfd::deformMesh(ofMesh mesh){
    ofMesh dst;
    dst.append(mesh);
    for ( int i=0; i<mesh.getNumVertices(); i++ ) {
        ofVec3f vec = mesh.getVertex(i);
        dst.setVertex(i, deform(vec));
    }
    return dst;
}
开发者ID:yusuketomoto,项目名称:ofxFfd,代码行数:9,代码来源:ofxFfd.cpp


示例14: getCentroid

ofVec3f getCentroid(ofMesh& mesh){
    ofVec3f sum;
    for(int i=0;i<mesh.getNumVertices();i++){
        sum+=mesh.getVertex(i);
    }
    sum/=mesh.getNumVertices();
    
    return sum;
}
开发者ID:merceditas008,项目名称:AppropriatingNewTechnologies,代码行数:9,代码来源:testApp.cpp


示例15: ofSetTextureWrap

//--------------------------------------------------------------
void testApp::draw(){
    fbo.begin();
        ofSetTextureWrap(GL_REPEAT,GL_REPEAT);
        fbfbo.draw(0,2);
    //cam.draw(0,0);
        fbfbo.getTextureReference().bind();
        trik2.draw();
        fbfbo.getTextureReference().unbind();
        
        ofSetColor(255,255,255);
    if(tritimer>tritimerlimit){
        float xpt, ypt,xtoff,ytoff;
        //draw gradient splashes
        ofMesh trik;
        for(int b = 0;b<5;b++){
            xtoff = ofRandomf()*0.5;
            ytoff = ofRandomf()*0.5;
            for(int i=0;i<3;i++){
                xpt = ofRandomuf()*2+xtoff;
                ypt = ofRandomuf()*2+ytoff;
                trik.addVertex(ofVec3f(xpt*w,ypt*h,0));
                trik.addColor(ofFloatColor(float(ofRandomuf()>0.5)*0.6+0.4,float(ofRandomuf()>0.5)*0.5+0.5,float(ofRandomuf()>0.5)*0.7+0.3));
            }
        }
        trik.draw();
        tritimer = 0;
        tritimerlimit= ofRandom(20,200);
    }
    
    if(tritimer2>45){
        //re-generate the feedback triangles
        float xpt, ypt,xoff,yoff,xtoff,ytoff;
        trik2.clear();
        //ofEnableNormalizedTexCoords();
        for(int b = 0;b<5;b++){
            xoff = ofRandomf()*0.1;
            yoff = ofRandomf()*0.1;
            xtoff = ofRandomf()*0.5;
            ytoff = ofRandomf()*0.5;
            for(int i=0;i<3;i++){
                xpt = ofRandomuf()+xtoff;
                ypt = ofRandomuf()+ytoff;
                trik2.addVertex(ofVec3f((xpt+xoff)*w,(ypt+yoff)*h,0));
                trik2.addTexCoord(ofVec2f(xpt*w,ypt*h));
                trik2.addColor(ofFloatColor(1,1,1));
            }
        }
        tritimer2=0;
        tritimer2limit= ofRandom(20,200);
        //ofDisableNormalizedTexCoords();
    }
    fbo.end();
    fbfbo.begin();
    fbo.draw(0,0);
    fbfbo.end();
    fbo.draw(0,0);
}
开发者ID:pixlpa,项目名称:pxPAPI,代码行数:58,代码来源:testApp.cpp


示例16: getProjectedMesh

ofMesh getProjectedMesh(const ofMesh& mesh) {
	ofMesh projected = mesh;
    for(std::size_t i = 0; i < mesh.getNumVertices(); i++) {
		glm::vec3 cur = ofWorldToScreen(mesh.getVerticesPointer()[i]);
		cur.z = 0;
		projected.setVertex(i, cur);
	}
	return projected;
}
开发者ID:kylemcdonald,项目名称:ofxFaceTracker,代码行数:9,代码来源:ofApp.cpp


示例17: create

//--------------------------------------------------------------
void ofxBulletSoftTriMesh::create( ofxBulletWorldSoft* a_world, ofMesh& aMesh, btTransform &a_bt_tr, float a_mass ) {
    
    if(a_world == NULL) {
        ofLogError("ofxBulletSoftTriMesh") << "create(): a_world param is NULL";
        return;
    }
    
    if( aMesh.getMode() != OF_PRIMITIVE_TRIANGLES ) {
        ofLogError("ofxBulletSoftTriMesh") << " only excepts meshes that are triangles";
        return;
    }
    
    _world = a_world;
    
    _cachedMesh.clear();
    _cachedMesh = aMesh;
    
    if( bullet_vertices != NULL ) {
        delete bullet_vertices;
        bullet_vertices = NULL;
    }
    
    int vertStride  = sizeof(btVector3);
    int indexStride = 3*sizeof(int);
    
    int totalVerts    = (int)aMesh.getNumVertices();
    int totalIndices  = (int)aMesh.getNumIndices();
    
    bullet_vertices = new btScalar[ totalVerts * 3 ];
    int* bullet_indices = new int[ totalIndices ];
    
    auto& tverts       = aMesh.getVertices();
    vector< ofIndexType >& tindices = aMesh.getIndices();
    
    for( int i = 0; i < totalVerts; i++ ) {
        bullet_vertices[i*3+0] = tverts[i].x;
        bullet_vertices[i*3+1] = tverts[i].y;
        bullet_vertices[i*3+2] = tverts[i].z;
    }
    for( int i = 0; i < totalIndices; i++ ) {
        bullet_indices[i] = tindices[i];
    }
    
    _softBody = btSoftBodyHelpers::CreateFromTriMesh( _world->getInfo(),
                                                         bullet_vertices,
                                                         bullet_indices,
                                                         totalIndices/3 );
    _softBody->transform( a_bt_tr );
    setMass( a_mass, true );
    
    setCreated(_softBody);
    createInternalUserData();

    delete [] bullet_indices;
    
}
开发者ID:NickHardeman,项目名称:ofxBullet,代码行数:57,代码来源:ofxBulletSoftTriMesh.cpp


示例18: drawChunkyCloud

void drawChunkyCloud(ofMesh& mesh, ofColor color, int innerRadius = 1, int outerRadius = 3) {
	ofPushStyle();
	ofSetColor(0);
	glPointSize(outerRadius);
	mesh.draw();
	ofSetColor(color);
	glPointSize(innerRadius);
	mesh.draw();
	ofPopStyle();
}
开发者ID:cibomahto,项目名称:Missing,代码行数:10,代码来源:MissingTracker.cpp


示例19: setNormals

//--------------------------------------------------------------
//Universal function which sets normals for the triangle mesh
void setNormals( ofMesh &mesh ){
    
    int nV = mesh.getNumVertices();//640
    int nT = mesh.getNumIndices() / 3;//213
    
    vector<ofPoint> norm( nV );
    
    for (int t=0; t<nT; t++) {
        
        int i1 = mesh.getIndex( 3 * t );
        int i2 = mesh.getIndex( 3 * t + 1 );
        int i3 = mesh.getIndex( 641 );
        
        const ofPoint &v1 = mesh.getVertex( i1 );
        const ofPoint &v2 = mesh.getVertex( i2 );
        const ofPoint &v3 = mesh.getVertex( i3 );
        
        //Compute the triangle's normal
        ofPoint dir = ( (v2 - v1).crossed( v3 - v1 ) ).normalized();
        
        norm[ i1 ] += dir;
        norm[ i2 ] += dir;
        norm[ i3 ] += dir;
    }
    
    //Normalize the normal's length
    for (int i=0; i<nV; i++) {
        norm[i].normalize();
    }
    
    //Set the normals to mesh
    mesh.clearNormals();
    mesh.addNormals( norm );
}
开发者ID:superpeachman,项目名称:BotB20160116,代码行数:36,代码来源:Human.cpp


示例20: ofxNDCircularGradient

void ofxNDCircularGradient(float radius, const ofColor & start, const ofColor & end)
{
    int n = 32; // circular gradient resolution
    static ofMesh _nd_cg_mesh;

    _nd_cg_mesh.clear();
    _nd_cg_mesh.setMode(OF_PRIMITIVE_TRIANGLE_FAN);
    
    ofVec2f center(0,0);
    _nd_cg_mesh.addVertex(center);

    float angleBisector = TWO_PI / (n * 2);
    float smallRadius = radius;
    float bigRadius = smallRadius / cos(angleBisector);
    for(int i = 0; i <= n; i++) {
        float theta = i * TWO_PI / n;
        _nd_cg_mesh.addVertex(center + ofVec2f(sin(theta), cos(theta)) * bigRadius);
    }
    
    _nd_cg_mesh.clearColors();
    _nd_cg_mesh.addColor(start);
    for(int i = 0; i <= n; i++) {
        _nd_cg_mesh.addColor(end);
    }
    
    _nd_cg_mesh.draw();
}
开发者ID:ndonald2,项目名称:drawAndFade,代码行数:27,代码来源:ofxNDGraphicsUtils.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ofMutex类代码示例发布时间:2022-05-31
下一篇:
C++ ofMatrix4x4类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap