Jump to content
  • Advertisement
Sign in to follow this  
SmajlerKamil

OpenGL Creating texture from model

This topic is 2342 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everyone i'm having a problem, i have written an application i c++ and OpenGL which shows a 3d model with a texture generated in application. Now i'd like to generate texture map from this model and save it to graphic file. The problem is that i don't know what is the best way to do it. My idea is to draw each triangle in to 2d plane like that:

/\ /\ /\ /\ /\ /\ (/\ is a triangle)
/\ /\ /\ /\ /\ /\

I was also looking for any algorithms to get texture like an Unwrap in blender using "'mark seed" to get texture like that:
face_unwrap.jpg
but i've found only something like "mesh parametrization" and there is only wrote what is it, no explanation how to do it. Does anybody was working to get something like that? Any internet site ?

Share this post


Link to post
Share on other sites
Advertisement
Just to clarify your question, are you looking into algorithms that automatically generate UV mapping for meshes like the head UV map you posted?

Share this post


Link to post
Share on other sites
[color=#333333][font=arial, sans-serif]

I am looking for[/font][color=#333333][font=arial, sans-serif]

[/font][color=#333333][font=arial, sans-serif]

an algorithm[/font][color=#333333][font=arial, sans-serif]

[/font][color=#333333][font=arial, sans-serif]

to generate the[/font][color=#333333][font=arial, sans-serif]

[/font][color=#333333][font=arial, sans-serif]

2D[/font][color=#333333][font=arial, sans-serif]

[/font][color=#333333][font=arial, sans-serif]

mesh (UV map?)[/font][color=#333333][font=arial, sans-serif]

[/font][color=#333333][font=arial, sans-serif]

from the 3D model.[/font]
[font="arial, sans-serif"][size="3"][color="#333333"]06)-UV-fig.jpg[/font]I
I have a 3d model and i want an algorithm to generate 2d mesh like on the picture. It can be in one part( hands, feets in one part)

Share this post


Link to post
Share on other sites
Blender is open source, so take a look at the source. Maybe the author of the according part has left some links to some articles discussing the used algorithm.

Share this post


Link to post
Share on other sites
A UV generation algoritm works like this:
1 - Build a list of connections (edges) of the mesh.
2 - Pick a triangle, determine what plane you should use for it (x positive/negative, y positive/negative or z positive/negative)
That selection is based on the largest component of the triangle normal (x, y or z)
3 - After that, look at the neighbor triangles (using the connection list you built earlier), and select any triangles that also lie in the same plane
Do it until you cannot find more triangles for that plane in connections.
4 - Mark all triangles selected as a "group"
5 - When no more found, go back to point 2 and pick another triangle not already selected
6 - After iterating all triangles, you should now have a list of groups. Each group belongs to a plane, with that information you can transform the 3d coords into 2d coords.
7 - After having everything in 2D, you can run a packing algoritm to fit everything into a rectangular area

Share this post


Link to post
Share on other sites
In addition to what Relfos said -

To get the uv map like the picture, you need to define "seams"; that is, mark edges where you can accept discontinuity in the texture parameter space. This will give you "islands" of the mesh parts. The benefit is that you can minimize/optimize texture stretching, and also separate areas of interest into separate sections for easy texturing work.

Fully automated seaming is also possible, but it is best to do it manually as human judgement is very useful in the process.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!