# Various questions about ofmesh and texture coordinates

hello guys i’m really new so bare with me
So i have a mesh I created like this:

``````define ofpoint
``````

and then i add the triangles

``````for()
int a = base+i;
int b = base+(i+1) %circleN;
int c = circleN + a;
int d = circleN+b;
``````

how can I remove vertices from this? for exemple the first ones created so i can get the tube runing endlessly?
(this is taken from the book Mastering openFrameworks: Creative Coding Demystified , drawing 3d twisting knot)

now for texture coordinates, imagine i want to texture some hand made geometry and i want to apply a texture in the model, and then modify the texture coordinates to manipulate the position of the texture in the model, how do i do that? I cant understand how to give coordinates to vertices of parts that are not the picture, hope you guys understand.

Thanks, Roger.

Can anyone give me a hint please?

Roger

You can remove vertices using:

``````myMesh.removeVertex(indexToRemove);
``````

In terms of you texCoords, you just need to add one for every vertex in the mesh. You can then adjust them like so:

``````myMesh.setTextCoord(index, ofVec3f(newX, newY, newZ));
``````

or

``````ofVec3f vec = &myMesh.getTexCoord(index);
vec->x = newX;
vec->y = newY;
vec->z = newZ;
``````

I’d recommend having a good look through this if you haven’t already? - http://openframeworks.cc/tutorials/graphics/opengl.html

thanks mate.

still have some questions. maybe i wasn’t clear enough

how do I figure whitch indexes i should remove.

for example:

i want to remove vertice v1, i have to remove the 3 indexes right? how do I find them out?

now for the vertice coordinates, maping a texture from 0 to 1.

how should i define a texture coordinate when the vertice is out of the texture?

v1-----------------v2

---------------------
-------------…
-------------…

v3-----------…v4
the texture is in the dots, the dashes are empty. How do I map v1 v2 and v3?
even better how to map just one face of ofbox?

Thanks, Roger.

If you remove the vertex it would probably be best to clear the indices and re-enter them though. ofMesh::removeVertex() uses the erase method which will close the gap in the vertex array (you will have [0,2,3] instead of [0,1,2,3]). This will mean all your indices that connect vertices above the index you removed will be incorrect. Unless of course you loop through the indices and correct them.

Maybe it would be better to keep the vertices consistent and just redraw the indices whenever you want a vertex to seem to have disappeared.

quickly (and not sure if it’s helpful) theres a function in this addon:

to take a non indexed mesh and make it use indicies.

yeah, its silly that i didn’t thought of that, thanks. My problem was really on restructuring the indices so that should work well.

@zach thanks will look into it!

I’ll do some experimentation with tex coords this afternoon, if I have time.
I will probably come with more questions after that

thanks alot! Roger

hi again guys.

so tryed the texture thing.
http://imgur.com/LNlSDN6

so what i get from this is that i have to create each face independent of the others for this to work?
I tryed some clamping, but it did not help.

Ok so I think using 2 separate meshes is ok for what I want.

I tryed doing the mesh with the faces as islands but i would have to give texcoords to the other faces aswell, so doing 2 completly independent meshes works the best.
http://imgur.com/JcAb2av

``````ofVboMesh mesh;
ofVboMesh front;

//bot face vertices

//top face vertices

//front face vertices

//front

//bot
//top