Hello there, I here have a quite technical question, and as my english isn't perfect, feel free to ask any questions if I wasn't clear enough on my explanations.
I am building a homemade voxel model creator. My models are a set of blocks, from which I generate a mesh.
I would like to texture them using an external 2D image file. So, I have to 'uv-map' the vertices of my model, meaning, having a projection of 3D vertices on a 2D plane (texture)
I am looking for an algorithm to generate an optimal texture (optimal: having the lowest memory usage but still holding every vertices, without overlaps)
Let me pose the problem more formally. Feel free to look at the example if there is any comprehension issues.
• What I have: I have list of planes, where each planes is defined by 2 integers (width, height)• What the algorithm should do:
1) give the smallest (in term of area) rectangle which can hold every planes, without overlaps
2) give the position and orientation of each planes relatively this rectangle. The position is where the plane should be mapped. (x, y), the orientation is 0 or 1, weather the plane is flipped once mapped. Flipped: map on the rectangle from (x, y) to (x + height, y + width), (instead of (x, y) to (x + height, y + width))
There might be multiple optimal solutions (as the following example shows, I would like to find an algorithm that generate at least one of them)
Example: (notice that "LEFT" plan is flipped once mapped here) sample.bmp
Source code: https://github.com/rpereira-dev/VoxelEngine/blob/master/VoxelEngine/src/com/grillecube/client/renderer/model/editor/mesher/ModelMesherCull.java
Screenshot: modelEditor.bmp
NB: I've posted this topic on the "graphic and GPU programming" section; as this generated texture will be used in an OpenGL context.
↧