How to access the vertices enclosed in a GLModel using GLGraphics?
in
Contributed Library Questions
•
2 years ago
Exploring Andres great GLGraphics library, I'm trying to get a dynamic mesh to display. One in which I can map the model's z values to an arbitrary value, to be updated every frame. Shouldn't be too difficult, but I ran aground trying to access the vertex values stored in the model. A Floatbuffer? How does that work? :)
I was thinking of something like this, where "mesh" is a static glmodel with normalised z-values, and display is a dynamic/stream version that maps the normalised z-values of the static model to a dynamic value. In this code I presumed a ArrayList style list of vertices.
But it's not an ArrayList. :)
I was thinking of something like this, where "mesh" is a static glmodel with normalised z-values, and display is a dynamic/stream version that maps the normalised z-values of the static model to a dynamic value. In this code I presumed a ArrayList style list of vertices.
- void update() {
float x, y, z;
display.beginUpdateVertices();
for (int i = 0; i < display.vertices.size(); i++) {
x = mesh.get(i).vertices.x;
y = mesh.get(i).vertices.y;
z = mesh.get(i).vertices.z*displayHeight; // mapped
display.updateVertex(index, x, y, z);
}
display.endUpdateVertices();
}
But it's not an ArrayList. :)
1