Quantcast
Channel: openFrameworks - Latest posts
Viewing all articles
Browse latest Browse all 40524

Adding ofMatrix4x4 transformations to a mesh and go back to the original position

$
0
0

what you are doing when creating the finalMesh, is appending the meshes to one another but not their transformations, in order to do so you would need to multiply each vertex of each mesh by it's node's matrix. something like:

for(auto v: root.getMesh().getVertices()){
    finalMesh.addVertex(v * root.getGlobalTransformationMatrix());
}

for(auto i: root.getMesh().getIndices()){
    finalMesh.addIndex(i);
}

another problem is that unless the mesh is created as triangles (by default they are created as triangle strip) they can't be appended like that since the order of the vertices and indices is more complex then just putting the vertices of one after the other. that's why you see the glitchy final mesh. you can set the type of the 3d primitives when calling set like:

root.set(branchDimension, branchLenght, radiusSegments, heightSegments, capSegments, true, OF_PRIMITIVE_TRIANGLES);

to start with i think it would be easier to just have separate meshes and then try to join them in one if you have performance issues


Viewing all articles
Browse latest Browse all 40524

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>