[osg-users] Capturing all visible nodes

Isaac Wolf ijwolf8 at gmail.com
Tue Jan 22 13:38:31 PST 2019


Thank you for the replies!

mp3butcher, I may try something like that, thank you.

Robert, the end goal is to take a picture of an object in real life and apply it as a texture to a 3D model by orienting the geometry in the program to be roughly the same as in the picture.

My plan was to capture all the points currently visible, retrieve their locations on the screen, and then apply those values as texture coordinates to the model. As if the XY screen space is the UV texture space.

I understand that this will result in skewed textures once the model is rotated, but that is just fine for the purposes of the project.

The "only visible points" portion of this is important, because the user could be zoomed in on a model, and the texture should only be applied to that space.

Since posting the message, I have abused some of my other functions to get what I want. Essentially, I use view->computeIntersections on every point on the screen, and then add any non-zero value to an array. Ends up looking like this:


Code:

int res = 50;
osg::Vec3f origin(0.0f, 0.0f, 0.0f);
for (int i = 0; i < vp->width(); i+=res) {
    for (int j = 0; j < vp->height(); j+=res) {
        float x = vp->x() + (float)i;
        float y = vp->y() + (float)j;
        osg::Vec3f newPoint = getSelectedPoint(x, y, view);
        if (newPoint != origin) {
            pointGroup->push_back(newPoint);
            uv->push_back(osg::Vec3(x/vp->width(), y/vp->height(), 0.0f));
        }
    }
}




This effectively gets me what I want, but I am sure there is a better way to do it!

Really appreciate your time, I've been thrown into OSG recently and this forum has been a huge help!

Regards,

Isaac

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75531#75531







More information about the osg-users mailing list