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


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

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


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

示例1: setup

	void setup() {
		useSharedData();
		data.setup(ofGetWidth(), ofGetHeight(), 8);
		historyMesh.setMode(OF_PRIMITIVE_POINTS);
		dataMesh.setMode(OF_PRIMITIVE_POINTS);
		neighborsMesh.setMode(OF_PRIMITIVE_POINTS);
	}
开发者ID:Abhayshar,项目名称:SharingFaces,代码行数:7,代码来源:main.cpp

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

示例3: createMeshBevelJoint

//---------------------------------------------------------
void ofxPolyline::createMeshBevelJoint(ofMesh &mesh, int begin, int end) {
    
    mesh.setMode(OF_PRIMITIVE_TRIANGLES);
    
    // Starting point
    pair<ofVec2f, ofVec2f> jb1 = jointBegin((*this)[begin], (*this)[begin+1], width);
    pair<vector<ofVec2f>, vector<ofVec2f> > jb2 = bevelJoint((*this)[begin], (*this)[begin+1], (*this)[begin+2], width);
    
    mesh.addVertex(jb1.first);
    mesh.addVertex(jb1.second);
    mesh.addVertex(jb2.first.front());
    
    mesh.addVertex(jb1.second);
    mesh.addVertex(jb2.first.front());
    mesh.addVertex(jb2.second.front());
    
    // Between both ends
    for (int i=begin+1; i<end-1; i++) {
        pair<vector<ofVec2f>, vector<ofVec2f> > j1 = bevelJoint((*this)[i-1], (*this)[i], (*this)[i+1], width);
        pair<vector<ofVec2f>, vector<ofVec2f> > j2 = bevelJoint((*this)[i], (*this)[i+1], (*this)[i+2], width);
        
        // triangle of bevel joint
        for (int i=0; i<j1.first.size(); i++) {
            mesh.addVertex(j1.first[i]);
        }
        for (int i=0; i<j1.second.size(); i++) {
            mesh.addVertex(j1.second[i]);
        }
        
        // the two points of the bevel triangle + next left point
        mesh.addVertex(j1.first.back());
        mesh.addVertex(j1.second.back());
        mesh.addVertex(j2.first.front());
        
        // right point of the bevel triangle + next left point
        mesh.addVertex(j1.second.back());
        mesh.addVertex(j2.first.front());
        mesh.addVertex(j2.second.front());
        
    }
    
    // End point
    pair<vector<ofVec2f>, vector<ofVec2f> > je1 = bevelJoint((*this)[end-2], (*this)[end-1], (*this)[end], width);
    pair<ofVec2f, ofVec2f> je2 = jointEnd((*this)[end-1], (*this)[end], width);
    
    for (int i=0; i<je1.first.size(); i++) {
        mesh.addVertex(je1.first[i]);
    }
    for (int i=0; i<je1.second.size(); i++) {
        mesh.addVertex(je1.second[i]);
    }
    
    mesh.addVertex(je1.first.back());
    mesh.addVertex(je1.second.back());
    mesh.addVertex(je2.first);
    
    mesh.addVertex(je1.second.back());
    mesh.addVertex(je2.first);
    mesh.addVertex(je2.second);
}
开发者ID:kokinomura,项目名称:SvgLineAnimation,代码行数:61,代码来源:ofxPath.cpp

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

示例5: setup

 void setup() {
     vid.initGrabber(w, h);
     mesh.setMode(OF_PRIMITIVE_POINTS);
     mesh.addVertices(vector<ofVec3f>(n));
     mesh.addColors(vector<ofFloatColor>(n));
     
 }
开发者ID:nimabeh,项目名称:CCLab_oF_Final,代码行数:7,代码来源:main.cpp

示例6: pushCirclePart

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

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

//--------------------------------------------------------------
ofMesh testApp::pixelManipulate(ofImage imageA, ofMesh meshA, float intensityThreshold, float sketchDepth){
    
    
    imageA.resize(200, 200);
    
    //create mesh with points as the primitive
    //meshA.setMode(OF_PRIMITIVE_POINTS);
    
    //create a mesh with lines
      meshA.setMode(OF_PRIMITIVE_LINE_LOOP);
    
    //meshA.setMode(OF_PRIMITIVE_LINE_STRIP);
    
    
    int w = imageA.getWidth();
    
    int h = imageA.getHeight();
    
    //loop through each pixel in the image using image width & height
    for (int x=0; x<w; x++){
        for(int y=0; y<h; y++){
            
            //create the color object at that pixel
            //ofColor c = imageA.getColor(x, y);
            
            ofColor c = imageA.getColor(x, y);

            
            //check the intensity of the pixel's color
            float intensity = c.getLightness();
            
            //if the intensity exceeds the threshold, create a vertex at the location of the pixel
            //& color it with the pixel's color
            if (intensity >= intensityThreshold){
                
                //pushes brighter colors in the positive z direction
                //pushes whiter colors in the negative z direction
                float saturation = c.getSaturation();
                float z = ofMap(saturation, 0, 255, -sketchDepth, sketchDepth);
                
                //the image is now 1/4 the size of the OF window, so multiply
                //the pixel location by 4 so that the mesh covers the OF window
                ofVec3f pos(5*x, 4*y, z);
                meshA.addVertex(pos);
                meshA.addColor(c);
            }
        }
    }
    
    return meshA;
}
开发者ID:joselynNeon,项目名称:dtplayfulsystems,代码行数:52,代码来源:testApp.cpp

示例9: aiMeshToOfMesh

//--------------------------------------------------------------
static void aiMeshToOfMesh(const aiMesh* aim, ofMesh& ofm, ofxAssimpMeshHelper * helper = NULL){

	// default to triangle mode
	ofm.setMode(OF_PRIMITIVE_TRIANGLES);

	// copy vertices
	for (int i=0; i < (int)aim->mNumVertices;i++){
		ofm.addVertex(ofVec3f(aim->mVertices[i].x,aim->mVertices[i].y,aim->mVertices[i].z));
	}

	if(aim->HasNormals()){
		for (int i=0; i < (int)aim->mNumVertices;i++){
			ofm.addNormal(ofVec3f(aim->mNormals[i].x,aim->mNormals[i].y,aim->mNormals[i].z));
		}
	}

	// aiVector3D * 	mTextureCoords [AI_MAX_NUMBER_OF_TEXTURECOORDS]
	// just one for now
	if(aim->GetNumUVChannels()>0){
		for (int i=0; i < (int)aim->mNumVertices;i++){
			if( helper != NULL && helper->texture.getWidth() > 0.0 ){
				ofVec2f texCoord = helper->texture.getCoordFromPercent(aim->mTextureCoords[0][i].x ,aim->mTextureCoords[0][i].y);
				ofm.addTexCoord(texCoord);
			}else{
				ofm.addTexCoord(ofVec2f(aim->mTextureCoords[0][i].x ,aim->mTextureCoords[0][i].y));			
			}
		}
	}

	//aiColor4D * 	mColors [AI_MAX_NUMBER_OF_COLOR_SETS]
	// just one for now
	if(aim->GetNumColorChannels()>0){
		for (int i=0; i < (int)aim->mNumVertices;i++){
			ofm.addColor(aiColorToOfColor(aim->mColors[0][i]));
		}
	}

	for (int i=0; i <(int) aim->mNumFaces;i++){
		if(aim->mFaces[i].mNumIndices>3){
			ofLog(OF_LOG_WARNING,"non-triangular face found: model face # " + ofToString(i));
		}
		for (int j=0; j<(int)aim->mFaces[i].mNumIndices; j++){
			ofm.addIndex(aim->mFaces[i].mIndices[j]);
		}
	}

	ofm.setName(string(aim->mName.data));
	//	ofm.materialId = aim->mMaterialIndex;
}
开发者ID:6301158,项目名称:openFrameworks_0.071_debian_package,代码行数:50,代码来源:ofxAssimpModelLoader.cpp

示例10: meshFromFbo

void CloudsVisualSystemNbody::meshFromFbo(ofFbo& fbo, ofMesh& mesh){
	
	mesh.addTexCoord(ofVec2f(0,0));
	mesh.addVertex(ofVec3f(0,0,0));
	
	mesh.addTexCoord(ofVec2f(fbo.getWidth(),0));
	mesh.addVertex(ofVec3f(fbo.getWidth(),0,0));
	
	mesh.addTexCoord(ofVec2f(0,fbo.getHeight()));
	mesh.addVertex(ofVec3f(0,fbo.getHeight(),0));
	
	mesh.addTexCoord(ofVec2f(fbo.getWidth(),fbo.getHeight()));
	mesh.addVertex(ofVec3f(fbo.getWidth(),fbo.getHeight(),0));
	
	mesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
	
}
开发者ID:CLOUDS-Interactive-Documentary,项目名称:CLOUDS,代码行数:17,代码来源:CloudsVisualSystemNbody.cpp

示例11: texturedRect

void texturedRect(float width, float height) {
	if(texturedRectMesh.getNumVertices() == 0) {
		texturedRectMesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
		texturedRectMesh.addTexCoord(ofVec2f(0, 0));
		texturedRectMesh.addVertex(ofVec2f(0, 0));
		texturedRectMesh.addTexCoord(ofVec2f(0, 1));
		texturedRectMesh.addVertex(ofVec2f(0, 1));
		texturedRectMesh.addTexCoord(ofVec2f(1, 0));
		texturedRectMesh.addVertex(ofVec2f(1, 0));
		texturedRectMesh.addTexCoord(ofVec2f(1, 1));
		texturedRectMesh.addVertex(ofVec2f(1, 1));
	}
	ofPushMatrix();
	ofScale(width, height);
	texturedRectMesh.drawFaces();
	ofPopMatrix();
}
开发者ID:Mat-Loz,项目名称:FaceSubstitution,代码行数:17,代码来源:testApp.cpp

示例12: createMeshMiterJoint

//---------------------------------------------------------
void ofxPolyline::createMeshMiterJoint(ofMesh &mesh, int begin, int end) {
    mesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
    
    // Starting point
    pair<ofVec2f, ofVec2f> joint = jointBegin((*this)[begin], (*this)[begin+1], width);
    mesh.addVertex(joint.first);
    mesh.addVertex(joint.second);    
    
    // Between both ends
    for (int i=begin+1; i<end-1; i++) {
        joint = miterJoint((*this)[i-1], (*this)[i], (*this)[i+1], width);
        mesh.addVertex(joint.first);
        mesh.addVertex(joint.second);
    }
    
    // End point
    joint = jointEnd((*this)[end-1], (*this)[end], width);
    mesh.addVertex(joint.first);
    mesh.addVertex(joint.second);
}
开发者ID:kokinomura,项目名称:SvgLineAnimation,代码行数:21,代码来源:ofxPath.cpp

示例13: prepareBitmapTexture

//---------------------------------------------------------------------
static void prepareBitmapTexture(){

			
	
	if (!bBitmapTexturePrepared){
		myLetterPixels.allocate(16*16, 16*16, 4); // letter size:8x14pixels, texture size:16x8letters, gl_rgba: 4bytes/1pixel
        myLetterPixels.set(0);

		bitmappedFontTexture.allocate(16*16, 16*16, GL_RGBA, false);
		
		bBitmapTexturePrepared = true;
		
		for (int i = 0; i < 256; i++) {
			
			const unsigned char * face = bmpChar_8x13_Map[i];
			
			for (int j = 1; j < 15; j++){
				for (int k = 0; k < 8; k++){
					if ( ((face[15-j] << k) & (128)) > 0 ){
						myLetterPixels[(((int)(i/16))*16*16*16+(i%16)*16 + (j-1)*16*16 + k)*4] = 255;
						myLetterPixels[(((int)(i/16))*16*16*16+(i%16)*16 + (j-1)*16*16 + k)*4+1] = 255;
						myLetterPixels[(((int)(i/16))*16*16*16+(i%16)*16 + (j-1)*16*16 + k)*4+2] = 255;
						myLetterPixels[(((int)(i/16))*16*16*16+(i%16)*16 + (j-1)*16*16 + k)*4+3] = 255;
					}else{
						myLetterPixels[(((int)(i/16))*16*16*16+(i%16)*16 + (j-1)*16*16 + k)*4] = 0;
						myLetterPixels[(((int)(i/16))*16*16*16+(i%16)*16 + (j-1)*16*16 + k)*4+1] = 0;
						myLetterPixels[(((int)(i/16))*16*16*16+(i%16)*16 + (j-1)*16*16 + k)*4+2] = 0;
						myLetterPixels[(((int)(i/16))*16*16*16+(i%16)*16 + (j-1)*16*16 + k)*4+3] = 0;
					}
				}
			}
		}
		
		bitmappedFontTexture.loadData(myLetterPixels);
		bitmappedFontTexture.setTextureMinMagFilter(GL_LINEAR,GL_NEAREST);

		charMesh.setMode(OF_PRIMITIVE_TRIANGLES);
		
	}

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

示例14: performTessellation

//----------------------------------------------------------
void ofTessellator::performTessellation(ofPolyWindingMode polyWindingMode, ofMesh& dstmesh, bool bIs2D ) {

	if (!tessTesselate(cacheTess, polyWindingMode, TESS_POLYGONS, 3, 3, 0)){
		ofLogError("ofTessellator") << "performTessellation(): mesh polygon tessellation failed, winding mode " << polyWindingMode;
		return;
	}

	int numVertices = tessGetVertexCount( cacheTess );
	int numIndices = tessGetElementCount( cacheTess )*3;

	dstmesh.clear();
	dstmesh.addVertices((ofDefaultVertexType*)tessGetVertices(cacheTess),numVertices);
	dstmesh.addIndices((ofIndexType*)tessGetElements(cacheTess),numIndices);
	/*ofIndexType * tessElements = (ofIndexType *)tessGetElements(cacheTess);
	for(int i=0;i<numIndices;i++){
		if(tessElements[i]!=TESS_UNDEF)
			dstmesh.addIndex(tessElements[i]);
	}*/
	dstmesh.setMode(OF_PRIMITIVE_TRIANGLES);

}
开发者ID:Ahbee,项目名称:openFrameworks,代码行数:22,代码来源:ofTessellator.cpp

示例15: createSegmentedMeshTriangles

void ofApp::createSegmentedMeshTriangles(const ofVec3f& center,
                            ofMesh &mesh,
                            double radius,
                           	double limitH,
                            int textWidth,
                            int textHeight)
	//using triangles only
{

	int h, drawH, drawW, w;
	int divNumber = 32;
	double theta, phi, phi_1, limitW;
	ofVec3f p;

	mesh.clear();

	//Handle special cases 
    if (radius < 0)
        radius = -radius;
    if (precision < 0)
        precision = -precision;
    if (precision < 4 || radius <= 0) {
        mesh.addVertex(center);
    return;
    }

	mesh.setMode(OF_PRIMITIVE_TRIANGLES);

	//limitH = 3.14 / (double) hDivNumber;
	
	limitW = limitH * (textWidth/(double)textHeight);

	drawH = textHeight / divNumber;
	drawW = textWidth / divNumber;

	for(h = 0; h < drawH;  h++)
	//create the mesh
	{
		phi = (((h * divNumber) * limitH)/(double) textHeight) + (1.57079632679 - (limitH/ (double )2));
		//phi_1 = (((h+1) * limitH)/(double) textHeight) + (1.57079632679 - (limitH/ (double )2));

		for(w = 1; w <= drawW; w++) //count forward
		{
		
			theta = (limitW * (w * divNumber)) / (double) textWidth + (1.57079632679 - (limitW/ (double )2));

            p.x = radius*cos(theta)*sin(phi);
            p.y = radius* sin(theta)*sin(phi);
            p.z = radius*cos(phi);
   			
   			/*p.x = w;
            p.y = 2;
            p.z = h;*/
            mesh.addTexCoord(ofVec2f((w*divNumber), (h*divNumber)));
   			mesh.addVertex(p);
            
            

		}
		
	}
	
	/*for (int y = 0; y<drawH; y = y+1){
	    for (int x=0; x<drawW; x = x + 1){
	    	const ofIndexType texIndex = static_cast<ofIndexType>(x + y*drawW);
	    	mesh.setTexCoord(texIndex, ofVec2f((w*divNumber), (h*divNumber)));

	    }
	}*/


	//mesh.clearIndices();
	
	for (int y = 0; y<drawH-1; y = y+1){
	    for (int x=0; x<drawW-1; x++){
	        mesh.addIndex(x+y*drawW);               // 0
	        mesh.addIndex(x+(y+1)*drawW);           // 10
	        mesh.addIndex((x+1)+(y+1)*drawW);       // 11
	       // mesh.addIndex(x);               // 0
	        //mesh.addIndex(x+drawW);           // 10
	        //mesh.addIndex((x+1)+drawW);       // 11
	        
	        mesh.addIndex((x+1)+y*drawW);           // 1
	        mesh.addIndex(x+y*drawW);               // 0
	        mesh.addIndex((x+1)+(y+1)*drawW);       // 11
	       
	        
	        
	        
	    }
	}



}
开发者ID:brnold,项目名称:ofSphericalVideo,代码行数:95,代码来源:ofApp.cpp


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