mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-06-03 00:58:13 -04:00
Fixed coding errors
This commit is contained in:
parent
50c17c2ec4
commit
eb4981808b
@ -2,9 +2,14 @@
|
|||||||
|
|
||||||
namespace AssetStudio
|
namespace AssetStudio
|
||||||
{
|
{
|
||||||
char* Fbx::StringToCharArray(String^ s)
|
char* Fbx::StringToUTF8(String^ s)
|
||||||
{
|
{
|
||||||
return (char*)(void*)Marshal::StringToHGlobalAnsi(s);
|
auto bytes = Text::Encoding::UTF8->GetBytes(s);
|
||||||
|
auto chars = new char[bytes->Length + 1];
|
||||||
|
pin_ptr<unsigned char> ptr = &bytes[0];
|
||||||
|
memcpy(chars, ptr, bytes->Length);
|
||||||
|
chars[bytes->Length] = '\0';
|
||||||
|
return chars;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fbx::Init(FbxManager** pSdkManager, FbxScene** pScene)
|
void Fbx::Init(FbxManager** pSdkManager, FbxScene** pScene)
|
||||||
|
@ -10,19 +10,18 @@
|
|||||||
using namespace System;
|
using namespace System;
|
||||||
using namespace System::Collections::Generic;
|
using namespace System::Collections::Generic;
|
||||||
using namespace System::IO;
|
using namespace System::IO;
|
||||||
using namespace System::Runtime::InteropServices;
|
|
||||||
|
|
||||||
#define WITH_MARSHALLED_STRING(name,str,block)\
|
#define WITH_MARSHALLED_STRING(name,str,block)\
|
||||||
{ \
|
{ \
|
||||||
char* name; \
|
char* name; \
|
||||||
try \
|
try \
|
||||||
{ \
|
{ \
|
||||||
name = StringToCharArray(str); \
|
name = StringToUTF8(str); \
|
||||||
block \
|
block \
|
||||||
} \
|
} \
|
||||||
finally \
|
finally \
|
||||||
{ \
|
{ \
|
||||||
Marshal::FreeHGlobal((IntPtr)name); \
|
delete name; \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,13 +42,13 @@ namespace AssetStudio {
|
|||||||
public:
|
public:
|
||||||
static Vector3 QuaternionToEuler(Quaternion q);
|
static Vector3 QuaternionToEuler(Quaternion q);
|
||||||
static Quaternion EulerToQuaternion(Vector3 v);
|
static Quaternion EulerToQuaternion(Vector3 v);
|
||||||
static char* StringToCharArray(String^ s);
|
static char* StringToUTF8(String^ s);
|
||||||
static void Init(FbxManager** pSdkManager, FbxScene** pScene);
|
static void Init(FbxManager** pSdkManager, FbxScene** pScene);
|
||||||
|
|
||||||
ref class Exporter
|
ref class Exporter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void Export(String^ path, IImported^ imported, bool eulerFilter, float filterPrecision, bool allFrames, bool allBones, bool skins, float boneSize, float scaleFactor, bool flatInbetween, int versionIndex, bool isAscii);
|
static void Export(String^ name, IImported^ imported, bool eulerFilter, float filterPrecision, bool allFrames, bool allBones, bool skins, float boneSize, float scaleFactor, bool flatInbetween, int versionIndex, bool isAscii);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool exportSkins;
|
bool exportSkins;
|
||||||
|
@ -12,9 +12,8 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
String^ currentDir = Directory::GetCurrentDirectory();
|
String^ currentDir = Directory::GetCurrentDirectory();
|
||||||
Directory::SetCurrentDirectory(dir->FullName);
|
Directory::SetCurrentDirectory(dir->FullName);
|
||||||
path = Path::GetFileName(path);
|
auto name = Path::GetFileName(path);
|
||||||
|
Exporter^ exporter = gcnew Exporter(name, imported, allFrames, allBones, skins, boneSize, scaleFactor, versionIndex, isAscii);
|
||||||
Exporter^ exporter = gcnew Exporter(path, imported, allFrames, allBones, skins, boneSize, scaleFactor, versionIndex, isAscii);
|
|
||||||
//TODO exporter->ExportMorphs(false, flatInbetween);
|
//TODO exporter->ExportMorphs(false, flatInbetween);
|
||||||
exporter->ExportAnimations(eulerFilter, filterPrecision, flatInbetween);
|
exporter->ExportAnimations(eulerFilter, filterPrecision, flatInbetween);
|
||||||
exporter->pExporter->Export(exporter->pScene);
|
exporter->pExporter->Export(exporter->pScene);
|
||||||
@ -23,7 +22,7 @@ namespace AssetStudio
|
|||||||
Directory::SetCurrentDirectory(currentDir);
|
Directory::SetCurrentDirectory(currentDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
Fbx::Exporter::Exporter(String^ path, IImported^ imported, bool allFrames, bool allBones, bool skins, float boneSize, float scaleFactor, int versionIndex, bool isAscii)
|
Fbx::Exporter::Exporter(String^ name, IImported^ imported, bool allFrames, bool allBones, bool skins, float boneSize, float scaleFactor, int versionIndex, bool isAscii)
|
||||||
{
|
{
|
||||||
this->imported = imported;
|
this->imported = imported;
|
||||||
exportSkins = skins;
|
exportSkins = skins;
|
||||||
@ -51,7 +50,7 @@ namespace AssetStudio
|
|||||||
FbxGlobalSettings& globalSettings = pScene->GetGlobalSettings();
|
FbxGlobalSettings& globalSettings = pScene->GetGlobalSettings();
|
||||||
globalSettings.SetSystemUnit(FbxSystemUnit(scaleFactor));
|
globalSettings.SetSystemUnit(FbxSystemUnit(scaleFactor));
|
||||||
|
|
||||||
cDest = StringToCharArray(path);
|
cDest = StringToUTF8(name);
|
||||||
pExporter = FbxExporter::Create(pScene, "");
|
pExporter = FbxExporter::Create(pScene, "");
|
||||||
|
|
||||||
int pFileFormat = 0;
|
int pFileFormat = 0;
|
||||||
@ -155,7 +154,7 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
if (cDest != NULL)
|
if (cDest != NULL)
|
||||||
{
|
{
|
||||||
Marshal::FreeHGlobal((IntPtr)cDest);
|
delete cDest;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -387,7 +386,7 @@ namespace AssetStudio
|
|||||||
char* pMatName = NULL;
|
char* pMatName = NULL;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pMatName = StringToCharArray(mat->Name);
|
pMatName = StringToUTF8(mat->Name);
|
||||||
int foundMat = -1;
|
int foundMat = -1;
|
||||||
for (int j = 0; j < pMaterials->GetCount(); j++)
|
for (int j = 0; j < pMaterials->GetCount(); j++)
|
||||||
{
|
{
|
||||||
@ -467,7 +466,7 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
Marshal::FreeHGlobal((IntPtr)pMatName);
|
delete pMatName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -579,7 +578,7 @@ namespace AssetStudio
|
|||||||
char* pTexName = NULL;
|
char* pTexName = NULL;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pTexName = StringToCharArray(matTexName);
|
pTexName = StringToUTF8(matTexName);
|
||||||
int foundTex = -1;
|
int foundTex = -1;
|
||||||
for (int i = 0; i < pTextures->GetCount(); i++)
|
for (int i = 0; i < pTextures->GetCount(); i++)
|
||||||
{
|
{
|
||||||
@ -608,17 +607,7 @@ namespace AssetStudio
|
|||||||
pTex->SetRotation(0.0, 0.0);
|
pTex->SetRotation(0.0, 0.0);
|
||||||
pTextures->Add(pTex);
|
pTextures->Add(pTex);
|
||||||
|
|
||||||
String^ path = Path::GetDirectoryName(gcnew String(pExporter->GetFileName().Buffer()));
|
FileInfo^ file = gcnew FileInfo(matTex->Name);
|
||||||
if (path == String::Empty)
|
|
||||||
{
|
|
||||||
path = ".";
|
|
||||||
}
|
|
||||||
FileInfo^ file = gcnew FileInfo(path + Path::DirectorySeparatorChar + Path::GetFileName(matTex->Name));
|
|
||||||
DirectoryInfo^ dir = file->Directory;
|
|
||||||
if (!dir->Exists)
|
|
||||||
{
|
|
||||||
dir->Create();
|
|
||||||
}
|
|
||||||
BinaryWriter^ writer = gcnew BinaryWriter(file->Create());
|
BinaryWriter^ writer = gcnew BinaryWriter(file->Create());
|
||||||
writer->Write(matTex->Data);
|
writer->Write(matTex->Data);
|
||||||
writer->Close();
|
writer->Close();
|
||||||
@ -626,7 +615,7 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
Marshal::FreeHGlobal((IntPtr)pTexName);
|
delete pTexName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user