View Full Version : Determining a particular uv set for a given map in a material?
hellknows2008 07-30-2008, 10:22 AM Hi
I am currently writing an exporter for a game engine. I want to know which uv set is linked to a particular map in a material, typical usage would be lightmapping which typically requires a separate uv set that unwraps all polygons in a way that there is no overlap and no mirror. Does anyone know how to do this? I searched through the net and found no answer. I also found a similar post here (http://www.gamedev.net/community/forums/topic.asp?topic_id=484014)
Any help is appreciated
Thx
|
|
ewerybody
07-31-2008, 08:01 AM
Materials do not have UV-sets you know?! ;]
But polygons that have a certain material assigned may have multiple UV-sets.
You are asking for an API-way, huh?
Via mel you can query -allUVSets with the polyUVSet command.
You'd have to switch on the corresponding uvSet with
polyUVSet -currentUVSet -uvSet "uvSetName" |pCube1|pCubeShape1;
for instance, to be able to query the positions of uvs
polyEditUV -query;
// Result: 0 0 1 0 0 1 1 1 0 2 1 2 0 3 1 3 0 4 1 4 2 0 2 1 -1 0 -1 1 //
hellknows2008
07-31-2008, 09:35 AM
Thx for your reply first.
Yes, I do know uv sets belong to polygons. The problem is that I want to programmatically (either MEL or C/C++, tho C/C++ is prefered) determine that which uv set is linked to a particular attribute(e.g. color, transparency, more but don't know the exact names) in a material. If I know the uv set name in question then its fine. But its usually not known beforehand and I don't want to constraint users to rename the uv set as e.g. "Lightmap_UVSet".
Apparently when there are more than 1 uv sets then in UV linking (UV centric) editor, after linking e.g. transparency to "uvSet1", there will be a node called "uvChooser1" added in the hypershade editor, but I can't find anything useful in that node. One more note, the "uvChooser1" only happens when the uv set of the linking is not the current uv set
GiantG
07-31-2008, 12:06 PM
You have to trace down the Connection of the Material till you find the uvChooser Node.
This one reveals the Name of the UVSet.
But remember that you will only find non-default UVSets.
The default UVSet doesn't have an uvChooser Node.
To find this you have so store all non-standard UVSets and everything that is not inside one of the non-default uvset belongs to the default UVSet.
Example:
listConnections -t "shadingEngine" pSphereShape1;
listConnections phong2;
listConnections ramp2;
listConnections place2dTexture2;
getAttr uvChooser1.uvSets[0];
If i find some time i will write it for you...
cheerz..
hellknows2008
08-01-2008, 02:02 AM
Thx. Its very useful
However, I discovered one weird thing. If I have the following uv sets in a polygon node:
map1
uvSet
uvSet1
uvSet2
Then, if I link "uvSet" to transparency attribute then I can successfully retrieve the name by using "getAttr uvChooser1.uvSets[0]". However, if I link using "uvSet1" then, "getAttr uvChooser1.uvSets[1]" is what I want. Then if I link using "uvSet2" then, "getAttr uvChooser1.uvSets[0]" is what I am after. I opened the connection editor and it revealed what I said above
Any idea??
CGTalk Moderation
08-01-2008, 02:02 AM
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.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.