Mailing List
Home
Forum Home
Softimage
Carrara
trueSpace
Dir3d-l
Maya - a powerful 3D animation and visual effects software
Macromedia Flash Development
Subjects
Subject: Cameras
Subject: scaleDown command
Subject: black out solved
Subject: Aircraft Tutorial
Subject: Mathematical XYZ ?
Subject: Re: Its done This vs That
Subject: Re: Its done first week
recommendations for screen video captures?
Subject: 3DExplorer "Oddity "
Subject: Re: New Director
Subject: ProTeam renewals
Fuel 's new websites (X post)
Blue peter create a make toy
targeting groups question
XPost: Shockwave 3D game ( sort of )
Subject: RES: RES: RES: Fish Modeling
Emitting particles from object intersection
Fuel 's new websites (X post)
Subject: Re: Texturing
Big Break Contest Videos
Subject: New Plugins
Models and Texture on my updated site
Error Installing Patch tS6 6
Subject: Plasma?
Looking for Inspiration
Subject: Weird EMail Q
Subject: Re: It 's done first week ?
Subject: Cherry not cranberry
Subject: Re: New game
Camera Animation Problem
Subject: Particle plugins?
 
3d Max Texture burn?

3d Max Texture burn?

2004-02-27       - By Neto

 Back
Reply:     <<     11     12     13     14     15     16     17  

The basics is. You have the destination model (the one that'll receive the
UVs), and the source model (the one you'll copy the UVs from). Both models
have the same geometry, but if you look at their vertexlists, they're
differently ordered, and might have different lengths.

You loop for every face in every mesh in the destination model, and find
which faces in all meshes of the source model use the very same vertices
(you might also want to compare the normal direction, if you want to support
two faces in the same position, but facing opposite directions). If they
match, you copy the UVs for each face vertex from the source model into the
destination model's texturecordinatelist.

Here are the handlers I use to do so. Notisce it won't change anything
visually, because it's sole purpose is generate a list of texture
coordinates per mesh that can be loaded by another function (just
model.meshdeform.mesh[n].texturelayer[2].texturecoordinatelist =
newTextCoordList[n]):

on convertTextureCoordinates sModel, dModel
--Initial setup
sModel.addmodifier(#meshdeform)
repeat with i = 1 to sModel.meshdeform.mesh.count
sModel.meshdeform.mesh[i].texturelayer.add()
sModel.meshdeform.mesh[i].texturelayer.add()
sModel.meshdeform.mesh[i].texturelayer.add()
end repeat

dModel.addmodifier(#meshdeform)
repeat with i = 1 to sModel.meshdeform.mesh.count
dModel.meshdeform.mesh[i].texturelayer.add()
dModel.meshdeform.mesh[i].texturelayer.add()
dModel.meshdeform.mesh[i].texturelayer.add()
end repeat

--Major error check
if sModel.meshdeform.face.count <> sModel.meshdeform.face.count then
alert "# faces are different"
abort
end if

--Build the source model data list
sMeshList = buildDataList(sModel)

--Build the converted destination model data list
dMeshList = buildDataList(dModel)

--Generate progress check data
tCount = 0
tTotal = 0
repeat with i = 1 to dMeshList.count
tTotal = tTotal + dMeshList[i].face.count
end repeat


--Convert the texture coordinates
repeat with m = 1 to dMeshList.count
dMesh = dMeshList[m]
repeat with f = 1 to dMesh.face.count
dFace = dMesh.face[f]
dFaceVertices = [dMesh.vertexlist[dFace[1]],
dMesh.vertexlist[dFace[2]],
dMesh.vertexlist[dFace[3]]]

--Find corresponding face on sModel
repeat with sm = 1 to sMeshList.count
sMesh = sMeshList[sm]
repeat with sf = 1 to sMesh.face.count
sFace = sMesh.face[sf]
sFaceVertices = [sMesh.vertexlist[sFace[1]],
sMesh.vertexlist[sFace[2]],
sMesh.vertexlist[sFace[3]]]

--Checks if both lists have the same items, and returns the ordering (can be
different)
tCompared = arrange(dFaceVertices, sFaceVertices)

if tCompared[1] then
--If similar, copy the texturecoordinates from the source model to the
destination model
--using the ordering from the source face
tOrder = tCompared[2]

dMesh.texturecoordinatelist[dFace[1]] =
sMesh.texturecoordinatelist[sFace[tOrder[1]]]
dMesh.texturecoordinatelist[dFace[2]] =
sMesh.texturecoordinatelist[sFace[tOrder[2]]]
dMesh.texturecoordinatelist[dFace[3]] =
sMesh.texturecoordinatelist[sFace[tOrder[3]]]
end if
end repeat
end repeat

global percent
tCount = tCount + 1
percent = integer(tCount / float(tTotal)*100)
updatePercent()
end repeat
end repeat

--prepare texturecoordinatelist for delivery
tList = []
repeat with i = 1 to dMeshList.count
tList.append(dMeshList[i].texturecoordinatelist)
end repeat

return tList
end

on arrange list1, list2
--Compares two 3-tem lists for similarity, even in different orders.
--Returns a list with two items. The first is a boolean, and tells if the
lists
--have the same items. The second item is a 3-item list with the order
--the items in list2 maps into list1
tResult = [0, []]

tResult[2] = [list2.getOne(list1[1]), list2.getOne(list1[2]),
list2.getOne(list1[3])]
if tResult[2].getOne(0) = 0 then tResult[1] = 1

return tResult
end
__ ____ ____ ____ ____ ____ ____ ____ ____ ____
Dir3d-l mailing list
Dir3d-l@(protected)
http://nuttybar.drama.uga.edu/mailman/listinfo/dir3d-l