At the moment I’m creating a Mesh comprised of a grid of Vec3f points, and applying a live video texture to it. I’d like to deform the mesh in different ways, but the structure of the mesh is not what I’m expecting.
In the list of types for ofMesh::setMode() I can’t find anything that will construct a plain grid structure - ie. all the points are joined together relative to the closest points. Instead the closest thing I can find is OF_PRIMITIVE_TRIANGLE_FAN - but this creates a strange (fan) effect - with all of the points somehow linking to the first indexed point (see picture);
If you take a look at the Mesh from Camera example, there is a simple mesh set up in the beginning of it. It doesn’t appear to have a setMode. If you want, you can rewrite the code to include a call to getMode to find out what it is using.
This is just generating a plain mesh without a texture though - I’m struggling to find anything in the examples or on Github that illustrates a simple 2D/3D mesh with an image texture - ie. the standard style of QC or processing demo with flag moving in the wind.
I’ve just rewritten my patch to generate the mesh in a triangular fan pattern instead of in columns / rows. It looks fine before any deformation;
Perhaps you can use ofPlanePrimitive to create the mesh. It is handy beause it can compute the texture coords.
In this example, I use the OF_PRIMITIVE_TRIANGLES mode to initialize the mesh. This create vertices in this order:
0 1 2
3 4 5
6 7 8
ofApp.h
class ofApp : public ofBaseApp{
public:
void setup();
void update();
void draw();
ofVideoGrabber cam;
ofPlanePrimitive plane;
int planeWidth;
int planeHeight;
int planeGridSize;
int planeColumsNbr;
int planeRowsNbr;
vector< ofVec3f > baseVertices;
};
Thank you! That’s the ticket! I also got my existing mesh working by adding triangles as well as vertices, after taking a look at the grid format in ofxPiMapper