mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-07-18 03:24:15 -04:00
Prototype animation export
This commit is contained in:
51
AssetStudioFBX/AssetStudioFBX.cpp
Normal file
51
AssetStudioFBX/AssetStudioFBX.cpp
Normal file
@ -0,0 +1,51 @@
|
||||
#include <fbxsdk.h>
|
||||
#include <fbxsdk/fileio/fbxiosettings.h>
|
||||
#include "AssetStudioFBX.h"
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
char* Fbx::StringToCharArray(String^ s)
|
||||
{
|
||||
return (char*)(void*)Marshal::StringToHGlobalAnsi(s);
|
||||
}
|
||||
|
||||
void Fbx::Init(FbxManager** pSdkManager, FbxScene** pScene)
|
||||
{
|
||||
*pSdkManager = FbxManager::Create();
|
||||
if (!pSdkManager)
|
||||
{
|
||||
throw gcnew Exception(gcnew String("Unable to create the FBX SDK manager"));
|
||||
}
|
||||
|
||||
FbxIOSettings* ios = FbxIOSettings::Create(*pSdkManager, IOSROOT);
|
||||
(*pSdkManager)->SetIOSettings(ios);
|
||||
|
||||
FbxString lPath = FbxGetApplicationDirectory();
|
||||
#if defined(FBXSDK_ENV_WIN)
|
||||
FbxString lExtension = "dll";
|
||||
#elif defined(FBXSDK_ENV_MAC)
|
||||
FbxString lExtension = "dylib";
|
||||
#elif defined(FBXSDK_ENV_LINUX)
|
||||
FbxString lExtension = "so";
|
||||
#endif
|
||||
(*pSdkManager)->LoadPluginsDirectory(lPath.Buffer(), lExtension.Buffer());
|
||||
|
||||
*pScene = FbxScene::Create(*pSdkManager, "");
|
||||
}
|
||||
|
||||
Vector3 Fbx::QuaternionToEuler(Quaternion q)
|
||||
{
|
||||
FbxAMatrix lMatrixRot;
|
||||
lMatrixRot.SetQ(FbxQuaternion(q.X, q.Y, q.Z, q.W));
|
||||
FbxVector4 lEuler = lMatrixRot.GetR();
|
||||
return Vector3((float)lEuler[0], (float)lEuler[1], (float)lEuler[2]);
|
||||
}
|
||||
|
||||
Quaternion Fbx::EulerToQuaternion(Vector3 v)
|
||||
{
|
||||
FbxAMatrix lMatrixRot;
|
||||
lMatrixRot.SetR(FbxVector4(v.X, v.Y, v.Z));
|
||||
FbxQuaternion lQuaternion = lMatrixRot.GetQ();
|
||||
return Quaternion((float)lQuaternion[0], (float)lQuaternion[1], (float)lQuaternion[2], (float)lQuaternion[3]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user