CGTalk > Software > Autodesk 3ds max > 3dsMax SDK and MaxScript
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 02-28-2013, 08:04 PM   #1
cgneuling
Veteran
portfolio
Elisabeth
Wien, Austria
 
Join Date: Nov 2011
Posts: 69
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:
  1. Take the index of the mesh vertex.
  2. Find out which faces reference the index of the face.
  3. Note the number of the vertex (1 st , 2 nd or 3 rd - .x, .y or .z) inside each face.
  4. For each face referencing the vertex, get the texture face with the same index.
  5. Get the index of the respective texture vertex from the face - 1 st , 2 nd or 3 rd / .x, .y or .z
  6. The vertex you got corresonds to the mesh vertex we started with.
  7. Repeat steps 3 to 6 for all faces found.

    Same applies to color vertices.
but I don't understand that. Can someone explain it to me a bit more understandable? Thanks a lot.
 
Old 02-28-2013, 09:04 PM   #2
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,626
Send a message via ICQ to denisT
do you need it for mesh or poly? .. i don't want to write a code two times....
 
Old 02-28-2013, 09:08 PM   #3
Klunk
Lord of the posts
 
Klunk's Avatar
portfolio
Klunk
United Kingdom
 
Join Date: Sep 2005
Posts: 701
this was my editable poly function for this before i started using the sdk

Code:
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
 
Old 02-28-2013, 09:13 PM   #4
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,626
Send a message via ICQ to denisT
Quote:
Originally Posted by denisT
do you need it for mesh or poly? .. i don't want to write a code two times....

well ... let's do it for editable_mesh trimesh:
Code:
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 )
 
Old 02-28-2013, 09:15 PM   #5
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,626
Send a message via ICQ to denisT
... and Klunk showed it for poly
 
Old 03-06-2013, 02:53 PM   #6
cgneuling
Veteran
portfolio
Elisabeth
Wien, Austria
 
Join Date: Nov 2011
Posts: 69
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?
 
Old 03-06-2013, 03:37 PM   #7
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,626
Send a message via ICQ to denisT
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.
 
Old 03-06-2013, 03:59 PM   #8
cgneuling
Veteran
portfolio
Elisabeth
Wien, Austria
 
Join Date: Nov 2011
Posts: 69
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?
 
Old 03-06-2013, 03:59 PM   #9
CGTalk Moderation
Expert
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,478
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 12:14 PM.


Powered by vBulletin
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.