Hi, as the title suggest, I want to create a mesh out of different ofPlanePrimitive. After that, i want to apply a texture on it. For now I’m just debugging the mesh creation.
This is what I’m doing:
in my header file i’ve of3dPrimitive foliage.
in my App.cpp:
//in the setup
int n_planes = 3;
int distance = 100;
float rot = 0;
for (uint i = 0; i < n_planes; i++) {
auto p = ofPlanePrimitive(width, height, resolution, resolution);
p.setPosition(0, 0,float(distance*i));
// this loop is needed otherwise all the planes will be on the same z position
for (int i=0; i<p.getMesh().getNumVertices(); i++) {
ofVec3f actualVert =p.getMesh().getVerticesPointer()[i];
ofVec3f newVert = actualVert * p.getGlobalTransformMatrix();
p.getMesh().getVerticesPointer()[i] = newVert;
}
foliage.getMesh().append(p.getMesh());
}
In the draw method there is simply a foliage.drawWireframe(). And this is the result.
As you see there are some lines that connect the last vertex of a plane mesh with the first vertex of the next plane mesh. Is there a way to avoid this?
I’ve also considered putting all the planes in a container, like std::vector<shared_ptr<ofPlanePrimitive> > planesContainer; and then iterate through them, calling mapTexCoordsFromTexture(ofTexture texture) on each of them and then draw the plane. But it is slow when the planes are more than 3, that’s why I was thinking to merge the meshes in a single of3dPrimitive, call mapTexCoordsFromTexture(ofTexture texture) on it and then draw it.
which allows to create separate primitives, the default triangle strip creates every triangle connected with the previous, that’s why you see the line connecting the planes
you probably need to call mapTexCoordsFromTexture for every one of the original planes instead of the final mesh since that method only knows how to map the texture for the original primitive, if you change it it won’t work