Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

ofMesh: accessing the vertex vector

$
0
0

@bob97086 wrote:

A couple of questions about accessing the vertex vector in ofMesh.

My starting point is a rectangular mesh of vertices representing a height field or terrain map: z(x,y). I build the initial field then calculate differential heights which can be fed back into the structure to imitate, for example, ripples on a liquid surface. I did one version of this in Processing using Java and accessed the field as a 2D array z[rows][cols]. Very convenient since the differential accesses the rows above and below the z-cell in question as well as left and right positions.

In openFrameworks, the mesh vertex vector is linear but we know the number of columns so I can think in terms of rows and columns by indexing with (columnIndex + rowIndex*numberOfColumns).

Question 1: Is there a C++ “cast” operation or other technique where I can sort of convert, say, the pointer to the vertex vector into a 2D reference of known number of columns and rows? (This would make conversion of old Java code simpler.)

Question 2: In browsing the Forum I ran across a mesh vertex access written like this, as best I recall:

mesh.getVertices().at(i).z

This looks like it would be useful. I can find documentation for getVertices() but where the heck is the extension “at()”?

Question 3: Got any references to help me understand the documentation of ofMesh in terms of templates and the .inf file?

Thanks for your thoughts.

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles