Unique Uv's spanning multiple objects

Discussions concerning programming of SOFTIMAGE©
Post Reply
Manticor
Posts: 160
Joined: 09 Jun 2011, 22:41

Unique Uv's spanning multiple objects

Post by Manticor » 12 May 2014, 16:46

**SOLVED***
Last edited by Manticor on 12 May 2014, 20:18, edited 1 time in total.

User avatar
myara
Posts: 403
Joined: 28 Sep 2011, 10:33

Re: **SOLVED***

Post by myara » 12 May 2014, 20:07

This kinda goes against the main purpose of a forum, sharing information.
M.Yara
Character Modeler | Softimage Generalist (sort of)

Manticor
Posts: 160
Joined: 09 Jun 2011, 22:41

Unique Uv's spanning multiple objects

Post by Manticor » 12 May 2014, 20:18

Sorry didn't think of that....my bad

Here is the problem and the solution
Basically I was working on a script to create a uv set that spanned multiple objects because when you select multiple objects and apply a unique uvs operator it fill the uvs in a full page for each object ...not good if you want to share a lightmap across multiple objects.
At the moment Im merging all the objects together as a copy and storing all the cluster information from the originals .Applying a unique uvs op on the merged mesh and then detaching the object based on the clusters..
Problem I had was that some sometimes some polys arent assigned a cluster and sometimes clusters overlap.So was wanting idea's for a better solution.

It dawned on me that I could use gator on each of the originals with closest knot setting to transfer the uv info back.

Ill post the python script when I'm done.

Kenny

NNois
Posts: 754
Joined: 09 Jun 2009, 20:33

Re: Unique Uv's spanning multiple objects

Post by NNois » 13 May 2014, 09:09

you can apply an unfold op to a group ;-) !

User avatar
myara
Posts: 403
Joined: 28 Sep 2011, 10:33

Re: Unique Uv's spanning multiple objects

Post by myara » 13 May 2014, 09:22

Yeah, the problem with clusters is that they get merged if they are using the same material.

A workaround I did once, for a different purpose, was to create a temporal Material for each object, merge objects, reassign the old material, delete the temporal one, and rename the cluster. This way, each object would have a cluster.

The problem is when you are dealing with objects that already have poly clusters and multiple materials. I guess you would have to create multiple overlapping clusters and it would be very messy to deal with them.

Anyway, for your case, the gator approach would be more straight forward. And since the topology won't change, don't forget to use Transfer Method in Closest Vertex to make the transfer more precise.
M.Yara
Character Modeler | Softimage Generalist (sort of)

Manticor
Posts: 160
Joined: 09 Jun 2011, 22:41

Re: Unique Uv's spanning multiple objects

Post by Manticor » 13 May 2014, 18:27

Thanks for the help fellas.
And oh yeah I forgot .Im on XSI 7.01 so cant use the unfold trick ....as it doesn't have it.

Unfortunately the Gator method isn't working perfectly for me .Some objects its perfect ...others it creates a mess of the uv's.
Also tried copy pasting uvs between objects .that only works part of the time too.
I think Im gonna go back to the old approach and use some tricks you were sugesting myara.

Here's the code to the Gator method

xsi = Application
lm = xsi.LogMessage
oSel = xsi.Selection
lm(oSel(0).type)
from win32com.client import constants as c

cacheObjList= []
uvString = "LIGHTMAP_UV"
from win32com.client import Dispatch as disp
tempObjList = []

def GatorMultiObj(targetList,sourceList):
for x, i in enumerate(targetList):
lm(i.name)
lm(sourceList)
xsi.ApplyGenOp("Gator", "", (i.name)+";"+(sourceList[x].name), 3, "siPersistentOperation", "siKeepGenOpInputs", "")
xsi.SetValue(i.name+".TransferAttributes.method", 1, "")
xsi.TransferAllPropertiesAcrossGenOp(i.name+".polymsh.TransferAttributes",i.name,c.siClsUVSpaceTxtType, True)
xsi.FreezeObj(i,"","")


def GetObjectFromString(string):
temp = string.split(".")
oRoot= xsi.ActiveProject.ActiveScene.Root
newObj =oRoot.FindChild(temp[0])
return (newObj)

if oSel.count <= 1:
try :
XSIUIToolkit.Msgbox( "Please select more than one mesh",0)
exit()
except:
lm("END")

for i in oSel:
cacheObjList.append(i)
tempMaterialList = []
objList = xsi.Duplicate(oSel, "", 0, 1, 1, 0, 0, 1, 0, 1, "", "", "", "", "", "", "", "", "", "", 0)

for i in oSel:
for j in i.ActivePrimitive.Geometry.Clusters:
xsi.DeleteObj(j)
for i in objList:
lm("working on " +str(i.name))
xsi.SelectObj(i)
xsi.ActivateRaycastPolySelTool("")
xsi.SelectAllUsingFilter("Polygon", "siCheckComponentVisibility","", "")
tempMat = Application.ApplyShader("Phong", "",i.name, "", "siRemoveFromExistingClusters")
tempMaterialList.append (tempMat)
xsi.DeselectAll()
xsi.ActivateObjectSelTool("")
xsi.ToggleVisibility("", "", "")
xsi.ToggleVisibility(objList)
lm(cacheObjList)
for x, i in enumerate(objList):
for j in i.ActivePrimitive.Geometry.Clusters:
lm(cacheObjList[x])
j.name =str(cacheObjList[x])+"_T3MP"
xsi.ToggleVisibility(cacheObjList)


asda = xsi.ApplyGenOp("MeshMerge", "", objList, 3, "siPersistentOperation", "siKeepGenOpInputs","")
Application.SetValue(str(asda) +".tolerance", 0, "")
Application.TransferAllPropertiesAcrossGenOp(asda, "polymsh", "material", True)
obj = GetObjectFromString(str(asda))
#---------- find any Auto generated clusters that we dont want
for i in obj.ActivePrimitive.Geometry.Clusters:
if "_AUTO" in i.name and i.type == "poly":
xsi.DeleteObj(i)
xsi.FreezeObj(obj,"","")
oUvs = xsi.GenerateUniqueUVs(obj, str(uvString))
coll = disp("XSI.Collection")
coll = xsi.FindObjects("","{6630D811-0699-11D1-B723-00AA0068BF56}")
for i in coll:
if i.name == uvString:
xsi.SelectObj(i.FullName,"","")
newOp = (str(i.FullName) + ".PolyPackUV")
Application.OpenView("Texture Editor",False)
tester = xsi.InspectObj(newOp,"","",4,True)



oCls=obj.ActivePrimitive.Geometry.Clusters
for i in oCls:
if i.type == 'poly':
oSub =i.CreateSubComponent()
xsi.SelectMembers(oSub)
xsi.ExtractFromComponents("ExtractPolygonsOp", "", i.name,True,1,0)

xsi.DeleteObj(obj)
xsi.DeleteObj(objList)
xsi.SIUnhideObjects(cacheObjList)

meshColl = xsi.FindObjects("","{5FC0CCAE-3DC8-11D0-9449-00AA006D3165}")
tempColl = []
sortedtempColl = []
for j in meshColl:
if j.type == "polymsh":
if "_T3MP" in j.name:
tempColl.append(j)
#---------Sort the temp object list into a new list --------
for i in cacheObjList:
for j in tempColl:
if (j.name) == i.name+"_T3MP":
sortedtempColl.append(j)

GatorMultiObj(cacheObjList,sortedtempColl)

xsi.DeleteObj(sortedtempColl)

Post Reply

Who is online

Users browsing this forum: No registered users and 27 guests