How are textures mapped to mesh objects?

I have learned a lot about the structure of character mesh files, and what I didn't know Sir Kane's 3ds mesh importer (http://www.saintsrowmods.com/forum/threads/mesh-importer-for-3ds-max.4661/) was useful for filling in the gaps. But one thing I still can't figure out is how textures are mapped to mesh objects.

Each character mesh is divided up into multiple mesh objects with each mesh object representing the exact same model but with different levels of detail. Using Kinzie (npc_Kinzie.str2_pc) as an example, shows that the character mesh is divided into four objects (or four lod). The highest lod is divided up into six different draw calls with each draw call representing a different portion of the model (in this order as read from the CMESH):
  • jacket
  • gloves, buttons, glasses
  • hair(bangs, bun)
  • pants
  • shoes
  • finger tips
And of course the CMESH file also has a list of textures associated with it (in this order as read from the CMESH):
  • kinzie_sm_upper_d
  • kinzie_sm_upper_n
  • hair_blonde_01_sb
  • leather_02_sb
  • cloth_matte_02_sb
  • skin_ca_02_sb
  • kinzie_sm_lower_d
  • kinzie_sm_lower_n
Now Sir Kane did identify what he called a MaterialIndex associated with each draw call and it is consistent from one object to the next but a texture is not a material. They don't match up as I have found. For one thing it doesn't account for multiple textures (diffuse and normal) being used together.

So how does the game know what texture goes to a particular draw call in a mesh object?
 
I don't know 'all' of the proper crunched file specifics but what you have seems to be correct. The material of course has the referenced textures ( D, N, etc ) and assigned shader and the mesh components/draw calls are based off of unique materials. This may or may not be very helpful.

LOD 0
< Material >
- < Mesh >
-- < Verts >
-- < Faces >
-- < UVs >
-- < SkinWeights >
< Material >
- < Mesh >
...

LOD 1
< Material >
- < Mesh >
< Material >
- < Mesh >
 
Somewhat useful. There is a section at the end of the CMESH that fits your example. But it doesn't list texture names and doesn't have anything that looks like the texture indexes. How would a reference to a texture be included, by hash, sum, crc or some other method? I'm assuming everything necessary is included in the STR2 bundle and not hidden away elsewhere (making an exception of course for common textures like hair_blonde etc...).
 
Somewhat useful. There is a section at the end of the CMESH that fits your example. But it doesn't list texture names and doesn't have anything that looks like the texture indexes. How would a reference to a texture be included, by hash, sum, crc or some other method? I'm assuming everything necessary is included in the STR2 bundle and not hidden away elsewhere (making an exception of course for common textures like hair_blonde etc...).

I'm not too familiar with whats in the actual crunched data but I would assume a crc should be in the STR2. I'll try to confirm.
 
Back
Top