Thursday, May 25, 2017

When I reverse engineer models, I don't think too much about abnormalities. Normally it is just the vertices, indices or faces, normals and texture coordinates.
These are the primary things I look for and apply them to a mesh in 3D Studio Max.
For long I used the following method to apply texture coordinates:

local theMesh = mesh vertices:vertex_list \
name:meshName \
faces:faces_list \
vnorms:normal_list \

buildTVFaces theMesh false

for f = 1 to faces_list.count do
setTVFace theMesh f faces_list[f]

update theMesh

This was my method to make it work.
Recently I stumbled on a more advanced setup, that of Overwatch models. They have multiple UVW map channels. So I need to apply this to the imported model too.
At first it looked like impossible job...

After reading, like, a LOT of the documentation and searching the internet, which of course had no real solution and certainly no example, I had to figure this out by myself.

So here is my solution:

meshop.setMapSupport theMesh 1 true
for i=1 to textcoord_list[1].count do
meshop.setMapVert theMesh 1 i textcoord_list[1][i]
meshop.buildMapFaces theMesh 1
update theMesh

if(textcoord_list.count>1) then
Format "Applying secondary uv texture coordinates mapping"

meshop.setNumMaps theMesh 3
meshop.setMapSupport theMesh 2 true
for i=1 to textcoord_list[2].count do
meshop.setMapVert theMesh 2 i textcoord_list[2][i]

meshop.buildMapFaces theMesh 2
update theMesh


For each additional channel, up to 99, you need to set the number of supported maps explicitly.

How can you see these mappings?
Select the model and add the "Unwrap UVW" modifier and press "Edit..." for the initial texture coordinates.
Change the channel to 2 and press the button "Reset UVWs", when prompted, press Yes. And press the "Edit..." button again.
This will display the second applied texture coordinates as shown in the picture below.

Secondary texture coordinates are usually used as an emission map or light map.


Changes to my 3D Model Viewer v3.2 Support for Overwatch models, raw models and owmdl files both file types can be exported via a tool c...