Create geometry on the fly with xyz data from text file


#1

Greetings to all from Greece,
i have a txt file with xyz values (almost 30.000 points) and i pass them to OF via OSC. I want to build a mesh step by step with the vertices provided from OSC and connect those vertices with triangles or lines in real time.
Which method is better to achieve this? i have to use shaders or it is more simple?

It is relatively easy i thing, but as you can see from the category i am a beginner…


#2

just put the vertices in an ofMesh as soon as you receive them, if they are ordered as triangles the mesh should just show correctly when calling draw on it. otherwise you might need to short them as triangles or add indices by adding the order number using mesh.addIndex().

so if for example you have 4 vertices and want to form a square with them:

mesh.addIndex(0);
mesh.addIndex(1);
mesh.addIndex(2);

mesh.addIndex(2);
mesh.addIndex(3);
mesh.addIndex(4);

if you want to show the wireframe instead of the solid faces just call mesh.drawWireframe

there’s more information in the ofMesh docs:

http://openframeworks.cc/documentation/3d/ofMesh/


#3

Thank you Arturo,
So, a loop like that should do what i am looking for
ofMesh mesh;
for (int row = 0; row< 30000; row++) {

mesh.addVertex(ofPoint (oscX, oscY, oscZ));
mesh.addColor(ofFloatColor (ofRandom(0 ,255), ofRandom(0, 255), ofRandom(0, 255)));
}
The indices don’t really matter because it will be an abstract visualization of this data. I only want creation of geometry. Right?


#4

yeah you probably don’t need the for loop just check that theres new messages in the osc receiver with a while loop and add any new point like you are doing there


#5

You rock, thank you again.
When i have something concrete i ll share the results