Exemplo n.º 1
0
//--------------------------------------------------------------
void Page::addFace(ofMesh& mesh, vectorFace& _face) {
	addFace(mesh, _face.A, _face.B, _face.C);
    mesh.addTexCoord(_face.a);
    mesh.addTexCoord(_face.b);
    mesh.addTexCoord(_face.c);
    
	addFace(mesh, _face.A, _face.C, _face.D);
    mesh.addTexCoord(_face.a);
    mesh.addTexCoord(_face.c);
    mesh.addTexCoord(_face.d);
}
//--------------------------------------------------------------
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;
}
Exemplo n.º 3
0
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();
}
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);
	
}
Exemplo n.º 5
0
//--------------------------------------------------------------
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);
}
Exemplo n.º 6
0
OFX_OBJLOADER_BEGIN_NAMESPACE

void load(string path, ofMesh& mesh, bool generateNormals, bool flipFace)
{
	path = ofToDataPath(path);

	mesh.clear();

	GLMmodel* m;

	m = glmReadOBJ((char*)path.c_str());

	if (generateNormals)
	{
		glmFacetNormals(m);
		glmVertexNormals(m, 90);
	}

	if (flipFace)
	{
		glmReverseWinding(m);
	}

	for (int j = 0; j < m->numtriangles; j++)
	{
		const GLMtriangle &tri = m->triangles[j];

		for (int k = 0; k < 3; k++)
		{
			GLfloat *v = m->vertices + (tri.vindices[k] * 3);
			mesh.addVertex(ofVec3f(v[0], v[1], v[2]));

			if (m->colors)
			{
				GLfloat *c = m->colors + (tri.vindices[k] * 3);
				mesh.addColor(ofFloatColor(c[0], c[1], c[2]));
			}

			if (m->normals && ofInRange(tri.nindices[k], 0, m->numnormals))
			{
				GLfloat *n = m->normals + (tri.nindices[k] * 3);
				mesh.addNormal(ofVec3f(n[0], n[1], n[2]));
			}

			if (m->texcoords && ofInRange(tri.tindices[k], 0, m->numtexcoords))
			{
				GLfloat *c = m->texcoords + (tri.tindices[k] * 2);
				mesh.addTexCoord(ofVec2f(c[0], c[1]));
			}
		}
	}

	glmDelete(m);
}
Exemplo n.º 7
0
//----------------------------------------
void ofGenerateSphereMesh( ofMesh& _mesh, float _radius, int _numRings, int _numSegments ){
	
	cout << "*** ofGenerateSphereMesh ***" << endl;	
	
	_mesh.clear();	
	
	float uTile = 1.0f; // Texcoord tiling, do we want to support that?
	float vTile = 1.0f;		
	
	float fDeltaRingAngle = (PI / _numRings);
	float fDeltaSegAngle = (TWO_PI / _numSegments);
	
	int offset = 0;	
	
	// Generate the group of rings for the sphere
	for(unsigned int ring = 0; ring <= _numRings; ring++ ) {
		float r0 = _radius * sinf (ring * fDeltaRingAngle);
		float y0 = _radius * cosf (ring * fDeltaRingAngle);
		
		// Generate the group of segments for the current ring
		for(unsigned int seg = 0; seg <= _numSegments; seg++) {
			float x0 = r0 * sinf(seg * fDeltaSegAngle);
			float z0 = r0 * cosf(seg * fDeltaSegAngle);
			
			// Add one vertex to the strip which makes up the sphere
			
			ofVec3f pos(x0, y0, z0);
			
			_mesh.addVertex( pos );
			
			_mesh.addNormal( pos.getNormalized() );
			
			if( ofGetPrimitiveGenerateTexCoords()  ){
				//for (unsigned int tc=0;tc<numTexCoordSet;tc++)				
				_mesh.addTexCoord( ofVec2f( (float) seg / (float)_numSegments * uTile, (float) ring / (float)_numRings * vTile ) );
			}
			
			if (ring != _numRings) {
				// each vertex (except the last) has six indices pointing to it
				
				_mesh.addIndex(offset + _numSegments);
				_mesh.addIndex(offset);
				_mesh.addIndex(offset + _numSegments + 1);
				
				_mesh.addIndex(offset);
				_mesh.addIndex(offset + 1);
				_mesh.addIndex(offset + _numSegments + 1);
				
				offset ++;
			}
		}; // end for seg
	} // end for ring	
}
Exemplo n.º 8
0
void faceColorToTexture(ofMesh& mesh, ofImage& image)
{
	vector<ofFloatColor> &color = mesh.getColors();
	int num_face = color.size() / 3;
	
	int tex_size = ofNextPow2(ceil(sqrt(num_face)));
	
	bool arb = ofGetUsingArbTex();
	ofDisableArbTex();
	image.allocate(tex_size, tex_size, OF_IMAGE_COLOR);
	if (arb) ofEnableArbTex();
	
	mesh.clearTexCoords();
	
	image.getPixelsRef().set(0);
	
	float texel_size = (1. / image.getWidth()) * 0.5;
	
	for (int i = 0; i < num_face; i++)
	{
		int u = (i % tex_size);
		int v = (i / tex_size);
		
		ofColor c = color[i * 3];
		
		image.setColor(u, v, c);
		
		float uu = (float)u / image.getWidth() + texel_size;
		float vv = (float)v / image.getHeight() + texel_size;
		
		mesh.addTexCoord(ofVec2f(uu, vv));
		mesh.addTexCoord(ofVec2f(uu, vv));
		mesh.addTexCoord(ofVec2f(uu, vv));
	}
	
	image.update();
	mesh.clearColors();
}
Exemplo n.º 9
0
void ofxObjLoader::load(string path, ofMesh& mesh, bool generateNormals) {
	path = ofToDataPath(path);
    
    mesh.clear();
    
	GLMmodel* m;
	
	m = glmReadOBJ((char*)path.c_str());
	
    if(generateNormals){
        glmFacetNormals(m);
        glmVertexNormals(m, 90);
    }
    
    GLfloat *v, *n, *c;
    for(int i = 1; i <= m->numvertices; i++){
        v = &m->vertices[3 * i];
		mesh.addVertex(ofVec3f(v[0], v[1], v[2]));
    }
    
	for(int i = 1; i <= m->numnormals; i++){
        n = &m->normals[3 * i];
        mesh.addNormal(ofVec3f(n[0], n[1], n[2]));
    }
    
    for(int i = 1; i <= m->numtexcoords; i++){
        c = &m->texcoords[2 * i];
        mesh.addTexCoord(ofVec2f(c[0], c[1]));
    }
    
	for (int i = 0; i < m->numtriangles; i++) {
		GLMtriangle &t = m->triangles[i];
        
        //NOTE: ofMesh does not have support for different indices for tex coords and mormals
		mesh.addIndex(t.vindices[0]);
        mesh.addIndex(t.vindices[1]);
        mesh.addIndex(t.vindices[2]);
	}
	
	glmDelete(m);
	
	return mesh;
}
Exemplo n.º 10
0
void addForheadToFaceMesh(ofMesh & input){
	
	if (input.getVertices().size() != 66) return;
	
	static int forehead[10] = {0,17,18,19,20,/*21,22,*/23,24,25,26,16};		// skipping 21 and 22 because there is a triangle that overlaps somehow
	ofPoint extras[10];
	ofVec2f texture[10];
	
	for (int i = 0; i < 10; i++){
		extras[i] = input.getVertices()[forehead[i]] + (input.getVertices()[27] - input.getVertices()[33]);
		texture[i] = input.getTexCoords()[forehead[i]] + (input.getTexCoords()[27] - input.getTexCoords()[33]);
		input.addVertex(extras[i]);
		input.addTexCoord(texture[i]);				 
	}
	
	for (int i = 0; i < (10-1); i++){
	
		// a b c
		// b c d;
		
		int a = forehead[i];
		int b = 66 + i;
		int c = forehead[i+1];
		
		input.addIndex(a);
		input.addIndex(b);
		input.addIndex(c);
		
		int d = 66 + i + 1;
		
		input.addIndex(b);
		input.addIndex(c);
		input.addIndex(d);
		
	}
	
}
Exemplo n.º 11
0
void BGGraphics::pushVertex(ofMesh & mesh, float x, float y, float z, float nx, float ny, float nz, float offsetX, float offsetY) {
    mesh.addVertex(ofVec3f(x, y, z));
    mesh.addNormal(ofVec3f(nx, ny, nz));
    mesh.addTexCoord(ofVec2f(offsetX, offsetY));
    mesh.addColor(ofFloatColor(255, 255, 255));
}
Exemplo n.º 12
0
void addTexCoords(ofMesh& to, const std::vector<T>& from) {
    for(std::size_t i = 0; i < from.size(); i++) {
        to.addTexCoord(glm::vec2(from[i].x, from[i].y));
	}
}
Exemplo n.º 13
0
void addTexCoords(ofMesh& to, const vector<T>& from) {
	for(int i = 0; i < from.size(); i++) {
		to.addTexCoord(from[i]);
	}
}
Exemplo n.º 14
0
void addTexCoords(ofMesh& mesh, ofVec2f a, ofVec2f b, ofVec2f c) {
	mesh.addTexCoord(a);
	mesh.addTexCoord(b);
	mesh.addTexCoord(c);
}
Exemplo n.º 15
0
//from ofSetSphereResolution
void testApp::buildSphereMesh(int radius, int res, ofMesh & sphereMesh) {
    
    
    int n = res * 2;
    float ndiv2=(float)n/2;
    
    /*
     Original code by Paul Bourke
     A more efficient contribution by Federico Dosil (below)
     Draw a point for zero radius spheres
     Use CCW facet ordering
     http://paulbourke.net/texture_colour/texturemap/
     */
    
    float theta2 = TWO_PI;
    float phi1 = -HALF_PI;
    float phi2 = HALF_PI;
    //    float r = 1.f; // normalize the verts
    float r = radius;
    
    sphereMesh.clear();
    //sphereMesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
    
    int i, j;
    float theta1 = 0.f;
    float jdivn,j1divn,idivn,dosdivn,unodivn=1/(float)n,t1,t2,t3,cost1,cost2,cte1,cte3;
    cte3 = (theta2-theta1)/n;
    cte1 = (phi2-phi1)/ndiv2;
    dosdivn = 2*unodivn;
    ofVec3f e,p,e2,p2;
    
    if (n < 0){
        n = -n;
        ndiv2 = -ndiv2;
    }
    if (n < 4) {n = 4; ndiv2=(float)n/2;}
    if(r <= 0) r = -r;
    
    t2=phi1;
    cost2=cos(phi1);
    j1divn=0;
    
    ofVec3f vert, normal;
    ofVec2f tcoord;
    
    for (j=0;j<ndiv2;j++) {
        t1 = t2;
        t2 += cte1;
        t3 = theta1 - cte3;
        cost1 = cost2;
        cost2 = cos(t2);
        e.y = sin(t1);
        e2.y = sin(t2);
        p.y = r * e.y;
        p2.y = r * e2.y;
        
        idivn=0;
        jdivn=j1divn;
        j1divn+=dosdivn;
        for (i=0;i<=n;i++) {
            t3 += cte3;
            e.x = cost1 * cos(t3);
            e.z = cost1 * sin(t3);
            p.x = r * e.x;
            p.z = r * e.z;
            
            normal.set( e.x, e.y, e.z );
            tcoord.set( idivn, jdivn);
            vert.set( p.x, p.y, p.z );
            
            sphereMesh.addNormal(normal);
            sphereMesh.addTexCoord(tcoord);
            sphereMesh.addVertex(vert);
            
            e2.x = cost2 * cos(t3);
            e2.z = cost2 * sin(t3);
            p2.x = r * e2.x;
            p2.z = r * e2.z;
            
            normal.set(e2.x, e2.y, e2.z);
            tcoord.set(idivn, j1divn);
            vert.set(p2.x, p2.y, p2.z);
            
            sphereMesh.addNormal(normal);
            sphereMesh.addTexCoord(tcoord);
            sphereMesh.addVertex(vert);
            
            idivn += unodivn;
            
        }
    }
}
Exemplo n.º 16
0
void ofApp::createSegmentedMesh(const ofVec3f& center,
								ofMesh &mesh,
                                double radius,
                                int precision,
                                int textWidth,
                                int textHeight,
                                double theta1, double theta2,
                                double phi1, double phi2)
{
    /*
     original funtion used as inspiration
     Create a sphere centered at c, with radius r, and precision n
     Draw a point for zero radius spheres
     Use CCW facet ordering
     Partial spheres can be created using theta1->theta2, phi1->phi2
     in radians 0 < theta < 2pi, -pi/2 < phi < pi/2
     */
    int i,j;
    double t1,t2,t3;
    ofVec3f e,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;
    }
    
    for (j=0;j<precision/2;j++) {
        t1 = phi1 + j * (phi2 - phi1) / (precision/2);
        t2 = phi1 + (j + 1) * (phi2 - phi1) / (precision/2);

        mesh.setMode(OF_PRIMITIVE_POINTS );
        //mesh.setMode( OF_PRIMITIVE_LINE_STRIP);
        
        for (i=0;i<=precision;i++) {
            t3 = theta1 + i * (theta2 - theta1) / precision;
            
            e.x = cos(t1) * cos(t3);
            e.y = sin(t1);
            e.z = cos(t1) * sin(t3);
            p.x = center.x + radius * e.x;
            p.y = center.y + radius * e.y;
            p.z = center.z + radius * e.z;
            mesh.addNormal(e);
            mesh.addTexCoord(ofVec2f( (i/(double)precision) * textWidth,
                                      textHeight - (2*j/(double)precision) * textHeight));
            mesh.addVertex(p);
            
            e.x = cos(t2) * cos(t3);
            e.y = sin(t2);
            e.z = cos(t2) * sin(t3);
            p.x = center.x + radius * e.x;
            p.y = center.y + radius * e.y;
            p.z = center.z + radius * e.z;
            mesh.addNormal(e);
            mesh.addTexCoord(ofVec2f( (i/(double)precision) * textWidth,
                                      textHeight - (2*(j+1)/(double)precision) * textHeight));
            mesh.addVertex(p);
		}
    }
}
Exemplo n.º 17
0
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
	       
	        
	        
	        
	    }
	}



}
Exemplo n.º 18
0
/*
Old, beta function, use the triangle funtion now
*/
void ofApp::createSegmentedMeshMine(const ofVec3f& center,
								ofMesh &mesh,
                                double radius,
                                int textWidth,
                                int textHeight)
{
	//uses triangle strips
	int h, hTemp, w;
	double theta, phi, phi_1, limitH, 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.setupIndicesAuto();

	textWidth = textWidth / 4;
	textHeight = textHeight / 4;
	
	mesh.setMode( OF_PRIMITIVE_TRIANGLE_STRIP);

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

	for(hTemp = 0; hTemp < textHeight-1; hTemp = hTemp+2)
	{
		
		h = hTemp;
		//phi = (h * 3.141)/(double) textHeight;
		//phi_1 = ((h+1) * 3.141)/(double) textHeight;

		phi = ((h * limitH)/(double) textHeight) + (1.57079632679 - (limitH/ (double )2));
		phi_1 = (((h+1) * limitH)/(double) textHeight) + (1.57079632679 - (limitH/ (double )2));

		for(w = 0; w <= textWidth; w++) //count forward
		{
		
			theta = (limitW * w) / (double) textWidth + (1.57079632679 - (limitW/ (double )2));
			
           // p.x = radius * cos(theta);
            //p.y = h;
            //p.z = radius * sin(theta);

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

            //p.x = radius *cos(theta);
            //p.y = h+1;
            //p.z = radius * sin(theta);
             p.x = radius*cos(theta)*sin(phi_1);
            p.y = radius* sin(theta)*sin(phi_1);
            p.z = radius*cos(phi_1);

            mesh.addTexCoord(ofVec2f(4*w, (4*h)+1));
            mesh.addVertex(p);

		}
		
		h = hTemp+1;
		phi = ((h * limitH)/(double) textHeight) + (1.57079632679 - (limitH/ (double )2));
		phi_1 = (((h+1) * limitH)/(double) textHeight) + (1.57079632679 - (limitH/ (double )2));
		for(w = textWidth; w>=0; w--) //count backwards
		{

			theta = (limitW * w) / (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);
            mesh.addTexCoord(ofVec2f(w, h));
            mesh.addVertex(p);

             p.x = radius*cos(theta)*sin(phi_1);
            p.y = radius* sin(theta)*sin(phi_1);
            p.z = radius*cos(phi_1);
            mesh.addTexCoord(ofVec2f(w, h+1));
            mesh.addVertex(p);

		}
		
	}
}