-- Copyright Harmonikater 2017 based on Martijn Buijs' (Remdul) Meshman Code
-- Copyright Harmonikater 2017 based on Martijn Buijs' (Remdul) Meshman Code
-- http:--www.bytehazard.com
g_bf2doInclude "general/misc.ms"
...
...
@@ -438,6 +438,15 @@ struct bf2mesh
)
return 0
),
fn GetTexc UsageID =
(
if UsageID == 5 do return 1
if UsageID == 261 do return 2
if UsageID == 517 do return 3
if UsageID == 773 do return 4
if UsageID == 1029 do return 5
return 0
),
fn GetTexcOffset uvchan =
(
if uvchan == 1 do return (GetAttribOffset 5)
...
...
@@ -447,6 +456,18 @@ struct bf2mesh
if uvchan == 5 do return (GetAttribOffset 1029)
return 0
),
fn getHighestTexc =
(
local highest = 5
for i=1 to vertattribnum do
(
if vertattrib[i].usage > highest and vertattrib[i].usage != 6 then
(
highest = vertattrib[i].usage
)
)
return (GetTexc highest)
),
fn GetWeightOffset =
(
return GetAttribOffset 2
...
...
@@ -953,8 +974,11 @@ fn alternate_meshImport fname lightmapInt s =
-- set the number of uv channels (5 for static meshes, 1 for all others)
local minUVs = 1
local maxUVs = 1
if (curMesh.isBundledMesh != true) and (curMesh.isSkinnedMesh != true) do maxUVs = 5
if (lightmapInt == 1) and not isAlphaOrOG do minUVs = 5
if (curMesh.isBundledMesh != true) and (curMesh.isSkinnedMesh != true) then
(
maxUVs = curMesh.getHighestTexc()
if (lightmapInt == 1) and not isAlphaOrOG do minUVs = curMesh.getHighestTexc()
)
-- get the indices of each uv channel in the vertex table
local attriboff = #()
...
...
@@ -1124,9 +1148,12 @@ fn alternate_meshImport fname lightmapInt s =
(
idxUV = uvChan - minUVs + 1
local tochan = uvchan
if (lightmapInt == 1 and uvchan == 5) do tochan = 9
if (curMesh.isBundledMesh != true) and (curMesh.isSkinnedMesh != true) then
(
if (lightmapInt == 1 and uvchan == maxUVs and ((findString fname "/vegitation/" == undefined) and (findString fname "\\vegitation\\" == undefined))) do tochan = 9
)
--create the channel if necessary
if uvchan > 1 do meshop.setNumMaps newObj (tochan+1)
if uvchan >= 1 do meshop.setNumMaps newObj (tochan+1)
--set this channel active (doesn't init the tvert array)