Skip to content

Commit

Permalink
version 152
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeoverbay committed Oct 10, 2024
1 parent a3be02c commit a93d21c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 29 deletions.
54 changes: 30 additions & 24 deletions !_Tank Exporter/Modules/get_FBX.vb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ Module get_FBX

fbxgrp(item).nPrimitives_ = mesh.FaceCount
fbxgrp(item).nVertices_ = mesh.VertexCount

If mesh.HasVertexColors(0) Then
ReDim fbxgrp(item).vertColor(mesh.VertexCount)
End If
If mesh.HasVertexColors(1) Then
ReDim fbxgrp(item).vertColor(mesh.VertexCount)
End If
' Debug output for mesh data
'Debug.WriteLine("Processing Mesh: " & mesh.Name)
'Debug.WriteLine("Vertex Count: " & mesh.VertexCount)
Expand All @@ -90,48 +95,49 @@ Module get_FBX
End If
Next

cnt = 0
Dim vertexIndex As Integer = 0 ' To keep track of global vertex index across primitives
For Each vert In mesh.Vertices
fbxgrp(item).stride = 37
fbxgrp(item).stride = 32
If cnt = mesh.VertexCount Then Exit For ' Ensure we do not exceed the array bounds
fbxgrp(item).vertices(cnt) = New vertice_
fbxgrp(item).vertices(cnt).x = vert.X
fbxgrp(item).vertices(cnt).y = vert.Y
fbxgrp(item).vertices(cnt).z = vert.Z
fbxgrp(item).vertices(vertexIndex) = New vertice_
fbxgrp(item).vertices(vertexIndex).x = vert.X
fbxgrp(item).vertices(vertexIndex).y = vert.Y
fbxgrp(item).vertices(vertexIndex).z = vert.Z
If mesh.HasNormals Then
fbxgrp(item).vertices(cnt).nx = mesh.Normals(cnt).X
fbxgrp(item).vertices(cnt).ny = mesh.Normals(cnt).Y
fbxgrp(item).vertices(cnt).nz = mesh.Normals(cnt).Z
fbxgrp(item).vertices(vertexIndex).nx = mesh.Normals(vertexIndex).X
fbxgrp(item).vertices(vertexIndex).ny = mesh.Normals(vertexIndex).Y
fbxgrp(item).vertices(vertexIndex).nz = mesh.Normals(vertexIndex).Z
End If
If mesh.HasTextureCoords(0) Then
fbxgrp(item).vertices(cnt).u = mesh.TextureCoordinateChannels(0)(cnt).X
fbxgrp(item).vertices(cnt).v = -mesh.TextureCoordinateChannels(0)(cnt).Y
fbxgrp(item).vertices(vertexIndex).u = mesh.TextureCoordinateChannels(0)(vertexIndex).X
fbxgrp(item).vertices(vertexIndex).v = -mesh.TextureCoordinateChannels(0)(vertexIndex).Y
End If
If mesh.HasTextureCoords(1) Then
fbxgrp(item).vertices(cnt).u2 = mesh.TextureCoordinateChannels(1)(cnt).X
fbxgrp(item).vertices(cnt).v2 = -mesh.TextureCoordinateChannels(1)(cnt).Y
fbxgrp(item).vertices(vertexIndex).u2 = mesh.TextureCoordinateChannels(1)(vertexIndex).X
fbxgrp(item).vertices(vertexIndex).v2 = -mesh.TextureCoordinateChannels(1)(vertexIndex).Y
fbxgrp(item).has_uv2 = 1
Else
fbxgrp(item).has_uv2 = 0
End If
If mesh.HasVertexColors(1) Then
fbxgrp(item).stride = 37
fbxgrp(item).has_color = 1
Dim c = mesh.VertexColorChannels(1)(cnt)
fbxgrp(item).vertices(cnt).weight_1 = CByte(c.R * 255)
fbxgrp(item).vertices(cnt).weight_2 = CByte(c.G * 255)
fbxgrp(item).vertices(cnt).weight_3 = CByte(c.B * 255)
fbxgrp(item).vertices(cnt).weight_4 = CByte(c.A * 255)
Dim c = mesh.VertexColorChannels(1)(vertexIndex)
fbxgrp(item).vertColor(vertexIndex) = New Vector4()
fbxgrp(item).vertColor(vertexIndex).X = CByte(c.R * 255)
fbxgrp(item).vertColor(vertexIndex).Y = CByte(c.G * 255)
fbxgrp(item).vertColor(vertexIndex).Z = CByte(c.B * 255)
fbxgrp(item).vertColor(vertexIndex).W = 255
End If
If mesh.HasVertexColors(0) Then
fbxgrp(item).stride = 40
fbxgrp(item).has_color = 1
Dim c = mesh.VertexColorChannels(0)(cnt)
fbxgrp(item).vertices(cnt).index_1 = CByte(c.R * 255)
fbxgrp(item).vertices(cnt).index_2 = CByte(c.G * 255)
fbxgrp(item).vertices(cnt).index_3 = CByte(c.B * 255)
Dim c = mesh.VertexColorChannels(0)(vertexIndex)
fbxgrp(item).vertColor(vertexIndex).X = CByte(c.R * 255)
fbxgrp(item).vertColor(vertexIndex).Y = CByte(c.G * 255)
fbxgrp(item).vertColor(vertexIndex).Z = CByte(c.B * 255)
End If
cnt += 1
vertexIndex += 1
Next
'Debug.WriteLine(cnt.ToString + " " + item.ToString)

Expand Down
2 changes: 1 addition & 1 deletion !_Tank Exporter/Modules/modFBX.vb
Original file line number Diff line number Diff line change
Expand Up @@ -1321,7 +1321,7 @@ outahere:
fbx_in.specular_id = fbx_out.specular_id
fbx_in.texture_count = fbx_out.texture_count
fbx_in.has_uv2 = fbx_out.has_uv2
fbx_in.has_Vcolor = fbx_out.has_Vcolor
fbx_in.has_color = fbx_out.has_color
fbx_in.bumped = fbx_out.bumped
fbx_in.stride = fbx_out.stride

Expand Down
10 changes: 6 additions & 4 deletions !_Tank Exporter/Modules/modPrimWriter.vb
Original file line number Diff line number Diff line change
Expand Up @@ -988,11 +988,12 @@ found_section:
ReDim fbx_uv2s(1000000)
obj_cnt = m_groups(ID).cnt
Try
r = New FileStream(My.Settings.res_mods_path + "\" + m_groups(ID).f_name(0).Replace(".model", ".primitives_processed"), FileMode.OpenOrCreate, FileAccess.Write)
r = New FileStream(My.Settings.res_mods_path + "\" + m_groups(ID).f_name(0).Replace(".model", ".primitives_processed"), FileMode.Truncate, FileAccess.Write)
Catch e As Exception
MsgBox("I could not open """ + My.Settings.res_mods_path + "\" + m_groups(ID).f_name(0) + """!" + vbCrLf +
"The Root folder is there but there are no .primitive_processed files." + vbCrLf _
"The Root folder is there but there are no .primitive_processed files." + vbCrLf _
+ " Did you delete them?", MsgBoxStyle.Exclamation, "Can find folder!")
frmMain.m_extract.PerformClick()
Return
End Try

Expand Down Expand Up @@ -1538,7 +1539,7 @@ no_UV2EVER:
total_indices = 0
For i = 1 To obj_cnt
pnter = m_groups(id).list(i - 1)
total_indices += fbxgrp(pnter).comp.indi_cnt
total_indices += fbxgrp(pnter).indices.Length
Next
Dim h2() = "list".ToArray
ind_scale = 2
Expand All @@ -1548,7 +1549,7 @@ no_UV2EVER:
End If
ReDim Preserve h2(63)
br.Write(h2)
br.Write(total_indices)
br.Write(total_indices * 3)
br.Write(Convert.ToUInt32(obj_cnt)) 'write how many objects there are in this model
Dim off As UInt32 = 0
For i = 1 To obj_cnt
Expand Down Expand Up @@ -1623,6 +1624,7 @@ no_UV2EVER:
off += comp.vert_cnt
Next
Dim s_index, s_vertex As UInt32
indi_cnt = 0
For i = 1 To obj_cnt
pnter = m_groups(id).list(i - 1)
Dim pnter2 = pnter
Expand Down

0 comments on commit a93d21c

Please sign in to comment.