x


How does submesh index map to material?

What I did was make a cube in Sketchup, set each side with a different material, exported as 2-sided FBX, imported to Unity. As expected, there are 7 materials (one for each exterior face and one for the 'inside' faces). And 24 triangles (2 per face, and 2 sets of those per side of the cube (exterior and interior). I examine the triangle index from the raycast hit, and using Scrooge's script, find the submesh. The index I get does not correspond to the order a that materials are listed in the IDE. So is there something I'm missing, is there a hidden API or member that maps submesh to material?

more ▼

asked Aug 01 '12 at 12:03 AM

artie gravatar image

artie
192 6 7 10

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

i'd check it right now. submesh index and material index are the same. both are zero-based. if you get another result somewhere - show us example.

more ▼

answered Aug 01 '12 at 05:35 AM

ScroodgeM gravatar image

ScroodgeM
7.6k 2 6

See other post. Will put up screen shots tomorrow. Basically (using your script) I do get submesh indices 0 to 5 as expected (hitting exterior triangles of course), but the materials on those triangles don't follow the same order as what I see listed (top to bottom) in the inspector. Well now that I think of it, I'm looking at the material sample list (on the object), not the array of materials (by name) on the MeshRenderer. Maybe those don't jibe? Anyway, will check manana.

Aug 01 '12 at 07:01 AM artie

waiting for screenshots 8)

Aug 01 '12 at 04:38 PM ScroodgeM
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x813
x20

asked: Aug 01 '12 at 12:03 AM

Seen: 652 times

Last Updated: Aug 01 '12 at 04:38 PM