Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


#ActualHAM

Posted 18 January 2013 - 03:33 AM

I'm not sure how far along you are on this but I would suggest tackling this step by step.

  1. Forget about obj files and cylinders.
  2. Draw an untextured quad on the screen. (Two triangles forming a square)
    1. Do this manually creating the vertex and index buffers and filling in the vertex data yourself.
  3. Load a texture.  In this case your jpeg.
  4. 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:

  1. How to deal with vertex and index buffers
  2. How to load an image and create a texture
  3. How to construct the vertex data and set UVs
  4. 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.


#1HAM

Posted 18 January 2013 - 03:31 AM

I'm not sure how far along you are on this but I would suggest tackling this step by step.

 

  1. Forget about obj files and cylinders.
  2. Draw an untextured quad on the screen. (Two triangles forming a square)
    1. Do this manually creating the vertex and index buffers and filling in the vertex data yourself.
  3. Load a texture.  In this case your jpeg.
  4. 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:

  1. How to deal with vertex and index buffers
  2. How to load an image and create a texture
  3. How to construct the vertex data and set UVs
  4. 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 its just about 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.

 

 

 

 

 


PARTNERS