mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-05-27 22:00:23 -04:00
multiple uv export
This commit is contained in:
parent
c71ceb7ea6
commit
d259c7a5cd
@ -1160,6 +1160,31 @@ namespace AssetStudio
|
|||||||
throw new ArgumentOutOfRangeException();
|
throw new ArgumentOutOfRangeException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float[] GetUV(int uv)
|
||||||
|
{
|
||||||
|
switch (uv)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
return m_UV0;
|
||||||
|
case 1:
|
||||||
|
return m_UV1;
|
||||||
|
case 2:
|
||||||
|
return m_UV2;
|
||||||
|
case 3:
|
||||||
|
return m_UV3;
|
||||||
|
case 4:
|
||||||
|
return m_UV4;
|
||||||
|
case 5:
|
||||||
|
return m_UV5;
|
||||||
|
case 6:
|
||||||
|
return m_UV6;
|
||||||
|
case 7:
|
||||||
|
return m_UV7;
|
||||||
|
default:
|
||||||
|
throw new ArgumentOutOfRangeException();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MeshHelper
|
public static class MeshHelper
|
||||||
|
@ -135,7 +135,7 @@ namespace AssetStudio
|
|||||||
public List<ImportedSubmesh> SubmeshList { get; set; }
|
public List<ImportedSubmesh> SubmeshList { get; set; }
|
||||||
public List<ImportedBone> BoneList { get; set; }
|
public List<ImportedBone> BoneList { get; set; }
|
||||||
public bool hasNormal { get; set; }
|
public bool hasNormal { get; set; }
|
||||||
public bool hasUV { get; set; }
|
public bool[] hasUV { get; set; }
|
||||||
public bool hasTangent { get; set; }
|
public bool hasTangent { get; set; }
|
||||||
public bool hasColor { get; set; }
|
public bool hasColor { get; set; }
|
||||||
}
|
}
|
||||||
@ -151,7 +151,7 @@ namespace AssetStudio
|
|||||||
{
|
{
|
||||||
public Vector3 Vertex { get; set; }
|
public Vector3 Vertex { get; set; }
|
||||||
public Vector3 Normal { get; set; }
|
public Vector3 Normal { get; set; }
|
||||||
public float[] UV { get; set; }
|
public float[][] UV { get; set; }
|
||||||
public Vector4 Tangent { get; set; }
|
public Vector4 Tangent { get; set; }
|
||||||
public Color Color { get; set; }
|
public Color Color { get; set; }
|
||||||
public float[] Weights { get; set; }
|
public float[] Weights { get; set; }
|
||||||
|
@ -381,13 +381,15 @@ namespace AssetStudio
|
|||||||
lGeometryElementNormal->SetReferenceMode(FbxGeometryElement::eDirect);
|
lGeometryElementNormal->SetReferenceMode(FbxGeometryElement::eDirect);
|
||||||
}
|
}
|
||||||
|
|
||||||
FbxGeometryElementUV* lGeometryElementUV = NULL;
|
for (int uv = 0; uv < 8; uv++)
|
||||||
if (iMesh->hasUV)
|
|
||||||
{
|
{
|
||||||
lGeometryElementUV = pMesh->CreateElementUV("UV0");
|
if (iMesh->hasUV[uv])
|
||||||
|
{
|
||||||
|
auto lGeometryElementUV = pMesh->CreateElementUV(FbxString("UV") + FbxString(uv));
|
||||||
lGeometryElementUV->SetMappingMode(FbxGeometryElement::eByControlPoint);
|
lGeometryElementUV->SetMappingMode(FbxGeometryElement::eByControlPoint);
|
||||||
lGeometryElementUV->SetReferenceMode(FbxGeometryElement::eDirect);
|
lGeometryElementUV->SetReferenceMode(FbxGeometryElement::eDirect);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FbxGeometryElementTangent* lGeometryElementTangent = NULL;
|
FbxGeometryElementTangent* lGeometryElementTangent = NULL;
|
||||||
if (iMesh->hasTangent)
|
if (iMesh->hasTangent)
|
||||||
@ -520,10 +522,14 @@ namespace AssetStudio
|
|||||||
lGeometryElementNormal->GetDirectArray().Add(FbxVector4(normal.X, normal.Y, normal.Z, 0));
|
lGeometryElementNormal->GetDirectArray().Add(FbxVector4(normal.X, normal.Y, normal.Z, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iMesh->hasUV)
|
for (int uv = 0; uv < 8; uv++)
|
||||||
{
|
{
|
||||||
array<float>^ uv = iVertex->UV;
|
if (iMesh->hasUV[uv])
|
||||||
lGeometryElementUV->GetDirectArray().Add(FbxVector2(uv[0], uv[1]));
|
{
|
||||||
|
auto m_UV = iVertex->UV[uv];
|
||||||
|
auto lGeometryElementUV = pMesh->GetElementUV(FbxString("UV") + FbxString(uv));
|
||||||
|
lGeometryElementUV->GetDirectArray().Add(FbxVector2(m_UV[0], m_UV[1]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iMesh->hasTangent)
|
if (iMesh->hasTangent)
|
||||||
|
@ -285,7 +285,11 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
|
|
||||||
iMesh.hasNormal = mesh.m_Normals?.Length > 0;
|
iMesh.hasNormal = mesh.m_Normals?.Length > 0;
|
||||||
iMesh.hasUV = mesh.m_UV0?.Length > 0;
|
iMesh.hasUV = new bool[8];
|
||||||
|
for (int uv = 0; uv < 8; uv++)
|
||||||
|
{
|
||||||
|
iMesh.hasUV[uv] = mesh.GetUV(uv)?.Length > 0;
|
||||||
|
}
|
||||||
iMesh.hasTangent = mesh.m_Tangents != null && mesh.m_Tangents.Length == mesh.m_VertexCount * 4;
|
iMesh.hasTangent = mesh.m_Tangents != null && mesh.m_Tangents.Length == mesh.m_VertexCount * 4;
|
||||||
iMesh.hasColor = mesh.m_Colors?.Length > 0;
|
iMesh.hasColor = mesh.m_Colors?.Length > 0;
|
||||||
|
|
||||||
@ -335,17 +339,22 @@ namespace AssetStudio
|
|||||||
iVertex.Normal = new Vector3(-mesh.m_Normals[j * c], mesh.m_Normals[j * c + 1], mesh.m_Normals[j * c + 2]);
|
iVertex.Normal = new Vector3(-mesh.m_Normals[j * c], mesh.m_Normals[j * c + 1], mesh.m_Normals[j * c + 2]);
|
||||||
}
|
}
|
||||||
//UV
|
//UV
|
||||||
if (iMesh.hasUV)
|
iVertex.UV = new float[8][];
|
||||||
|
for (int uv = 0; uv < 8; uv++)
|
||||||
{
|
{
|
||||||
if (mesh.m_UV0.Length == mesh.m_VertexCount * 2)
|
if (iMesh.hasUV[uv])
|
||||||
|
{
|
||||||
|
var m_UV = mesh.GetUV(uv);
|
||||||
|
if (m_UV.Length == mesh.m_VertexCount * 2)
|
||||||
{
|
{
|
||||||
c = 2;
|
c = 2;
|
||||||
}
|
}
|
||||||
else if (mesh.m_UV0.Length == mesh.m_VertexCount * 3)
|
else if (m_UV.Length == mesh.m_VertexCount * 3)
|
||||||
{
|
{
|
||||||
c = 3;
|
c = 3;
|
||||||
}
|
}
|
||||||
iVertex.UV = new[] { mesh.m_UV0[j * c], mesh.m_UV0[j * c + 1] };
|
iVertex.UV[uv] = new[] { m_UV[j * c], m_UV[j * c + 1] };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//Tangent
|
//Tangent
|
||||||
if (iMesh.hasTangent)
|
if (iMesh.hasTangent)
|
||||||
|
Loading…
Reference in New Issue
Block a user