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 03-26-2013, 07:10 AM   #1
MorzzE
New Member
portfolio
MorzE MorzE
Russia
 
Join Date: Mar 2013
Posts: 5
Question [SDK] How to get vert by tvert?

Hello everyone!
There is a question: how can i get vertex by texture vertex?
I'm using 3DS Max 2013 SDK.
 
Old 03-26-2013, 08:58 PM   #2
Klunk
Lord of the posts
 
Klunk's Avatar
portfolio
Klunk
United Kingdom
 
Join Date: Sep 2005
Posts: 701
mesh or mnmesh ?
 
Old 03-27-2013, 03:19 AM   #3
MorzzE
New Member
portfolio
MorzE MorzE
Russia
 
Join Date: Mar 2013
Posts: 5
Quote:
Originally Posted by Klunk
mesh or mnmesh ?

mesh
.......
 
Old 03-27-2013, 11:38 AM   #4
Klunk
Lord of the posts
 
Klunk's Avatar
portfolio
Klunk
United Kingdom
 
Join Date: Sep 2005
Posts: 701
the process is the same for both though the syntax differs

something like this should do the trick....

Code:
Mesh* mesh = ..... where you get the mesh if (!mesh->mapSupport(channel)) ..... handle the error BitArray geoverts(mesh->getNumVerts()); int nMapFaces = mesh->Map(channel).getNumFaces(); TVFace *mapFaces = mesh->mapFaces(channel); for (int i = 0; i < nMapFaces; i++) { if(mapFaces[i]) { for (int j=0; j<3; j++) { if(mapFaceData[i].t[j] == mapvert) { geoverts.Set(mesh->faces[i].v[j]); break; // there should only be one matching per face } } } }



its not been tested, is a quick conversion from an mnmesh version I have. Though it's not common it is possible to have a single map vert shared with many geo verts, if you are sure that this will never be the case you can add an escape flag for the main loop and use a single int to store the geovert index as opposed to the bitarray.

Last edited by Klunk : 03-27-2013 at 02:17 PM.
 
Old 03-27-2013, 12:06 PM   #5
MorzzE
New Member
portfolio
MorzE MorzE
Russia
 
Join Date: Mar 2013
Posts: 5
I do not quite understand what exactly does this code.


There is my code:
Code:
INode* rootNode = i->GetRootNode(); unsigned int meshCount = rootNode->NumberOfChildren(); for(unsigned int u = 0; u < meshCount; u++) { INode* node = rootNode->GetChildNode(u); BOOL deleteIt = FALSE; TriObject *tri = GetTriObjectFromNode(node, deleteIt); unsigned int tVertexCount = tri->mesh.getNumTVerts(); for(unsigned j = 0; j < tVertexCount; j++) { float x = tri->mesh.getTVert(j).x; float y = tri->mesh.getTVert(j).y; // So I get the coordinates of the texture vertices. // And how do I get the coordinates of the vertex corresponding to the given texture vertex? } }

Last edited by MorzzE : 03-27-2013 at 12:16 PM.
 
Old 03-27-2013, 12:51 PM   #6
Klunk
Lord of the posts
 
Klunk's Avatar
portfolio
Klunk
United Kingdom
 
Join Date: Sep 2005
Posts: 701
in this case go via the faces....

Code:
INode* rootNode = i->GetRootNode(); unsigned int meshCount = rootNode->NumberOfChildren(); for(unsigned int u = 0; u < meshCount; u++) { INode* node = rootNode->GetChildNode(u); BOOL deleteIt = FALSE; TriObject *tri = GetTriObjectFromNode(node, deleteIt); /* unsigned int tVertexCount = tri->mesh.getNumTVerts(); for(unsigned j = 0; j < tVertexCount; j++) { float x = tri->mesh.getTVert(j).x; float y = tri->mesh.getTVert(j).y; // So I get the coordinates of the texture vertices. // And how do I get the coordinates of the vertex corresponding to the given texture vertex? }*/ // go by faces int nfaces = tri->mesh.getNumFaces(); TVFace *mapfaces = tri->mesh.mapFaces(channel); // the generic case or //TVFace* mapfaces = tri->mesh.tvFace; // the specific channel 1 case Face *faces = tri->mesh.faces; for(int i = 0; i < nfaces; i++) { if(mapfaces[i] && faces[i]) { for(int j=0; j<3; j++) { int tvert_index = mapfaces[i].t[j]; // the index into the map vert data int vert_index = faces[i].v[j]; // the index for the equivalent geo vert } } } }

Last edited by Klunk : 03-27-2013 at 01:01 PM.
 
Old 03-27-2013, 01:59 PM   #7
MorzzE
New Member
portfolio
MorzE MorzE
Russia
 
Join Date: Mar 2013
Posts: 5
Thank you very much! It works.
 
Old 03-27-2013, 02:15 PM   #8
Klunk
Lord of the posts
 
Klunk's Avatar
portfolio
Klunk
United Kingdom
 
Join Date: Sep 2005
Posts: 701
you have to be quite careful sometimes, depending on what you are doing, because going by face means you can visit (and effect) the same verts repeatedly . Creating a bitarray of "visited" verts is a way round this.
 
Old 03-27-2013, 03:55 PM   #9
MorzzE
New Member
portfolio
MorzE MorzE
Russia
 
Join Date: Mar 2013
Posts: 5
Quote:
Originally Posted by Klunk
you have to be quite careful sometimes, depending on what you are doing, because going by face means you can visit (and effect) the same verts repeatedly . Creating a bitarray of "visited" verts is a way round this.

I need that repetition
 
Old 03-27-2013, 03:55 PM   #10
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,480
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:08 AM.


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