Notifications
Clear all
[Closed] UV Mapping issue? Help
Apr 27, 2010 2:15 am
From the maxsciprt help
Understanding Texture Coordinates[b][b][color=white][b]Finding the corresponding vertices[/b][/color][/b][/b]
[left]In order to find out which texture vertex corresponds to a mesh vertex, you have to do the following:
[/left]
[left]1. Take the index of the mesh vertex.
[/left]
[left]2. Find out which faces reference the index of the face.
[/left]
[left]3. Note the number of the vertex (1st, 2nd or 3rd - .x, .y or .z) inside each face.
[/left]
[left]4. For each face referencing the vertex, get the texture face with the same index.
[/left]
[left]5. Get the index of the respective texture vertex from the face - 1st, 2nd or 3rd / .x, .y or .z
[/left]
[left]6. The vertex you got corresonds to the mesh vertex we started with.
[/left]
[left]7. Repeat steps 3 to 6 for all faces found.
[/left]
[left]Same applies to color vertices.
fn fnGetVertColor mObj mVert mChannel =
(
-- assume mChannel = 0, vert colors for now
mChannel = 0
-- convert our vert to face selection
local mFaceList = (meshop.getFacesUsingVert mObj #{mVert}) as array
-- find our vert in the same order/pos in the array
local mFaceVerts = (meshop.getVertsUsingFace mObj #{mFaceList[1]}) as array
local mMapFaceVerts = meshop.getMapFace mObj mChannel mFaceList[1]
local mIndex = findItem mFaceVerts mVert
local mTexVert = mMapFaceVerts[mIndex]
format "Vert:% ID:%
" mVert mIndex
format "FaceVerts:%
" mFaceVerts
format "MapFaceVerts:%
" mMapFaceVerts
-- and finally read our uv pos
local mOutput = meshop.getMapVert mObj mChannel mTexVert
mOutput *= 255.0
return (mOutput as color)
)
Output
Vert:1 MatchingVert:1
Vert:1 ID:1
FaceVerts:#(1, 3, 4)
MapFaceVerts:[4,3,1]
Vert:2 MatchingVert:2
Vert:2 ID:2
FaceVerts:#(1, 2, 4)
MapFaceVerts:[1,2,4]
Vert:3 MatchingVert:3
Vert:3 ID:2
FaceVerts:#(1, 3, 4)
MapFaceVerts:[4,3,1]
Vert:4 MatchingVert:4
Vert:4 ID:3
FaceVerts:#(1, 3, 4)
MapFaceVerts:[4,3,1]
Ok, so my problem here is that the order of the face verts and the mapFace verts are not correct, for some reason. Has anyone experienced this problem before?
pic here showing the vertex numbers and my problem, vertex 4 and 1 colors are beeing swaped around due to the uv error…
[/left]
2 Replies
Apr 27, 2010 2:15 am
I think the issue is that im taking a snapshot of the mesh and its re-ordering the uvmapping when i do this??
1 Reply
here is the problem:
mFaceVerts = meshop.getVertsUsingFace ...
getVertsUsingFace returns vertices as bit array (numbers are in ascending order). Use GetFace function to get right order.