This commit is contained in:
Razmoth
2023-01-06 22:33:59 +04:00
parent a3cf868dfb
commit 2b31232b30
178 changed files with 5213 additions and 23780 deletions

View File

@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Version>0.18.60</Version>
<AssemblyVersion>0.18.60</AssemblyVersion>
<FileVersion>0.18.60</FileVersion>
<Version>0.80.30</Version>
<AssemblyVersion>0.80.30</AssemblyVersion>
<FileVersion>0.80.30</FileVersion>
<Copyright>Copyright © Perfare 2018-2022; Copyright © hozuki 2020</Copyright>
<DebugType>embedded</DebugType>
<DebugType>embedded</DebugType>
</PropertyGroup>
<ItemGroup>

View File

@@ -6,11 +6,11 @@ namespace AssetStudio
partial class Fbx
{
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsUtilQuaternionToEuler(float qx, float qy, float qz, float qw, out float vx, out float vy, out float vz);
[LibraryImport(FbxDll.DllName)]
private static partial void AsUtilQuaternionToEuler(float qx, float qy, float qz, float qw, out float vx, out float vy, out float vz);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsUtilEulerToQuaternion(float vx, float vy, float vz, out float qx, out float qy, out float qz, out float qw);
[LibraryImport(FbxDll.DllName)]
private static partial void AsUtilEulerToQuaternion(float vx, float vy, float vz, out float qx, out float qy, out float qz, out float qw);
}
}

View File

@@ -1,171 +1,100 @@
using System;
using System.Runtime.InteropServices;
using AssetStudio.PInvoke;
using System.Runtime.InteropServices;
namespace AssetStudio.FbxInterop
{
partial class FbxExporterContext
{
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr AsFbxCreateContext();
[LibraryImport(FbxDll.DllName)]
private static partial nint AsFbxCreateContext();
private static bool AsFbxInitializeContext(IntPtr context, string fileName, float scaleFactor, int versionIndex, bool isAscii, bool is60Fps, out string errorMessage)
{
bool b;
IntPtr pErrMsg;
using (var fileNameUtf8 = new Utf8StringHandle(fileName))
{
b = AsFbxInitializeContext(context, fileNameUtf8.DangerousGetHandle(), scaleFactor, versionIndex, isAscii, is60Fps, out pErrMsg);
}
errorMessage = Utf8StringHandle.ReadUtf8StringFromPointer(pErrMsg);
return b;
}
// Do not free the pointer strErrorMessage
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
[LibraryImport(FbxDll.DllName, StringMarshalling = StringMarshalling.Utf8)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool AsFbxInitializeContext(IntPtr context, IntPtr strFileName, float scaleFactor, int versionIndex, [MarshalAs(UnmanagedType.Bool)] bool isAscii, [MarshalAs(UnmanagedType.Bool)] bool is60Fps, out IntPtr strErrorMessage);
private static partial bool AsFbxInitializeContext(nint context, string fileName, float scaleFactor, int versionIndex, [MarshalAs(UnmanagedType.Bool)] bool isAscii, [MarshalAs(UnmanagedType.Bool)] bool is60Fps, out string errorMessage);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxDisposeContext(ref IntPtr ppContext);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxDisposeContext(ref nint ppContext);
private static void AsFbxSetFramePaths(IntPtr context, string[] framePaths)
private static void AsFbxSetFramePaths(nint context, string[] framePaths) => AsFbxSetFramePaths(context, framePaths, framePaths.Length);
[LibraryImport(FbxDll.DllName, StringMarshalling = StringMarshalling.Utf8)]
private static partial void AsFbxSetFramePaths(nint context, string[] framePaths, int count);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxExportScene(nint context);
[LibraryImport(FbxDll.DllName)]
private static partial nint AsFbxGetSceneRootNode(nint context);
private static nint AsFbxExportSingleFrame(nint context, nint parentNode, string framePath, string frameName, in Vector3 localPosition, in Vector3 localRotation, in Vector3 localScale)
{
var framePathCount = framePaths.Length;
if (framePathCount == 0)
{
AsFbxSetFramePaths(context, Array.Empty<IntPtr>(), 0);
}
else
{
var utf8Paths = new Utf8StringHandle[framePathCount];
try
{
for (var i = 0; i < framePathCount; i += 1)
{
utf8Paths[i] = new Utf8StringHandle(framePaths[i]);
}
var pathPointers = new IntPtr[framePathCount];
for (var i = 0; i < framePathCount; i += 1)
{
pathPointers[i] = utf8Paths[i].DangerousGetHandle();
}
AsFbxSetFramePaths(context, pathPointers, framePathCount);
}
finally
{
foreach (var path in utf8Paths)
{
path?.Dispose();
}
}
}
return AsFbxExportSingleFrame(context, parentNode, framePath, frameName, localPosition.X, localPosition.Y, localPosition.Z, localRotation.X, localRotation.Y, localRotation.Z, localScale.X, localScale.Y, localScale.Z);
}
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxSetFramePaths(IntPtr context, [MarshalAs(UnmanagedType.LPArray)] IntPtr[] strFramePaths, int count);
[LibraryImport(FbxDll.DllName, StringMarshalling = StringMarshalling.Utf8)]
private static partial nint AsFbxExportSingleFrame(nint context, nint parentNode, string strFramePath, string strFrameName, float localPositionX, float localPositionY, float localPositionZ, float localRotationX, float localRotationY, float localRotationZ, float localScaleX, float localScaleY, float localScaleZ);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxExportScene(IntPtr context);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxSetJointsNode_CastToBone(nint context, nint node, float boneSize);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr AsFbxGetSceneRootNode(IntPtr context);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxSetJointsNode_BoneInPath(nint context, nint node, float boneSize);
private static IntPtr AsFbxExportSingleFrame(IntPtr context, IntPtr parentNode, string framePath, string frameName, in Vector3 localPosition, in Vector3 localRotation, in Vector3 localScale)
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxSetJointsNode_Generic(nint context, nint node);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxPrepareMaterials(nint context, int materialCount, int textureCount);
[LibraryImport(FbxDll.DllName, StringMarshalling = StringMarshalling.Utf8)]
private static partial nint AsFbxCreateTexture(nint context, string matTexName);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxLinkTexture(int dest, nint texture, nint material, float offsetX, float offsetY, float scaleX, float scaleY);
[LibraryImport(FbxDll.DllName)]
private static partial nint AsFbxMeshCreateClusterArray(int boneCount);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxMeshDisposeClusterArray(ref nint ppArray);
[LibraryImport(FbxDll.DllName)]
private static partial nint AsFbxMeshCreateCluster(nint context, nint boneNode);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxMeshAddCluster(nint array, nint cluster);
[LibraryImport(FbxDll.DllName)]
private static partial nint AsFbxMeshCreateMesh(nint context, nint frameNode);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxMeshInitControlPoints(nint mesh, int vertexCount);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxMeshCreateElementNormal(nint mesh);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxMeshCreateDiffuseUV(nint mesh, int uv);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxMeshCreateNormalMapUV(nint mesh, int uv);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxMeshCreateElementTangent(nint mesh);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxMeshCreateElementVertexColor(nint mesh);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxMeshCreateElementMaterial(nint mesh);
private static nint AsFbxCreateMaterial(nint pContext, string matName, in Color diffuse, in Color ambient, in Color emissive, in Color specular, in Color reflection, float shininess, float transparency)
{
using (var framePathUtf8 = new Utf8StringHandle(framePath))
{
using (var frameNameUtf8 = new Utf8StringHandle(frameName))
{
return AsFbxExportSingleFrame(context, parentNode, framePathUtf8.DangerousGetHandle(), frameNameUtf8.DangerousGetHandle(), localPosition.X, localPosition.Y, localPosition.Z, localRotation.X, localRotation.Y, localRotation.Z, localScale.X, localScale.Y, localScale.Z);
}
}
return AsFbxCreateMaterial(pContext, matName, diffuse.R, diffuse.G, diffuse.B, ambient.R, ambient.G, ambient.B, emissive.R, emissive.G, emissive.B, specular.R, specular.G, specular.B, reflection.R, reflection.G, reflection.B, shininess, transparency);
}
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr AsFbxExportSingleFrame(IntPtr context, IntPtr parentNode, IntPtr strFramePath, IntPtr strFrameName, float localPositionX, float localPositionY, float localPositionZ, float localRotationX, float localRotationY, float localRotationZ, float localScaleX, float localScaleY, float localScaleZ);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxSetJointsNode_CastToBone(IntPtr context, IntPtr node, float boneSize);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxSetJointsNode_BoneInPath(IntPtr context, IntPtr node, float boneSize);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxSetJointsNode_Generic(IntPtr context, IntPtr node);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxPrepareMaterials(IntPtr context, int materialCount, int textureCount);
private static IntPtr AsFbxCreateTexture(IntPtr context, string matTexName)
{
using (var matTexNameUtf8 = new Utf8StringHandle(matTexName))
{
return AsFbxCreateTexture(context, matTexNameUtf8.DangerousGetHandle());
}
}
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr AsFbxCreateTexture(IntPtr context, IntPtr strMatTexName);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxLinkTexture(int dest, IntPtr texture, IntPtr material, float offsetX, float offsetY, float scaleX, float scaleY);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr AsFbxMeshCreateClusterArray(int boneCount);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxMeshDisposeClusterArray(ref IntPtr ppArray);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr AsFbxMeshCreateCluster(IntPtr context, IntPtr boneNode);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxMeshAddCluster(IntPtr array, IntPtr cluster);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr AsFbxMeshCreateMesh(IntPtr context, IntPtr frameNode);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxMeshInitControlPoints(IntPtr mesh, int vertexCount);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxMeshCreateElementNormal(IntPtr mesh);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxMeshCreateDiffuseUV(IntPtr mesh, int uv);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxMeshCreateNormalMapUV(IntPtr mesh, int uv);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxMeshCreateElementTangent(IntPtr mesh);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxMeshCreateElementVertexColor(IntPtr mesh);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxMeshCreateElementMaterial(IntPtr mesh);
private static IntPtr AsFbxCreateMaterial(IntPtr pContext, string matName, in Color diffuse, in Color ambient, in Color emissive, in Color specular, in Color reflection, float shininess, float transparency)
{
using (var matNameUtf8 = new Utf8StringHandle(matName))
{
return AsFbxCreateMaterial(pContext, matNameUtf8.DangerousGetHandle(), diffuse.R, diffuse.G, diffuse.B, ambient.R, ambient.G, ambient.B, emissive.R, emissive.G, emissive.B, specular.R, specular.G, specular.B, reflection.R, reflection.G, reflection.B, shininess, transparency);
}
}
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr AsFbxCreateMaterial(IntPtr pContext, IntPtr pMatName,
[LibraryImport(FbxDll.DllName, StringMarshalling = StringMarshalling.Utf8)]
private static partial nint AsFbxCreateMaterial(nint pContext, string pMatName,
float diffuseR, float diffuseG, float diffuseB,
float ambientR, float ambientG, float ambientB,
float emissiveR, float emissiveG, float emissiveB,
@@ -173,153 +102,121 @@ namespace AssetStudio.FbxInterop
float reflectR, float reflectG, float reflectB,
float shininess, float transparency);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern int AsFbxAddMaterialToFrame(IntPtr frameNode, IntPtr material);
[LibraryImport(FbxDll.DllName)]
private static partial int AsFbxAddMaterialToFrame(nint frameNode, nint material);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxSetFrameShadingModeToTextureShading(IntPtr frameNode);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxSetFrameShadingModeToTextureShading(nint frameNode);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxMeshSetControlPoint(IntPtr mesh, int index, float x, float y, float z);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxMeshSetControlPoint(nint mesh, int index, float x, float y, float z);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxMeshAddPolygon(IntPtr mesh, int materialIndex, int index0, int index1, int index2);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxMeshAddPolygon(nint mesh, int materialIndex, int index0, int index1, int index2);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxMeshElementNormalAdd(IntPtr mesh, int elementIndex, float x, float y, float z);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxMeshElementNormalAdd(nint mesh, int elementIndex, float x, float y, float z);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxMeshElementUVAdd(IntPtr mesh, int elementIndex, float u, float v);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxMeshElementUVAdd(nint mesh, int elementIndex, float u, float v);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxMeshElementTangentAdd(IntPtr mesh, int elementIndex, float x, float y, float z, float w);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxMeshElementTangentAdd(nint mesh, int elementIndex, float x, float y, float z, float w);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxMeshElementVertexColorAdd(IntPtr mesh, int elementIndex, float r, float g, float b, float a);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxMeshElementVertexColorAdd(nint mesh, int elementIndex, float r, float g, float b, float a);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxMeshSetBoneWeight(IntPtr pClusterArray, int boneIndex, int vertexIndex, float weight);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxMeshSetBoneWeight(nint pClusterArray, int boneIndex, int vertexIndex, float weight);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr AsFbxMeshCreateSkinContext(IntPtr context, IntPtr frameNode);
[LibraryImport(FbxDll.DllName)]
private static partial nint AsFbxMeshCreateSkinContext(nint context, nint frameNode);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxMeshDisposeSkinContext(ref IntPtr ppSkinContext);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxMeshDisposeSkinContext(ref nint ppSkinContext);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
[LibraryImport(FbxDll.DllName)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool FbxClusterArray_HasItemAt(IntPtr pClusterArray, int index);
private static partial bool FbxClusterArray_HasItemAt(nint pClusterArray, int index);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private unsafe static extern void AsFbxMeshSkinAddCluster(IntPtr pSkinContext, IntPtr pClusterArray, int index, float* pBoneMatrix);
[LibraryImport(FbxDll.DllName)]
private static unsafe partial void AsFbxMeshSkinAddCluster(nint pSkinContext, nint pClusterArray, int index, float* pBoneMatrix);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxMeshAddDeformer(IntPtr pSkinContext, IntPtr pMesh);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxMeshAddDeformer(nint pSkinContext, nint pMesh);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr AsFbxAnimCreateContext([MarshalAs(UnmanagedType.Bool)] bool eulerFilter);
[LibraryImport(FbxDll.DllName)]
private static partial nint AsFbxAnimCreateContext([MarshalAs(UnmanagedType.Bool)] bool eulerFilter);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxAnimDisposeContext(ref IntPtr ppAnimContext);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxAnimDisposeContext(ref nint ppAnimContext);
private static void AsFbxAnimPrepareStackAndLayer(IntPtr pContext, IntPtr pAnimContext, string takeName)
{
using (var takeNameUtf8 = new Utf8StringHandle(takeName))
{
AsFbxAnimPrepareStackAndLayer(pContext, pAnimContext, takeNameUtf8.DangerousGetHandle());
}
}
[LibraryImport(FbxDll.DllName, StringMarshalling = StringMarshalling.Utf8)]
private static partial void AsFbxAnimPrepareStackAndLayer(nint pContext, nint pAnimContext, string takeName);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxAnimPrepareStackAndLayer(IntPtr pContext, IntPtr pAnimContext, IntPtr strTakeName);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxAnimLoadCurves(nint pNode, nint pAnimContext);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxAnimLoadCurves(IntPtr pNode, IntPtr pAnimContext);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxAnimBeginKeyModify(nint pAnimContext);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxAnimBeginKeyModify(IntPtr pAnimContext);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxAnimEndKeyModify(nint pAnimContext);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxAnimEndKeyModify(IntPtr pAnimContext);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxAnimAddScalingKey(nint pAnimContext, float time, float x, float y, float z);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxAnimAddScalingKey(IntPtr pAnimContext, float time, float x, float y, float z);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxAnimAddRotationKey(nint pAnimContext, float time, float x, float y, float z);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxAnimAddRotationKey(IntPtr pAnimContext, float time, float x, float y, float z);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxAnimAddTranslationKey(nint pAnimContext, float time, float x, float y, float z);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxAnimAddTranslationKey(IntPtr pAnimContext, float time, float x, float y, float z);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxAnimApplyEulerFilter(nint pAnimContext, float filterPrecision);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxAnimApplyEulerFilter(IntPtr pAnimContext, float filterPrecision);
[LibraryImport(FbxDll.DllName)]
private static partial int AsFbxAnimGetCurrentBlendShapeChannelCount(nint pAnimContext, nint pNode);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern int AsFbxAnimGetCurrentBlendShapeChannelCount(IntPtr pAnimContext, IntPtr pNode);
private static bool AsFbxAnimIsBlendShapeChannelMatch(IntPtr pAnimContext, int channelIndex, string channelName)
{
using (var channelNameUtf8 = new Utf8StringHandle(channelName))
{
return AsFbxAnimIsBlendShapeChannelMatch(pAnimContext, channelIndex, channelNameUtf8.DangerousGetHandle());
}
}
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
[LibraryImport(FbxDll.DllName, StringMarshalling = StringMarshalling.Utf8)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool AsFbxAnimIsBlendShapeChannelMatch(IntPtr pAnimContext, int channelIndex, IntPtr strChannelName);
private static partial bool AsFbxAnimIsBlendShapeChannelMatch(nint pAnimContext, int channelIndex, string channelName);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxAnimBeginBlendShapeAnimCurve(IntPtr pAnimContext, int channelIndex);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxAnimBeginBlendShapeAnimCurve(nint pAnimContext, int channelIndex);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxAnimEndBlendShapeAnimCurve(IntPtr pAnimContext);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxAnimEndBlendShapeAnimCurve(nint pAnimContext);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxAnimAddBlendShapeKeyframe(IntPtr pAnimContext, float time, float value);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxAnimAddBlendShapeKeyframe(nint pAnimContext, float time, float value);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr AsFbxMorphCreateContext();
[LibraryImport(FbxDll.DllName)]
private static partial nint AsFbxMorphCreateContext();
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxMorphInitializeContext(IntPtr pContext, IntPtr pMorphContext, IntPtr pNode);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxMorphInitializeContext(nint pContext, nint pMorphContext, nint pNode);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxMorphDisposeContext(ref IntPtr ppMorphContext);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxMorphDisposeContext(ref nint ppMorphContext);
private static void AsFbxMorphAddBlendShapeChannel(IntPtr pContext, IntPtr pMorphContext, string channelName)
{
using (var channelNameUtf8 = new Utf8StringHandle(channelName))
{
AsFbxMorphAddBlendShapeChannel(pContext, pMorphContext, channelNameUtf8.DangerousGetHandle());
}
}
[LibraryImport(FbxDll.DllName, StringMarshalling = StringMarshalling.Utf8)]
private static partial void AsFbxMorphAddBlendShapeChannel(nint pContext, nint pMorphContext, string channelName);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxMorphAddBlendShapeChannel(IntPtr pContext, IntPtr pMorphContext, IntPtr strChannelName);
[LibraryImport(FbxDll.DllName, StringMarshalling = StringMarshalling.Utf8)]
private static partial void AsFbxMorphAddBlendShapeChannelShape(nint pContext, nint pMorphContext, float weight, string shapeName);
private static void AsFbxMorphAddBlendShapeChannelShape(IntPtr pContext, IntPtr pMorphContext, float weight, string shapeName)
{
using (var shapeNameUtf8 = new Utf8StringHandle(shapeName))
{
AsFbxMorphAddBlendShapeChannelShape(pContext, pMorphContext, weight, shapeNameUtf8.DangerousGetHandle());
}
}
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxMorphCopyBlendShapeControlPoints(nint pMorphContext);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxMorphAddBlendShapeChannelShape(IntPtr pContext, IntPtr pMorphContext, float weight, IntPtr strShapeName);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxMorphSetBlendShapeVertex(nint pMorphContext, uint index, float x, float y, float z);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxMorphCopyBlendShapeControlPoints(IntPtr pMorphContext);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxMorphCopyBlendShapeControlPointsNormal(nint pMorphContext);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxMorphSetBlendShapeVertex(IntPtr pMorphContext, uint index, float x, float y, float z);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxMorphCopyBlendShapeControlPointsNormal(IntPtr pMorphContext);
[DllImport(FbxDll.DllName, CallingConvention = CallingConvention.Cdecl)]
private static extern void AsFbxMorphSetBlendShapeVertexNormal(IntPtr pMorphContext, uint index, float x, float y, float z);
[LibraryImport(FbxDll.DllName)]
private static partial void AsFbxMorphSetBlendShapeVertexNormal(nint pMorphContext, uint index, float x, float y, float z);
}
}

View File

@@ -9,17 +9,17 @@ namespace AssetStudio.FbxInterop
internal sealed partial class FbxExporterContext : IDisposable
{
private IntPtr _pContext;
private readonly Dictionary<ImportedFrame, IntPtr> _frameToNode;
private readonly List<KeyValuePair<string, IntPtr>> _createdMaterials;
private readonly Dictionary<string, IntPtr> _createdTextures;
private nint _pContext;
private readonly Dictionary<ImportedFrame, nint> _frameToNode;
private readonly List<KeyValuePair<string, nint>> _createdMaterials;
private readonly Dictionary<string, nint> _createdTextures;
public FbxExporterContext()
{
_pContext = AsFbxCreateContext();
_frameToNode = new Dictionary<ImportedFrame, IntPtr>();
_createdMaterials = new List<KeyValuePair<string, IntPtr>>();
_createdTextures = new Dictionary<string, IntPtr>();
_frameToNode = new Dictionary<ImportedFrame, nint>();
_createdMaterials = new List<KeyValuePair<string, nint>>();
_createdTextures = new Dictionary<string, nint>();
}
~FbxExporterContext()
@@ -98,9 +98,9 @@ namespace AssetStudio.FbxInterop
{
var rootNode = AsFbxGetSceneRootNode(_pContext);
Debug.Assert(rootNode != IntPtr.Zero);
Debug.Assert(rootNode != nint.Zero);
var nodeStack = new Stack<IntPtr>();
var nodeStack = new Stack<nint>();
var frameStack = new Stack<ImportedFrame>();
nodeStack.Push(rootNode);
@@ -140,7 +140,7 @@ namespace AssetStudio.FbxInterop
if (_frameToNode.TryGetValue(frame, out var node))
{
Debug.Assert(node != IntPtr.Zero);
Debug.Assert(node != nint.Zero);
if (castToBone)
{
@@ -181,11 +181,11 @@ namespace AssetStudio.FbxInterop
ExportMesh(rootFrame, materialList, textureList, meshNode, mesh, exportSkins, exportAllUvsAsDiffuseMaps);
}
private IntPtr ExportTexture(ImportedTexture texture)
private nint ExportTexture(ImportedTexture texture)
{
if (texture == null)
{
return IntPtr.Zero;
return nint.Zero;
}
if (_createdTextures.ContainsKey(texture.Name))
@@ -207,7 +207,7 @@ namespace AssetStudio.FbxInterop
return pTex;
}
private void ExportMesh(ImportedFrame rootFrame, List<ImportedMaterial> materialList, List<ImportedTexture> textureList, IntPtr frameNode, ImportedMesh importedMesh, bool exportSkins, bool exportAllUvsAsDiffuseMaps)
private void ExportMesh(ImportedFrame rootFrame, List<ImportedMaterial> materialList, List<ImportedTexture> textureList, nint frameNode, ImportedMesh importedMesh, bool exportSkins, bool exportAllUvsAsDiffuseMaps)
{
var boneList = importedMesh.BoneList;
var totalBoneCount = 0;
@@ -218,7 +218,7 @@ namespace AssetStudio.FbxInterop
hasBones = true;
}
var pClusterArray = IntPtr.Zero;
var pClusterArray = nint.Zero;
try
{
@@ -239,7 +239,7 @@ namespace AssetStudio.FbxInterop
}
else
{
AsFbxMeshAddCluster(pClusterArray, IntPtr.Zero);
AsFbxMeshAddCluster(pClusterArray, nint.Zero);
}
}
}
@@ -287,7 +287,7 @@ namespace AssetStudio.FbxInterop
if (mat != null)
{
var foundMat = _createdMaterials.FindIndex(kv => kv.Key == mat.Name);
IntPtr pMat;
nint pMat;
if (foundMat >= 0)
{
@@ -303,7 +303,7 @@ namespace AssetStudio.FbxInterop
pMat = AsFbxCreateMaterial(_pContext, mat.Name, in diffuse, in ambient, in emissive, in specular, in reflection, mat.Shininess, mat.Transparency);
_createdMaterials.Add(new KeyValuePair<string, IntPtr>(mat.Name, pMat));
_createdMaterials.Add(new KeyValuePair<string, nint>(mat.Name, pMat));
}
materialIndex = AsFbxAddMaterialToFrame(frameNode, pMat);
@@ -315,7 +315,7 @@ namespace AssetStudio.FbxInterop
var tex = ImportedHelpers.FindTexture(texture.Name, textureList);
var pTexture = ExportTexture(tex);
if (pTexture != IntPtr.Zero)
if (pTexture != nint.Zero)
{
switch (texture.Dest)
{
@@ -406,7 +406,7 @@ namespace AssetStudio.FbxInterop
if (hasBones)
{
IntPtr pSkinContext = IntPtr.Zero;
nint pSkinContext = nint.Zero;
try
{
@@ -471,7 +471,7 @@ namespace AssetStudio.FbxInterop
return;
}
var pAnimContext = IntPtr.Zero;
var pAnimContext = nint.Zero;
try
{
@@ -502,7 +502,7 @@ namespace AssetStudio.FbxInterop
}
}
private void ExportKeyframedAnimation(ImportedFrame rootFrame, ImportedKeyframedAnimation parser, IntPtr pAnimContext, float filterPrecision)
private void ExportKeyframedAnimation(ImportedFrame rootFrame, ImportedKeyframedAnimation parser, nint pAnimContext, float filterPrecision)
{
foreach (var track in parser.TrackList)
{
@@ -593,7 +593,7 @@ namespace AssetStudio.FbxInterop
var pNode = _frameToNode[frame];
var pMorphContext = IntPtr.Zero;
var pMorphContext = nint.Zero;
try
{