From 3D Mesh to 2D

Hey Everybody,

I’m trying to unwrap a 3D mesh (see below).


To help with mapping I want to unwrap the structure, but I don’t really know if there is an easy way to do this. I can’t change the z to 0 because that would give only the front of the structure. Is there an easy way to do this? Or any page I can look at for ideas?

Thanks!

what exactly do you mean by unwrap? can you provide some examples of what you want to achieve?

Like this, but the triangles should be all the same sizes and connected like the middle ones.

if all you need is an image of the front an back “unwrapped” you can just use a camera using orthographic perspective and positioned in front and behind the geometry looking at it.

if you want the position of each point you can do something similar but using the worldToScreen method from ofCamera to get the projected position of every point

Thanks for the tip! I’ve tried to use the worldToScreen method but it doesn’t seem to be working. This is my function call:

leds.addVertex(cam.screenToWorld(vec));

when I try to add a viewpoint (normal rectangle) it still gives the same result.

ofRectangle rect(ofVec3f(0,0,0),10000, 10000 );
leds.addVertex(cam.screenToWorld(vec, rect));

The result:


Am I still doing something wrong in the function call?

Update:
I printed out some of the converted vectors compared to the original ones, this is what I got:


The z doesn’t change to 0 while I did place the plane on z= 0.

the correct method is worldToScreen not screenToWorld, the second reverses the projection

hi Jipolie01
Does unwrap means something like this

  • from -
  • to -

if so, this may be something help.

  1. get all the triangles that the mesh owns.
  2. find every triangle’s binding triangle, and make the binding list;
  3. turn every 3D triangle into 2D triangle, like clip the triangle from the 3D world into a 2D paint board.
  4. use the binding list to re-order the position of the triangles, if the bind, they should be together.so need to rotate and move, and keep them side by side.

for 2, mesh.mergeDuplicateVertices() may help
for 3, one easy way is just calc the distance between every two points of triangle first.

hope it help.