mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-05-25 05:40:21 -04:00
multiple uv export
This commit is contained in:
parent
c71ceb7ea6
commit
d259c7a5cd
@ -1160,6 +1160,31 @@ namespace AssetStudio
|
||||
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
|
||||
|
@ -135,7 +135,7 @@ namespace AssetStudio
|
||||
public List<ImportedSubmesh> SubmeshList { get; set; }
|
||||
public List<ImportedBone> BoneList { get; set; }
|
||||
public bool hasNormal { get; set; }
|
||||
public bool hasUV { get; set; }
|
||||
public bool[] hasUV { get; set; }
|
||||
public bool hasTangent { get; set; }
|
||||
public bool hasColor { get; set; }
|
||||
}
|
||||
@ -151,7 +151,7 @@ namespace AssetStudio
|
||||
{
|
||||
public Vector3 Vertex { get; set; }
|
||||
public Vector3 Normal { get; set; }
|
||||
public float[] UV { get; set; }
|
||||
public float[][] UV { get; set; }
|
||||
public Vector4 Tangent { get; set; }
|
||||
public Color Color { get; set; }
|
||||
public float[] Weights { get; set; }
|
||||
|
@ -381,12 +381,14 @@ namespace AssetStudio
|
||||
lGeometryElementNormal->SetReferenceMode(FbxGeometryElement::eDirect);
|
||||
}
|
||||
|
||||
FbxGeometryElementUV* lGeometryElementUV = NULL;
|
||||
if (iMesh->hasUV)
|
||||
for (int uv = 0; uv < 8; uv++)
|
||||
{
|
||||
lGeometryElementUV = pMesh->CreateElementUV("UV0");
|
||||
lGeometryElementUV->SetMappingMode(FbxGeometryElement::eByControlPoint);
|
||||
lGeometryElementUV->SetReferenceMode(FbxGeometryElement::eDirect);
|
||||
if (iMesh->hasUV[uv])
|
||||
{
|
||||
auto lGeometryElementUV = pMesh->CreateElementUV(FbxString("UV") + FbxString(uv));
|
||||
lGeometryElementUV->SetMappingMode(FbxGeometryElement::eByControlPoint);
|
||||
lGeometryElementUV->SetReferenceMode(FbxGeometryElement::eDirect);
|
||||
}
|
||||
}
|
||||
|
||||
FbxGeometryElementTangent* lGeometryElementTangent = NULL;
|
||||
@ -468,7 +470,7 @@ namespace AssetStudio
|
||||
|
||||
bool hasTexture = false;
|
||||
|
||||
for each (ImportedMaterialTexture^ texture in mat->Textures)
|
||||
for each (ImportedMaterialTexture ^ texture in mat->Textures)
|
||||
{
|
||||
auto pTexture = ExportTexture(ImportedHelpers::FindTexture(texture->Name, imported->TextureList));
|
||||
if (pTexture != NULL)
|
||||
@ -520,10 +522,14 @@ namespace AssetStudio
|
||||
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;
|
||||
lGeometryElementUV->GetDirectArray().Add(FbxVector2(uv[0], uv[1]));
|
||||
if (iMesh->hasUV[uv])
|
||||
{
|
||||
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)
|
||||
@ -841,7 +847,7 @@ namespace AssetStudio
|
||||
{
|
||||
return;
|
||||
}
|
||||
for each (ImportedMorph^ morph in imported->MorphList)
|
||||
for each (ImportedMorph ^ morph in imported->MorphList)
|
||||
{
|
||||
auto frame = imported->RootFrame->FindFrameByPath(morph->Path);
|
||||
if (frame != nullptr)
|
||||
@ -865,7 +871,7 @@ namespace AssetStudio
|
||||
);
|
||||
lBlendShape->AddBlendShapeChannel(lBlendShapeChannel);
|
||||
|
||||
for each(ImportedMorphKeyframe^ keyframe in channel->KeyframeList)
|
||||
for each (ImportedMorphKeyframe ^ keyframe in channel->KeyframeList)
|
||||
{
|
||||
FbxShape* lShape = FbxShape::Create(pScene, FbxString(keyframe->Weight));
|
||||
lBlendShapeChannel->AddTargetShape(lShape, keyframe->Weight);
|
||||
|
@ -285,7 +285,11 @@ namespace AssetStudio
|
||||
}
|
||||
|
||||
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.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]);
|
||||
}
|
||||
//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])
|
||||
{
|
||||
c = 2;
|
||||
var m_UV = mesh.GetUV(uv);
|
||||
if (m_UV.Length == mesh.m_VertexCount * 2)
|
||||
{
|
||||
c = 2;
|
||||
}
|
||||
else if (m_UV.Length == mesh.m_VertexCount * 3)
|
||||
{
|
||||
c = 3;
|
||||
}
|
||||
iVertex.UV[uv] = new[] { m_UV[j * c], m_UV[j * c + 1] };
|
||||
}
|
||||
else if (mesh.m_UV0.Length == mesh.m_VertexCount * 3)
|
||||
{
|
||||
c = 3;
|
||||
}
|
||||
iVertex.UV = new[] { mesh.m_UV0[j * c], mesh.m_UV0[j * c + 1] };
|
||||
}
|
||||
//Tangent
|
||||
if (iMesh.hasTangent)
|
||||
|
Loading…
Reference in New Issue
Block a user