prettyPixel
03-10-2005, 04:17 PM
Hello,
Here is a problem i'm unable to solve:
I cannot find the correspondence between vertex UV's and vertex positions in Polys...
Ok, i've read the procedure for meshes, i tried it and it works fine, but as soon as i want to apply this method to polys, there's no more correspondence.
So, for each face, i get the vertices positions and the vertices UVWcoords, and they don't match!!!
here is the code to create my test object :
max modify mode
obj=plane Length_Segments:2 Width_Segments:2 length:1.0 width:1.0 pos:[0.5,0.5,0] mapCoords:true
select obj
obj.wirecolor=blue
convertToPoly obj
addModifier obj (Unwrap_UVW ())
objModUnwrap=obj.modifiers[1].unwrap
objModUnwrap2=obj.modifiers[1].unwrap2
objModUnwrap.setMapChannel 1
objModUnwrap.edit()
objModUnwrap.displayMap false
objModUnwrap2.setGridVisible false
objModUnwrap2.setTVSubObjectMode 3
objModUnwrap2.setTVElementMode false
for f=obj.numfaces to 1 by -1 do
(
objModUnwrap2.selectFaces #{f}
objModUnwrap.breakSelected()
)
objModUnwrap2.selectFaces #{}
convertToPoly obj
ok now you have the same object as me: a plane with 4 faces (2 by 2)
Each mapFace is independent to to others.
the object datas:
http://users.skynet.be/arketip/CGtalk/note.jpg
face 1 for example:
vertsOfFace=#(1, 2, 4, 5) -- the vertices of the face
mapVertsOfFace=#(13, 1, 15, 16) -- the MAPvertices of the same face
coord mapVertsOfFace[1]=[0,0.5,0] -- the coordinates of MAPvertices (to localize them in the object)
coord mapVertsOfFace[2]=[0,0,0]
coord mapVertsOfFace[3]=[0.5,0,0]
coord mapVertsOfFace[4]=[0.5,0.5,0]
It seems that the order of the vertices in an face don't match the order of the MAPvertices...
http://users.skynet.be/arketip/CGtalk/note2.jpg
if you wish it, Here's the code to print the values :
clearListener()
obj=selection[1]
for f=1 to obj.numFaces do
(
vertsOfFace=(polyOp.getVertsUsingFace Obj #{f})as array
mapVertsOfFace=polyOp.getMapFace obj 1 f
print("\nface f="+f as string)
print("vertsOfFace="+vertsOfFace as string)
print("mapVertsOfFace="+mapVertsOfFace as string)
for i=1 to mapVertsOfFace.count do
(
cmv=mapVertsOfFace[i]
coord=polyOp.getMapVert obj 1 cmv
print("coord mapVertsOfFace["+i as string+"]="+coord as string)
)
)--for f
Is the procedure of the help file "Understanding Textures coordinates" applicable to Polys ?
Can anyone say me if It's possible to find the correspondence ?
Anybody has not ever made that?
What's wrong with my code?
I'm stucked...
Thanks in advance for your help
Prettypixel
Here is a problem i'm unable to solve:
I cannot find the correspondence between vertex UV's and vertex positions in Polys...
Ok, i've read the procedure for meshes, i tried it and it works fine, but as soon as i want to apply this method to polys, there's no more correspondence.
So, for each face, i get the vertices positions and the vertices UVWcoords, and they don't match!!!
here is the code to create my test object :
max modify mode
obj=plane Length_Segments:2 Width_Segments:2 length:1.0 width:1.0 pos:[0.5,0.5,0] mapCoords:true
select obj
obj.wirecolor=blue
convertToPoly obj
addModifier obj (Unwrap_UVW ())
objModUnwrap=obj.modifiers[1].unwrap
objModUnwrap2=obj.modifiers[1].unwrap2
objModUnwrap.setMapChannel 1
objModUnwrap.edit()
objModUnwrap.displayMap false
objModUnwrap2.setGridVisible false
objModUnwrap2.setTVSubObjectMode 3
objModUnwrap2.setTVElementMode false
for f=obj.numfaces to 1 by -1 do
(
objModUnwrap2.selectFaces #{f}
objModUnwrap.breakSelected()
)
objModUnwrap2.selectFaces #{}
convertToPoly obj
ok now you have the same object as me: a plane with 4 faces (2 by 2)
Each mapFace is independent to to others.
the object datas:
http://users.skynet.be/arketip/CGtalk/note.jpg
face 1 for example:
vertsOfFace=#(1, 2, 4, 5) -- the vertices of the face
mapVertsOfFace=#(13, 1, 15, 16) -- the MAPvertices of the same face
coord mapVertsOfFace[1]=[0,0.5,0] -- the coordinates of MAPvertices (to localize them in the object)
coord mapVertsOfFace[2]=[0,0,0]
coord mapVertsOfFace[3]=[0.5,0,0]
coord mapVertsOfFace[4]=[0.5,0.5,0]
It seems that the order of the vertices in an face don't match the order of the MAPvertices...
http://users.skynet.be/arketip/CGtalk/note2.jpg
if you wish it, Here's the code to print the values :
clearListener()
obj=selection[1]
for f=1 to obj.numFaces do
(
vertsOfFace=(polyOp.getVertsUsingFace Obj #{f})as array
mapVertsOfFace=polyOp.getMapFace obj 1 f
print("\nface f="+f as string)
print("vertsOfFace="+vertsOfFace as string)
print("mapVertsOfFace="+mapVertsOfFace as string)
for i=1 to mapVertsOfFace.count do
(
cmv=mapVertsOfFace[i]
coord=polyOp.getMapVert obj 1 cmv
print("coord mapVertsOfFace["+i as string+"]="+coord as string)
)
)--for f
Is the procedure of the help file "Understanding Textures coordinates" applicable to Polys ?
Can anyone say me if It's possible to find the correspondence ?
Anybody has not ever made that?
What's wrong with my code?
I'm stucked...
Thanks in advance for your help
Prettypixel
