ofVboMesh and ofNode [solved]

Hi there, is there any way to do something like giving an ofVboMesh a parent ofNode? I want a mesh of “shapes” to track an ofBoxPrimitive through space. I need to use an ofVboMesh because trying to render a vector of shapes of the size I want is not practical.

Writing my own function to transform each vertex in the mesh to track the box seems like overkill; someone must have had this same issue before? What’s the standard way to get mesh vertices to transform according to the transformations of another object through space?


Maybe drawign instanced methods.

There is an example in the gl examples

(I deleted a previuos Post because i confused forums :blush: )

thanks for the reply. I’ve looked into instancing, and while it does look powerful, I dont have time currently learn it. Also, Im not sure it would help me here; I can get the frame rate Im looking for using vboMeshes, but the rotation of the mesh is the issue. The problem looks like this:

Each cluster of cones is a mesh. I want the tops of the cones in each mesh to line up with the pole coming out of the sphere. I’m currently setting the vertex locations in each mesh like this:

ofVboMesh Tree::generateLeaves(){
ofVboMesh vLeaves;
float leafSize = 6;
int numLeaves = ofRandom(10)+20;

ofConePrimitive leaf;
leaf.set(leafSize, leafSize);
ofVboMesh tempMesh;
ofVec3f stemPos = stem.getPosition();

for (int i = 0; i < numLeaves; i++) {
    float height = ofRandom(50);
    float width = ofRandom(50);
    float depth = ofRandom(50);

    tempMesh = leaf.getMesh();
    vector<ofVec3f>tempVerts = tempMesh.getVertices();
    for (int j = 0; j < tempVerts.size(); j++) {
        ofVec3f tempster = ofVec3f(tempVerts[j].x+width,
        tempMesh.getVertices()[j] = tempster;
return vLeaves;

So, stemPos will shift the mesh properly to the location of its pole, but the mesh will not have rotated to align with the pole. Im rotating the poles using a quaternion, but I cant seem to figure out how to use this same quaternion to rotate the mesh into place.

Any ideas?

Hi, perhaps not what you need but you could do:

mVbo.draw(); // this is now done in local space relative to the node

That is exactly what I needed! I didnt realize this function existed, my life will be much easier now.


also you can us an of3dPrimitive that is an ofVboMesh + an ofNode to access the mesh just call getMesh() on it

Thanks arturo, the issue is that Im calling cone.getMesh() a bunch of times to fill a single vboMesh with a bunch of static “cones” so that they’ll render quickly. Im confused about the standard way to add a bunch of vboMeshes from of3dPrimitives to one large mesh and then be able to move the large mesh around easily.

you can create an of3dPrimitive and put several cones in it:

of3dPrimitive cones;

for(int i=0;i<numCones;i++){
    auto cone = ofMesh::cone(100,200);
    for(auto & v: cone.getVertices()){

and then move cones around using it’s node inherited functions, parent it with another node…

ohhhh wow perfect, I assumed of3dPrimitive was an abstract interface for some reason. Thanks so much!