Notifications
Clear all

[Closed] Texture Coordinates

Hi! I have the following problem: I have vertex positions and I want to find the corresponding texture coordinats for the vertices. The documentation says the following:
In order to find out which texture vertex corresponds to a mesh vertex, you have to do the following:

          [ol]

[li] Take the index of the mesh vertex. [/li]
[li] Find out which faces reference the index of the face. [/li]
[li] Note the number of the vertex (1 st , 2 nd or 3 rd – .x, .y or .z) inside each face. [/li]
[li] For each face referencing the vertex, get the texture face with the same index. [/li]
[li] Get the index of the respective texture vertex from the face – 1 st , 2 nd or 3 rd / .x, .y or .z [/li]
[li] The vertex you got corresonds to the mesh vertex we started with. [/li]
[li] Repeat steps 3 to 6 for all faces found. [/li]
Same applies to color vertices.

[/ol]
but I don’t understand that. Can someone explain it to me a bit more understandable? Thanks a lot.

7 Replies

do you need it for mesh or poly? … i don’t want to write a code two times…

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

well … let’s do it for editable_mesh trimesh:


fn getMapVertsUsingVert mesh vert channel:1 = if (meshop.getMapSupport mesh channel) do  
(
	tverts = #{}
	for f in (meshop.getfacesusingvert mesh vert) do
	(
		vv = getface mesh f
		tv = meshop.getmapface mesh channel f
		out = off
		for k=1 to 3 while not out where out = (vv[k] == vert) do append tverts tv[k]
	)
	tverts
)	

this was my editable poly function for this before i started using the sdk

fn GeoVertToMapVert obj v mapCh =
	(
		faces = (polyop.getFacesUsingVert obj v) as array 
		faceIndices = for i in faces collect finditem (polyop.getFaceVerts obj i) v;
		makeUniqueArray (for i = 1 to faces.count collect (polyop.getMapFace obj mapCh faces[i])[faceIndices[i]]);
	)

I’m sure there are more elegant and faster solutions out there

… and Klunk showed it for poly

ok thanks, nice
does it matter if I have a editable poly and there a take a face with the 3 vertices and look for the texture coordinates with the editable poly method or if I convert the editable poly then and look for the texture coordinates? Does the vertices have another order when it is converted?
Is there also a method to get the Texture Coordinates of a random point on a face or should I interpolate it after I have the coordinates of my vertices?

i don’t know what you mean by “interpolate” but to get corresponding face map point to the geo face point you have to use Bary coordinates. there is a sample in the MXS help.

I mean that I have a face with 3 vertices and then I have a point P on that face. And dependent on that information I want to have the texture coordinates of the point P.
I know this function:
coordinates = meshop.getBaryCoords obj face_index P
but how can I get the texture coordinates for that point?