[osg-users] Mapping texture coordinates to a portion of a large (.obj) model
Isaac Wolf
ijwolf8 at gmail.com
Thu Oct 25 13:11:58 PDT 2018
Hello all,
I am new to OSG, and I am having some difficulty understanding the steps required to complete this task.
Basically, I want to map an image to a portion of a .obj file I am loading in as a Node. I have the 3D position and indices of four points that I would like to use as UV coordinates for an incoming image.
My primary issue is that the .obj doesn't have texture coordinates in the first place. So I figured I could add the only 4 points I care about manually, and assign them as UV coordinates.
Is this possible? Or do you always need a 1 to 1 mapping for texture coordinates? In pseudo/osg inspired code, I'd image it would look something like the following.
Say I had a Vec3 array of 4 points that sit on the surface of a model called points_of_concern, and a uv_array that is just <0,0>, <0,1>, etc.
Code:
...
<Node> myNode= readNodeFile("model.obj");
Vec3 points_of_concern=[<2.3, 3.2, 3.1>, ....];
Vec2 uv_array= [<0,0>, <0,1>...];
myNode->setTexCoordinates(points_of_concern);
Texture2D myTex = readImageFile("image.png");
myTex->setTextureCoordinates(uv_array);
myNode->setTexture(myTex);
It seems like a simple task, but I did a lot of searching without any luck!
Thanks for your time!
Regards,
Isaac[/code]
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75136#75136
More information about the osg-users
mailing list