1
$\begingroup$

Because of the intricacy associated in this room i'm modeling instead of building the entire room then uv-unwrapping i'm instead doing it piece by piece. I did the floor first and it looks good in unreal engine 4, but then i stated the walls and when i unwrapped them it came out looking like this in the uv editorenter image description here [pic below] does it look like that because of the way the camera was in the 3d view port? and regardless of what caused it how do i straighten it up or is it fine the way it is?

$\endgroup$
2
  • $\begingroup$ Use Smart UV Project instead of plain unwrap. $\endgroup$
    – SF12 Study
    Jul 23, 2019 at 4:50
  • 1
    $\begingroup$ Or unwrap with Angle Based. This requires you to set seams first though, but gives you the control where the seams are. Smart UV Project projects simply fom differen views. Think of uv mapping like a cutting pattern for a trouser for example. $\endgroup$
    – Tiles
    Jun 30, 2021 at 7:24

2 Answers 2

0
$\begingroup$

First, Select the object in object mode and apply rotation and scale. Second check your model for any connected polygons that will stretch the final map. Think about it like origami, where ever you would bend your model to make a paper version, that's where you put the seams. Generally you want to keep square polygons as a square shape in the uvmap. If you have a uneven polygon attached to a square polygon the uv map will stretch the square polygon's normals to match the uneven polygon. Just something to think about.

$\endgroup$
0
$\begingroup$

That's my fast way to create a flat-pattern: Select Floor -> Shift NumPad7: Mesh -> UV Unwrap -> Project from View Select Inside Walls: Mesh-UV -> Unwrap -> Unwrap Select rest of the Walls: Mesh-UV -> Unwrap -> Unwrap

For complex flat patterns in my projects, I've written a python script. If you want to use it: Edit mode. - Create a UV Map select all Items, and set the wished center face active Open Python Console - Copy / Paste Code into it Execute "FaceUV()"...

import bpy, bmesh
import mathutils, math

def ptAdd(pt1,pt2):
    return mathutils.Vector((pt2[0]+pt1[0],pt2[1]+pt1[1],pt2[2]+pt1[2]))

def ptSub(pt1,pt2):
    return mathutils.Vector((pt1[0]-pt2[0],pt1[1]-pt2[1],pt1[2]-pt2[2]))

def ptMult(pt1,pt2):
    return mathutils.Vector((pt1[0]*pt2[0],pt1[1]*pt2[1],pt1[2]*pt2[2]))

def ptDiv(pt1,pt2):
    return mathutils.Vector((pt1[0]/pt2[0],pt1[1]/pt2[1],pt1[2]/pt2[2]))

def CopyPt(pt):
    return mathutils.Vector((pt[0],pt[1],pt[2]))

def MinPt(pt_check,pt_min):
    if(pt_min==None):
        return CopyPt(pt_check)
    for i in range(0,3):
        if(pt_check[i]<pt_min[i]):
            pt_min[i]=pt_check[i]
    return pt_min

def MaxPt(pt_check,pt_max):
    if(pt_max==None):
        return CopyPt(pt_check)
        return
    for i in range(0,3):
        if(pt_check[i]>pt_max[i]):
            pt_max[i]=pt_check[i]
    return pt_max

#moves area area on vector vector
def moveArea(area,v):
    for i in range(0,len(area)):
        area[i]=ptAdd(area[i],v)

counter=1
def checkArea(faces,active_face):
    global counter
    counter+=1
    unset_faces=0
    done=0
    for index,face in enumerate(faces):
        if face[0]==0:
            if done==0:
                done=1
                faces[index][0]=1
            else:
                unset_faces+=1
        elif face[0]==1:
            if face[1]==active_face:
                face[0]=2
            else:
                active_face=face[1]
    #TODO hier weiter
    if counter>1000:
        print("DEBUG: LOOP\n")
        return 0
    return unset_faces

#index_face,state,point_coords,point_indices
#state 0...todo
#state 1...active_base
#state 2...finished

def Abwicklung(face_base,face_move):
    #index_face,state,point_coords,point_indices
    if(face_base[0]==face_move[0]):
        return
    if(face_base[1]<1):
        return
    face_base[1]=2
    if(face_move[1]>0):
        return
    index_pt1=None
    index_pt2=None
    for i1 in face_base[3]:
        for i2 in face_move[3]:
            if (i1 == i2):
                if(index_pt1==None):
                    index_pt1=i1
                else:
                    index_pt2=i1
                    break
        if(index_pt2!=None):
            break
    if(index_pt1==None or index_pt2==None):
        return
    TransformStruct(face_base,face_move,index_pt1,index_pt2)
    face_move[1]=1

def TransformStruct(f1,f2,index1,index2):
    print('Transform')
    pta1=None
    pta2=None
    ptb1=None
    ptb2=None
    for i,index in enumerate(f1[3]):
        if(index==index1):
            pta1=f1[2][i]
        elif(index==index2):
            pta2=f1[2][i]
    for i,index in enumerate(f2[3]):
        if(index==index1):
            ptb1=f2[2][i]
        elif(index==index2):
            ptb2=f2[2][i]
    if(pta1==None or ptb1==None or pta2==None or ptb2==None):
        print("FATAL: TransformStruct: not all points found")
        return
    ptc1=ptSub(pta1,pta1) #0,0,0
    ptc2=ptSub(pta2,pta1)
    ptd1=ptSub(ptb1,ptb1) #0,0,0
    ptd2=ptSub(ptb2,ptb1)
    rotc=atan2(ptc2[1],ptc2[0])
    rotd=atan2(ptd2[1],ptd2[0])
    e_rot=mathutils.Euler((0.0,0.0,rotc-rotd),'XYZ')
    print("Face: %5.2f,%5.2f %5.2f,%5.2f | %5.2f,%5.2f %5.2f,%5.2f"%(pta1[0],pta1[1],pta2[0],pta2[1],ptb1[0],ptb1[1],ptb2[0],ptb2[1]))
    for i,pt in enumerate(f2[2]):
        print("pt: %5.2f,%5.2f"%(f2[2][i][0],f2[2][i][1]),end=' => ')
        f2[2][i]=ptSub(pt,ptb1)
        print("%5.2f,%5.2f"%(f2[2][i][0],f2[2][i][1]),end=' => ')
        f2[2][i].rotate(e_rot)
        print("%5.2f,%5.2f"%(f2[2][i][0],f2[2][i][1]),end=' => ')
        f2[2][i]=ptAdd(f2[2][i],pta1)
        print("%5.2f,%5.2f"%(f2[2][i][0],f2[2][i][1]))

def FaceUV():    
    obj = bpy.context.edit_object
    if obj == None: 
        print("no Edit Object selected\n")
        return
    me = obj.data
    if me == None:
        print("no Mesh found\n")
        return
    bm = bmesh.from_edit_mesh(me)
    if bm == None: 
        print("no BMesh found\n")
        return
    uvlay = me.uv_layers.active
    if uvlay == None: 
        print("no selected UV Layer\n")
        return
    active_face=-1
    for fa in bm.faces:
        if fa.select:
            active_face=fa.index
    if active_face<0:
        print("no Face selected\n")
        return
    face_struct=[]
    n0=mathutils.Vector((0.0,0.0,1.0))
    #read and rotate faces:
    for fa in bm.faces:
        n=CopyPt(fa.normal)
        q_rot=n.rotation_difference(n0)
        e_rot=q_rot.to_euler('ZYX');
        state=0
        if fa.index == active_face:
            state=1
        n.rotate(e_rot)
        #index_face,state,point_coords,point_indices
        face_struct.append([fa.index,state,[],[]])
        item=len(face_struct)-1
        for ve in fa.verts:
            p1=mathutils.Vector(ve.co)
            p1.rotate(e_rot)
            face_struct[item][2].append(CopyPt(p1))
            face_struct[item][3].append(ve.index)
    n_faces=len(face_struct)
    n_finished=0
    i=0
    #erstelle Abwicklung:
    while(n_finished<n_faces):
        n_finished_old=n_finished
        n_finished=0
        for f1 in face_struct:
            if(f1[1]>0):
                n_finished+=1
                for f2 in face_struct:
                    Abwicklung(f1,f2)
        if(n_finished_old==n_finished):
            break
        i=i+1
        if(i>10):
            print('DEBUG i Overflow')
            return
    #einpassen in UV (0,0 - 1,1)
    ptmin=None
    ptmax=None
    for part in face_struct:
        for pt in part[2]:
            if(ptmin==None):
                ptmin=CopyPt(pt)
            else:
                ptmin=MinPt(pt,ptmin)
            if(ptmax==None):
                ptmax=CopyPt(pt)
            else:
                ptmax=MaxPt(pt,ptmax)
    pt0=[0.0,0.0,0.0]
    #fit into 0-1:
    vec_move=ptSub(pt0,ptmin)
    scale=max(ptmax[0]-ptmin[0],ptmax[1]-ptmin[1])
    for part in face_struct:
        for i,pt in enumerate(part[2]):
            pt=ptAdd(pt,vec_move)
            part[2][i]=ptDiv(pt,[scale,scale,1.0])
    #UV mesh erstellen:
    faces=[]
    vertices=[]
    vindex=0
    for part in face_struct:
        indices=[]
        for pt in part[2]:
            vertices.append(pt)
            indices.append(vindex)
            vindex+=1
        faces.append(indices)
    uvlay.name='Abwicklung'
    uv=me.uv_layers['Abwicklung']
    uv_layer=bm.loops.layers.uv.verify()
    for nf,fa in enumerate(bm.faces):
        face=face_struct[nf]
        for nv,lo in enumerate(fa.loops):
            pt=face[2][nv]
            luv=lo[uv_layer]
            luv.uv=[pt[0],pt[1]]

#End of Code
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .