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


C++ ofMesh::getVertex方法代码示例

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


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

示例1: 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

示例2: setNormals

void PyramidBrush::setNormals(ofMesh& mesh) {
    
    int nV = mesh.getNumVertices();
    int nT = mesh.getNumIndices() / 3;
    
    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(3*t + 2);
        
        const ofPoint &v1 = mesh.getVertex(i1);
        const ofPoint &v2 = mesh.getVertex(i2);
        const ofPoint &v3 = mesh.getVertex(i3);
        
        ofPoint dir = ( (v2 - v1).crossed(v3 - v1)).normalized();
        
        norm[i1] += dir;
        norm[i2] += dir;
        norm[i3] += dir;
    }
    for(int i = 0; i < nV; i++) {
        norm[i].normalize();
    }
    
    mesh.clearNormals();
    mesh.addNormals(norm);
}
开发者ID:GordeyChernyy,项目名称:DrawingTool,代码行数:28,代码来源:PyramidBrush.cpp

示例3: setNormals

//Universal function which sets normals for the triangle mesh
void ofxOcean::setNormals( ofMesh &mesh ){
    //The number of the vertices
    int nV = mesh.getNumVertices();
    //The number of the triangles
    int nT = mesh.getNumIndices() / 3;
    vector<ofPoint> norm( nV ); //Array for the normals
    //Scan all the triangles. For each triangle add its
    //normal to norm's vectors of triangle's vertices
    for (int t=0; t<nT; t++) {
        //Get indices of the triangle t
        int i1 = mesh.getIndex( 3 * t );
        int i2 = mesh.getIndex( 3 * t + 1 );
        int i3 = mesh.getIndex( 3 * t + 2 );
        //Get vertices of the triangle
        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).getCrossed( v3 - v1 ) ).getNormalized();
        //Accumulate it to norm array for i1, i2, i3
        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:xfischer,项目名称:ofxOcean,代码行数:33,代码来源:ofxOcean.cpp

示例4: fuseNeighbours

void MeshHelper::fuseNeighbours( ofMesh& outputMesh, const ofMesh& sourceMesh, float fuseDistance )
{
	//@todo tex coords, normals
	assert( sourceMesh.getMode() == OF_PRIMITIVE_TRIANGLES );
	
	if ( fuseDistance < 0 )
	{
		// fuse close-enough vertices
		// first define 'close enough' as 1/10000 of smallest dimension of the bounding box width/height/depth
		ofVec3f tlb, brf; // top left back, bottom right front
		calculateAABoundingBox( sourceMesh, tlb, brf );
		float minDimension = min(brf.x-tlb.x,min(brf.y-tlb.y, brf.z-tlb.z));
		fuseDistance = minDimension * 0.00001f;
	}

	// now fuse
	map<int,int> fused;
	vector<ofVec3f> vertices;
	for ( int i=0; i<sourceMesh.getNumVertices(); i++ )
	{
		const ofVec3f& vertex = sourceMesh.getVertex(i);
		//vertex.rotate(10, 10, 10);
		bool didFuse = false;
		for ( int j=0; j<vertices.size(); j++ ) {
			if ( (vertex-vertices[j]).length()<fuseDistance ) {
				// fuse i to j
				fused[i] = j;
				didFuse = true;
				break;
			}
		}
		if ( !didFuse ) {
			vertices.push_back( vertex );
			fused[i] = vertices.size()-1;
		}
	}
		
	// build the output mesh
	outputMesh.clear();
	outputMesh.addVertices(vertices);
	if ( sourceMesh.getNumIndices() > 0 ) {
		// walk through indices to build up the new mesh
		const vector<ofIndexType>& indices = sourceMesh.getIndices();
		for ( int i=0; i<indices.size(); i+=3 ) {
			assert( fused.find( indices[i] ) != fused.end() );
			assert( fused.find( indices[i+1] ) != fused.end() );
			assert( fused.find( indices[i+2] ) != fused.end() );
			outputMesh.addTriangle( fused[indices[i]], fused[indices[i+1]], fused[indices[i+2]] );
		}
	} else {
		// triangles are just triples of vertices
		for ( int i=0; i<sourceMesh.getNumVertices(); i+=3 ) {
			outputMesh.addTriangle( fused[i], fused[i+1], fused[i+2] );
		}
	}
	
	ofLogNotice("MeshHelper") << "fuseNeighbours: input " << sourceMesh.getNumVertices() << " vertices/" << sourceMesh.getNumIndices() << " indices, output " << outputMesh.getNumVertices() << " vertices/" << outputMesh.getNumIndices() << " indices";
}
开发者ID:andreasmuller,项目名称:ofxBullet,代码行数:58,代码来源:MeshHelper.cpp

示例5: 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

示例6: 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

示例7: update

	void update() {
		int n = mesh.getNumVertices();
		int start = ofMap(mouseX, 0, ofGetWidth(), 0, n, true);
		controlPoints.clear();
		controlPoints.setMode(OF_PRIMITIVE_POINTS);
		for(int i = start; i < n; i++) {
			unsigned int index = rankedCorners[i];
			controlPoints.addVertex(mesh.getVertex(index));
		}
	}
开发者ID:YCAMInterlab,项目名称:mapamok,代码行数:10,代码来源:main.cpp

示例8: drawNormals

void ofApp::drawNormals(const ofMesh& mesh){
    for(int i = 0; i < mesh.getVertices().size(); i++){
        ofVec3f n = mesh.getNormal(i);
        ofVec3f v = mesh.getVertex(i);

        ofPushStyle();
        ofSetColor(0, 255, 0);
        ofLine(v.x, v.y, v.z, v.x + (n.x*4), v.y + (n.y*4), v.z + (n.z*4) );
        ofPopStyle();
    }
}
开发者ID:atduskgreg,项目名称:ScanSimplifier,代码行数:11,代码来源:ofApp.cpp

示例9: getNearestVertex

float getNearestVertex(const ofMesh& mesh, const ofVec2f& target, int& vertexIndex) {
	float bestDistance = 0;
	for(int i = 0; i < mesh.getNumVertices(); i++) {
		float distance = target.distance(mesh.getVertex(i));
		if(distance < bestDistance || i == 0) {
			bestDistance = distance;
			vertexIndex = i;
		}
	}
	return bestDistance;
}
开发者ID:elazrus,项目名称:ofxPuppet,代码行数:11,代码来源:ofxPuppetInteractive.cpp

示例10: sqrt

oscThread::oscThread(ofVec2f origin, ofMesh mesh)
{
    originP = mesh.getVertex(origin.x);
    destP = mesh.getVertex(origin.y);
    
    length = sqrt(pow(destP.x-originP.x,2)+pow(destP.y-originP.y,2)+pow(destP.z-originP.z,2));
    
    tempO.set(-length/2,0);
    tempD.set(length/2,0);
    
    //Rethink these variables, and in what context do they REALLY have influence?
    color    = ofRandom(255);   //Real color of braid. Fixed
    res      = 200;             //Resolution of line
    speed    = 5;               //??
    amp      = 10;              //??
    f        = 10;              //??
    
    numVerts = 0;
    tLength  = 100;
    cSpeed   = 40;
}
开发者ID:AustinSlominski,项目名称:TensionCloud,代码行数:21,代码来源:oscThread.cpp

示例11: check_triangle_intersections

// Returns true iff the mesh contains two index defined traingles that intersect.
bool check_triangle_intersections(ofMesh &mesh)
{
    
    int len = mesh.getNumIndices();
    for(int i = 0; i < len; i += 3)
    {
        ofVec3f v1 = mesh.getVertex(mesh.getIndex(i));
        ofVec3f v2 = mesh.getVertex(mesh.getIndex(i + 1));
        ofVec3f v3 = mesh.getVertex(mesh.getIndex(i + 2));
        
        for(int j = 0; j < len; j += 3)
        {
            ofVec3f p1 = mesh.getVertex(mesh.getIndex(j));
            ofVec3f p2 = mesh.getVertex(mesh.getIndex(j + 1));
            ofVec3f p3 = mesh.getVertex(mesh.getIndex(j + 2));
            
            int b  = Intersecting(p1, p2, v1, v2, v3);
            int b2 = Intersecting(p2, p3, v1, v2, v3);
            int b3 = Intersecting(p3, p1, v1, v2, v3);
            
            if(b == 1 || b2 == 1 || b3 == 1)
            {
                return true;
            }
            
            if(point_triangle_intersection(v1, v2, v3, p1)||
               point_triangle_intersection(v1, v2, v3, p2)||
               point_triangle_intersection(v1, v2, v3, p3))
            {
                return true;
            }
            
            
        }
        
    }
    
    return false;
    
}
开发者ID:Bryce-Summers,项目名称:ofMeshValidator,代码行数:41,代码来源:MeshValidator.cpp

示例12: draw

	void draw() {
		ofBackground(0);
		glPointSize(2);
		ofSetColor(32);
		historyMesh.draw();
		ofSetColor(255);
		dataMesh.draw();
		ofSetColor(255, 0, 0);
		neighborsMesh.draw();
		for(int i = 0; i < neighborsMesh.getNumVertices(); i++) {
			ofLine(neighborsMesh.getVertex(i), ofVec2f(mouseX, mouseY));
		}
		ofDrawBitmapStringHighlight(ofToString(neighborsMesh.getNumVertices()), mouseX, mouseY);
		drawFramerate();
	}
开发者ID:Abhayshar,项目名称:SharingFaces,代码行数:15,代码来源:main.cpp

示例13: addMessage

void testApp::addMessage(string address, ofMesh data) {
    ofxOscMessage msg;
    msg.setAddress(address);

    int numOfVertices = data.getNumVertices();
    for (int i = 0; i < numOfVertices; i++) {
        ofVec3f vertex = data.getVertex(i);
        msg.addFloatArg(vertex.x);
        msg.addFloatArg(vertex.y);
        msg.addFloatArg(vertex.z);
    }

    
    bundle.addMessage(msg);
}
开发者ID:atsushieee,项目名称:FaceExchange_Server,代码行数:15,代码来源:testApp.cpp

示例14: getBoundingBox

void getBoundingBox(const ofMesh& mesh, ofVec3f& min, ofVec3f& max) {
	int n = mesh.getNumVertices();
	if(n > 0) {
		min = mesh.getVertex(0);
		max = mesh.getVertex(0);
		for(int i = 1; i < n; i++) {
			const ofVec3f& cur = mesh.getVertices()[i];
			min.x = MIN(min.x, cur.x);
			min.y = MIN(min.y, cur.y);
			min.z = MIN(min.z, cur.z);
			max.x = MAX(max.x, cur.x);
			max.y = MAX(max.y, cur.y);
			max.z = MAX(max.z, cur.z);
		}
	}
}
开发者ID:kylemcdonald,项目名称:LightLeaks,代码行数:16,代码来源:ofApp.cpp

示例15: calculateAABoundingBox

void MeshHelper::calculateAABoundingBox( const ofMesh& mesh, ofVec3f& topLeftBack, ofVec3f& bottomRightFront )
{
	ofVec3f& tlb = topLeftBack;
	ofVec3f& brf = bottomRightFront;

	for ( int i=0; i<mesh.getNumVertices(); i++ ) {
		
		ofVec3f vertex = mesh.getVertex(i);
		if ( i == 0 ){
			tlb = brf = vertex;
			continue;
		}
		
		tlb.x = min(tlb.x,vertex.x);
		tlb.y = min(tlb.y,vertex.y);
		tlb.z = min(tlb.z,vertex.z);
		brf.x = max(brf.x,vertex.x);
		brf.y = max(brf.y,vertex.y);
		brf.z = max(brf.z,vertex.z);
	}
}
开发者ID:andreasmuller,项目名称:ofxBullet,代码行数:21,代码来源:MeshHelper.cpp


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