I'm not sure how far along you are on this but I would suggest tackling this step by step.
- Forget about obj files and cylinders.
- Draw an untextured quad on the screen. (Two triangles forming a square)
- Do this manually creating the vertex and index buffers and filling in the vertex data yourself.
- Load a texture. In this case your jpeg.
- Now draw the quad with the texture mapped
At this point you will know what you need to deal with your problem. You'll know:
- How to deal with vertex and index buffers
- How to load an image and create a texture
- How to construct the vertex data and set UVs
- How to bind the texture and draw textured geometry.
Once you know all that, then all you have to do is find where the obj file is loaded and when it creates the vertex data from it. Once you know that you can write your UVs into that data. You may have to change the vertex type and declaration. Then your last challenge would be to figure out the math to get your UVs correct.
However, even though I think you would learn alot from doing this I wouldn't suggest changing or adding UVs in this way. I'm sure the obj file format can store your UVs and you should probably be setting up the UVs in the modeling package that exported the obj file.
For simple shapes like boxes, quads, cylinders, spheres, I would suggest not using an obj file at all. Create them yourself in code, if for no other reason other than to familiarize yourself with how to construct them and manipulate them.
You would need this knowledge if you then wanted to go back and start manipulating the data from the obj file.
Edited by HAM, 18 January 2013 - 03:33 AM.