mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-05-25 05:40:21 -04:00
improved
This commit is contained in:
parent
1cf59e8d67
commit
4f2046d412
@ -451,6 +451,10 @@ namespace AssetStudio
|
|||||||
public float[] m_UV1;
|
public float[] m_UV1;
|
||||||
public float[] m_UV2;
|
public float[] m_UV2;
|
||||||
public float[] m_UV3;
|
public float[] m_UV3;
|
||||||
|
public float[] m_UV4;
|
||||||
|
public float[] m_UV5;
|
||||||
|
public float[] m_UV6;
|
||||||
|
public float[] m_UV7;
|
||||||
public float[] m_Tangents;
|
public float[] m_Tangents;
|
||||||
private VertexData m_VertexData;
|
private VertexData m_VertexData;
|
||||||
private CompressedMesh m_CompressedMesh;
|
private CompressedMesh m_CompressedMesh;
|
||||||
@ -759,10 +763,18 @@ namespace AssetStudio
|
|||||||
case 7: //kShaderChannelTexCoord3
|
case 7: //kShaderChannelTexCoord3
|
||||||
m_UV3 = componentsFloatArray;
|
m_UV3 = componentsFloatArray;
|
||||||
break;
|
break;
|
||||||
//kShaderChannelTexCoord4 8
|
case 8: //kShaderChannelTexCoord4
|
||||||
//kShaderChannelTexCoord5 9
|
m_UV4 = componentsFloatArray;
|
||||||
//kShaderChannelTexCoord6 10
|
break;
|
||||||
//kShaderChannelTexCoord7 11
|
case 9: //kShaderChannelTexCoord5
|
||||||
|
m_UV5 = componentsFloatArray;
|
||||||
|
break;
|
||||||
|
case 10: //kShaderChannelTexCoord6
|
||||||
|
m_UV6 = componentsFloatArray;
|
||||||
|
break;
|
||||||
|
case 11: //kShaderChannelTexCoord7
|
||||||
|
m_UV7 = componentsFloatArray;
|
||||||
|
break;
|
||||||
//2018.2 and up
|
//2018.2 and up
|
||||||
case 12: //kShaderChannelBlendWeight
|
case 12: //kShaderChannelBlendWeight
|
||||||
if (m_Skin == null)
|
if (m_Skin == null)
|
||||||
@ -840,23 +852,40 @@ namespace AssetStudio
|
|||||||
if (m_CompressedMesh.m_Vertices.m_NumItems > 0)
|
if (m_CompressedMesh.m_Vertices.m_NumItems > 0)
|
||||||
{
|
{
|
||||||
m_VertexCount = (int)m_CompressedMesh.m_Vertices.m_NumItems / 3;
|
m_VertexCount = (int)m_CompressedMesh.m_Vertices.m_NumItems / 3;
|
||||||
m_Vertices = m_CompressedMesh.m_Vertices.UnpackFloats(3, 4);
|
m_Vertices = m_CompressedMesh.m_Vertices.UnpackFloats(3, 3 * 4);
|
||||||
}
|
}
|
||||||
//UV
|
//UV
|
||||||
if (m_CompressedMesh.m_UV.m_NumItems > 0)
|
if (m_CompressedMesh.m_UV.m_NumItems > 0)
|
||||||
{
|
{
|
||||||
m_UV0 = m_CompressedMesh.m_UV.UnpackFloats(2, 4, 0, m_VertexCount);
|
var m_UVInfo = m_CompressedMesh.m_UVInfo;
|
||||||
|
if (m_UVInfo != 0)
|
||||||
|
{
|
||||||
|
const int kInfoBitsPerUV = 4;
|
||||||
|
const int kUVDimensionMask = 3;
|
||||||
|
const int kUVChannelExists = 4;
|
||||||
|
const int kMaxTexCoordShaderChannels = 8;
|
||||||
|
|
||||||
|
int uvSrcOffset = 0;
|
||||||
|
for (int uv = 0; uv < kMaxTexCoordShaderChannels; uv++)
|
||||||
|
{
|
||||||
|
var texCoordBits = m_UVInfo >> (uv * kInfoBitsPerUV);
|
||||||
|
texCoordBits &= (1u << kInfoBitsPerUV) - 1u;
|
||||||
|
if ((texCoordBits & kUVChannelExists) != 0)
|
||||||
|
{
|
||||||
|
var uvDim = 1 + (int)(texCoordBits & kUVDimensionMask);
|
||||||
|
var m_UV = m_CompressedMesh.m_UV.UnpackFloats(uvDim, uvDim * 4, uvSrcOffset, m_VertexCount);
|
||||||
|
SetUV(uv, m_UV);
|
||||||
|
uvSrcOffset += uvDim * m_VertexCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_UV0 = m_CompressedMesh.m_UV.UnpackFloats(2, 2 * 4, 0, m_VertexCount);
|
||||||
if (m_CompressedMesh.m_UV.m_NumItems >= m_VertexCount * 4)
|
if (m_CompressedMesh.m_UV.m_NumItems >= m_VertexCount * 4)
|
||||||
{
|
{
|
||||||
m_UV1 = m_CompressedMesh.m_UV.UnpackFloats(2, 4, m_VertexCount * 2, m_VertexCount);
|
m_UV1 = m_CompressedMesh.m_UV.UnpackFloats(2, 2 * 4, m_VertexCount * 2, m_VertexCount);
|
||||||
}
|
}
|
||||||
if (m_CompressedMesh.m_UV.m_NumItems >= m_VertexCount * 6)
|
|
||||||
{
|
|
||||||
m_UV2 = m_CompressedMesh.m_UV.UnpackFloats(2, 4, m_VertexCount * 4, m_VertexCount);
|
|
||||||
}
|
|
||||||
if (m_CompressedMesh.m_UV.m_NumItems >= m_VertexCount * 8)
|
|
||||||
{
|
|
||||||
m_UV3 = m_CompressedMesh.m_UV.UnpackFloats(2, 4, m_VertexCount * 6, m_VertexCount);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//BindPose
|
//BindPose
|
||||||
@ -1066,6 +1095,39 @@ namespace AssetStudio
|
|||||||
m_Skin[i] = new BoneWeights4();
|
m_Skin[i] = new BoneWeights4();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetUV(int uv, float[] m_UV)
|
||||||
|
{
|
||||||
|
switch (uv)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
m_UV0 = m_UV;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
m_UV1 = m_UV;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
m_UV2 = m_UV;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
m_UV3 = m_UV;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
m_UV4 = m_UV;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
m_UV5 = m_UV;
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
m_UV6 = m_UV;
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
m_UV7 = m_UV;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new ArgumentOutOfRangeException();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MeshHelper
|
public static class MeshHelper
|
||||||
|
@ -167,24 +167,25 @@ namespace AssetStudioGUI
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region UV
|
#region UV
|
||||||
if (m_Mesh.m_UV0 != null && m_Mesh.m_UV0.Length == m_Mesh.m_VertexCount * 2)
|
if (m_Mesh.m_UV0?.Length > 0)
|
||||||
{
|
{
|
||||||
|
if (m_Mesh.m_UV0.Length == m_Mesh.m_VertexCount * 2)
|
||||||
|
{
|
||||||
|
c = 2;
|
||||||
|
}
|
||||||
|
else if (m_Mesh.m_UV0.Length == m_Mesh.m_VertexCount * 3)
|
||||||
|
{
|
||||||
|
c = 3;
|
||||||
|
}
|
||||||
for (int v = 0; v < m_Mesh.m_VertexCount; v++)
|
for (int v = 0; v < m_Mesh.m_VertexCount; v++)
|
||||||
{
|
{
|
||||||
sb.AppendFormat("vt {0} {1}\r\n", m_Mesh.m_UV0[v * 2], m_Mesh.m_UV0[v * 2 + 1]);
|
sb.AppendFormat("vt {0} {1}\r\n", m_Mesh.m_UV0[v * c], m_Mesh.m_UV0[v * c + 1]);
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (m_Mesh.m_UV1 != null && m_Mesh.m_UV1.Length == m_Mesh.m_VertexCount * 2)
|
|
||||||
{
|
|
||||||
for (int v = 0; v < m_Mesh.m_VertexCount; v++)
|
|
||||||
{
|
|
||||||
sb.AppendFormat("vt {0} {1}\r\n", m_Mesh.m_UV1[v * 2], m_Mesh.m_UV1[v * 2 + 1]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Normals
|
#region Normals
|
||||||
if (m_Mesh.m_Normals != null && m_Mesh.m_Normals.Length > 0)
|
if (m_Mesh.m_Normals?.Length > 0)
|
||||||
{
|
{
|
||||||
if (m_Mesh.m_Normals.Length == m_Mesh.m_VertexCount * 3)
|
if (m_Mesh.m_Normals.Length == m_Mesh.m_VertexCount * 3)
|
||||||
{
|
{
|
||||||
|
@ -341,13 +341,17 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//UV
|
//UV
|
||||||
if (mesh.m_UV0 != null && mesh.m_UV0.Length == mesh.m_VertexCount * 2)
|
if (mesh.m_UV0?.Length > 0)
|
||||||
{
|
{
|
||||||
iVertex.UV = new[] { mesh.m_UV0[j * 2], mesh.m_UV0[j * 2 + 1] };
|
if (mesh.m_UV0.Length == mesh.m_VertexCount * 2)
|
||||||
|
{
|
||||||
|
c = 2;
|
||||||
}
|
}
|
||||||
else if (mesh.m_UV1 != null && mesh.m_UV1.Length == mesh.m_VertexCount * 2)
|
else if (mesh.m_UV0.Length == mesh.m_VertexCount * 3)
|
||||||
{
|
{
|
||||||
iVertex.UV = new[] { mesh.m_UV1[j * 2], mesh.m_UV1[j * 2 + 1] };
|
c = 3;
|
||||||
|
}
|
||||||
|
iVertex.UV = new[] { mesh.m_UV0[j * c], mesh.m_UV0[j * c + 1] };
|
||||||
}
|
}
|
||||||
//Tangent
|
//Tangent
|
||||||
if (mesh.m_Tangents != null && mesh.m_Tangents.Length == mesh.m_VertexCount * 4)
|
if (mesh.m_Tangents != null && mesh.m_Tangents.Length == mesh.m_VertexCount * 4)
|
||||||
@ -576,7 +580,6 @@ namespace AssetStudio
|
|||||||
iMat.Emissive = col.Value;
|
iMat.Emissive = col.Value;
|
||||||
break;
|
break;
|
||||||
case "_SpecularColor":
|
case "_SpecularColor":
|
||||||
case "_SpecColor":
|
|
||||||
iMat.Specular = col.Value;
|
iMat.Specular = col.Value;
|
||||||
break;
|
break;
|
||||||
case "_ReflectColor":
|
case "_ReflectColor":
|
||||||
|
Loading…
Reference in New Issue
Block a user