Accessing UV Islands Topic is solved

Discussions concerning programming of SOFTIMAGE©
homam
Posts: 44
Joined: 16 Mar 2013, 23:15
Location: Montreal

Accessing UV Islands

Post by homam » 14 Oct 2017, 16:32

Hi,

Is there someway to get a list of UV islands through any scripting/complied language in XSI?

We can select islands easily from the UV editor UI but I don't know why this feature is not exposed to the SDK :-\

Thanks!

User avatar
rray
Moderator
Posts: 1575
Joined: 26 Sep 2009, 15:51
Location: Bonn, Germany

Re: Accessing UV Islands

Post by rray » 14 Oct 2017, 16:49

Hi Homam,

I think the texture editor might just be looking for polygons that are connected by their uv's each time. It should be a quick lookup, maybe it's using a UV->polygon lookup table, then it's even faster.

I've got this compound which initializes an attribute per node that you can read to get a polygon island id. (Set the checkmark to use its 'uv' mode)
You do not have the required permissions to view the files attached to this post.
"as a maya discussion grows longer, the probability of a suggestion involving deleting the preferences approaches one"

softimage resources section (formerly known as rray.de/xsi) updated May 30 2018

homam
Posts: 44
Joined: 16 Mar 2013, 23:15
Location: Montreal

Re: Accessing UV Islands

Post by homam » 16 Oct 2017, 00:28

Thanks rray! your ICE compound does the trick.

User avatar
rray
Moderator
Posts: 1575
Joined: 26 Sep 2009, 15:51
Location: Bonn, Germany

Re: Accessing UV Islands

Post by rray » 16 Oct 2017, 19:36

Good to hear it works with that :-!
"as a maya discussion grows longer, the probability of a suggestion involving deleting the preferences approaches one"

softimage resources section (formerly known as rray.de/xsi) updated May 30 2018

User avatar
myara
Posts: 358
Joined: 28 Sep 2011, 10:33

Re: Accessing UV Islands

Post by myara » 19 Oct 2017, 11:39

Sorry, how do I use this compound ?
M.Yara
Character Modeler | Softimage Generalist (sort of)

User avatar
rray
Moderator
Posts: 1575
Joined: 26 Sep 2009, 15:51
Location: Bonn, Germany

Re: Accessing UV Islands

Post by rray » 19 Oct 2017, 23:50

It sets an Attribute NodeIslandID,
you can use it to detect the island of a sample/node like this

Code: Select all

var selected_samples = Selection(0);
var selected_samples_coll = selected_samples.SubComponent.ComponentCollection;
var selected_obj = selected_samples.SubComponent.Parent3DObject;
var ICEAttr = selected_obj.ActivePrimitive.Geometry.GetICEAttributeFromName("NodeIslandID");
var ICEAttr_array = new VBArray( ICEAttr.DataArray ).toArray();

var oldAlwaysEvaluated = ICEAttr.AlwaysEvaluated;
ICEAttr.AlwaysEvaluated = true;  // forces evaluation of attribute

for(i=0; i<selected_samples_coll.Count; i++)
	logmessage("Selected Sample "+selected_samples_coll(i).Index+" is on island "+  ICEAttr_array[selected_samples_coll(i).Index]);
	
ICEAttr.AlwaysEvaluated = oldAlwaysEvaluated;
"as a maya discussion grows longer, the probability of a suggestion involving deleting the preferences approaches one"

softimage resources section (formerly known as rray.de/xsi) updated May 30 2018

User avatar
myara
Posts: 358
Joined: 28 Sep 2011, 10:33

Re: Accessing UV Islands

Post by myara » 23 Oct 2017, 12:23

Thanks for the code !

I've found my problem.
The XSI Man I was using as a test has it's Texture Projection named 'UV' so the compound was red and didn't give me the results I expected.

I was using a recursive function to get islands, but it was pretty slow. Your ICE solution seems to be the solution. With this I may be able to reproduce a tool I wrote in Maya to check the distance between islands to avoid bleeding when using mipmapping. I wish I was more "fluent" in ICE...

Thanks again
M.Yara
Character Modeler | Softimage Generalist (sort of)

User avatar
rray
Moderator
Posts: 1575
Joined: 26 Sep 2009, 15:51
Location: Bonn, Germany

Re: Accessing UV Islands

Post by rray » 23 Oct 2017, 14:53

You're welcome! Yes would've been useful to have a "get main UV" node in ICE for the main UV instead of having to select a specific one by name.

If it's applied in scripting there's at least a chance to set it inside the compound.
"as a maya discussion grows longer, the probability of a suggestion involving deleting the preferences approaches one"

softimage resources section (formerly known as rray.de/xsi) updated May 30 2018

User avatar
myara
Posts: 358
Joined: 28 Sep 2011, 10:33

Re: Accessing UV Islands

Post by myara » 26 Oct 2017, 16:54

I'm using your compound and it works perfect ! Can i use it in my plugin (mTextureEditor) ?

I wanted to use it for UV borders too, but it doesn't work well for that when the UV island are overlapped and folded in the middle like a XSI man head, sadly.
I guess I'll have to script something because I have no idea how to do it in ICE :D
M.Yara
Character Modeler | Softimage Generalist (sort of)

User avatar
rray
Moderator
Posts: 1575
Joined: 26 Sep 2009, 15:51
Location: Bonn, Germany

Re: Accessing UV Islands

Post by rray » 26 Oct 2017, 17:36

Great! Feel free to use it!

About uv mode, the compound would have to check each edge if its neighbor uv polygons are on the same side of the edge.
It's tricky however finding the exact meaning of "same side" (considering weird formed polygons) :)
Do you think checking the uv polygon centers is enough?
"as a maya discussion grows longer, the probability of a suggestion involving deleting the preferences approaches one"

softimage resources section (formerly known as rray.de/xsi) updated May 30 2018

User avatar
myara
Posts: 358
Joined: 28 Sep 2011, 10:33

Re: Accessing UV Islands

Post by myara » 27 Oct 2017, 05:37

I wouldn't mind if it doesn't support bad geometry or broken UVs. I was thinking in taking just one point of the neighbour polygon uv coordinates and triangulate with the edge, but centers would probably be better.
M.Yara
Character Modeler | Softimage Generalist (sort of)

User avatar
rray
Moderator
Posts: 1575
Joined: 26 Sep 2009, 15:51
Location: Bonn, Germany

Re: Accessing UV Islands

Post by rray » 27 Oct 2017, 17:05

Center turned out to be not so great because the polygon center can easily move on the other side of the edge if it's a 4+ sided polygon. I think testing 2 points very close to the edge and check if they're inside the 2 uv polygons is better

I'll try to put together a new compound tonight.

Image
(The house shaped part in the bottom right became it's own island because the center of the polyon above it is below the roof...)
"as a maya discussion grows longer, the probability of a suggestion involving deleting the preferences approaches one"

softimage resources section (formerly known as rray.de/xsi) updated May 30 2018

User avatar
rray
Moderator
Posts: 1575
Joined: 26 Sep 2009, 15:51
Location: Bonn, Germany

Re: Accessing UV Islands

Post by rray » 27 Oct 2017, 22:05

Image

There's a new tolerance settings that can deal with little errors in the uvs:
Image
You do not have the required permissions to view the files attached to this post.
"as a maya discussion grows longer, the probability of a suggestion involving deleting the preferences approaches one"

softimage resources section (formerly known as rray.de/xsi) updated May 30 2018

User avatar
myara
Posts: 358
Joined: 28 Sep 2011, 10:33

Re: Accessing UV Islands

Post by myara » 28 Oct 2017, 05:25

awesome I’ll try it as soon as I can ! thanks !
M.Yara
Character Modeler | Softimage Generalist (sort of)