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

the problem is that the indices you are adding for the second mesh are not correct, the idea is good, you need to add the indices starting from the last vertex number but the way you've implemented it is wrong, the number of vertices you are getting is considering that of the current mesh too and so it's adding indices pointing to vertices that don't exist yet. the last 2 for loops should look somethign like:

        auto prevNumVertices = finalMesh.getNumVertices();
        for(auto v: branch.getMesh().getVertices()){
            finalMesh.addVertex(v * branch.getGlobalTransformMatrix());
        }
        for(auto i: branch.getMesh().getIndices()){
            finalMesh.addIndex(i + prevNumVertices);
        }

or just invert the order so you add the indices first like:

        for(auto i: branch.getMesh().getIndices()){
            finalMesh.addIndex(i + finalMesh.getNumVertices());
        }
        for(auto v: branch.getMesh().getVertices()){
            finalMesh.addVertex(v * branch.getGlobalTransformMatrix());
        }

Viewing all articles
Browse latest Browse all 40524

Trending Articles



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