|
|
|
@ -132,6 +132,8 @@ bool CNelExport::exportMesh (const char *sPath, INode& node, TimeValue time)
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
nlwarning("Failed to create file %s", tempFileName);
|
|
|
|
|
if (_TerminateOnFileOpenIssues)
|
|
|
|
|
nelExportTerminateProcess();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Delete the pointer
|
|
|
|
@ -172,6 +174,8 @@ bool CNelExport::exportMesh (const char *sPath, INode& node, TimeValue time)
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
nlwarning("Failed to open file: %s", tempFileName);
|
|
|
|
|
if (_TerminateOnFileOpenIssues)
|
|
|
|
|
nelExportTerminateProcess();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (...)
|
|
|
|
@ -246,6 +250,17 @@ bool CNelExport::exportAnim (const char *sPath, std::vector<INode*>& vectNode, T
|
|
|
|
|
{
|
|
|
|
|
// Result to return
|
|
|
|
|
bool bRet=false;
|
|
|
|
|
char tempFileName[MAX_PATH] = { 0 };
|
|
|
|
|
char tempPathBuffer[MAX_PATH] = { 0 };
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
DWORD dwRetVal = GetTempPathA(MAX_PATH, tempPathBuffer);
|
|
|
|
|
if (dwRetVal > MAX_PATH || (dwRetVal == 0))
|
|
|
|
|
nlerror("GetTempPath failed");
|
|
|
|
|
UINT uRetVal = GetTempFileNameA(tempPathBuffer, TEXT("_nel_export_mesh_"), 0, tempFileName);
|
|
|
|
|
if (uRetVal == 0)
|
|
|
|
|
nlerror("GetTempFileName failed");
|
|
|
|
|
|
|
|
|
|
// Create an animation file
|
|
|
|
|
CAnimation animFile;
|
|
|
|
@ -282,15 +297,48 @@ bool CNelExport::exportAnim (const char *sPath, std::vector<INode*>& vectNode, T
|
|
|
|
|
{
|
|
|
|
|
// Open a file
|
|
|
|
|
COFile file;
|
|
|
|
|
if (file.open (sPath))
|
|
|
|
|
if (file.open (tempFileName))
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
nldebug("Serialize the animation");
|
|
|
|
|
// Serial the animation
|
|
|
|
|
animFile.serial (file);
|
|
|
|
|
|
|
|
|
|
// Close the file
|
|
|
|
|
file.close();
|
|
|
|
|
// All is good
|
|
|
|
|
bRet=true;
|
|
|
|
|
// Verify the file
|
|
|
|
|
nldebug("Verify exported anim file");
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
bool tempBRet = bRet;
|
|
|
|
|
bRet = false;
|
|
|
|
|
CIFile vf;
|
|
|
|
|
if (vf.open(tempFileName))
|
|
|
|
|
{
|
|
|
|
|
nldebug("File opened, size: %u", vf.getFileSize());
|
|
|
|
|
CAnimation a;
|
|
|
|
|
a.serial(vf);
|
|
|
|
|
nldebug("Anim serialized");
|
|
|
|
|
vf.close();
|
|
|
|
|
nldebug("File closed");
|
|
|
|
|
bRet = tempBRet;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
nlwarning("Failed to open file: %s", tempFileName);
|
|
|
|
|
bRet = false;
|
|
|
|
|
if (_TerminateOnFileOpenIssues)
|
|
|
|
|
nelExportTerminateProcess();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (...)
|
|
|
|
|
{
|
|
|
|
|
nlwarning("Failed to verify shape. Must crash now.");
|
|
|
|
|
remove(tempFileName);
|
|
|
|
|
bRet = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception& e)
|
|
|
|
|
{
|
|
|
|
@ -305,8 +353,30 @@ bool CNelExport::exportAnim (const char *sPath, std::vector<INode*>& vectNode, T
|
|
|
|
|
if (_ErrorInDialog)
|
|
|
|
|
MessageBox (NULL, "Can't open the file for writing.", "NeL export", MB_OK|MB_ICONEXCLAMATION);
|
|
|
|
|
else
|
|
|
|
|
nlwarning ("ERROR : Can't open the file (%s) for writing", sPath);
|
|
|
|
|
nlwarning ("ERROR : Can't open the file (%s) for writing", tempFileName);
|
|
|
|
|
if (_TerminateOnFileOpenIssues)
|
|
|
|
|
nelExportTerminateProcess();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (...)
|
|
|
|
|
{
|
|
|
|
|
nlwarning("Fatal exception at CNelExport::exportAnim.");
|
|
|
|
|
bRet = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (bRet)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
remove(sPath);
|
|
|
|
|
}
|
|
|
|
|
catch (...)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
CFile::moveFile(sPath, tempFileName);
|
|
|
|
|
nlinfo("MOVE %s -> %s", tempFileName, sPath);
|
|
|
|
|
}
|
|
|
|
|
return bRet;
|
|
|
|
|
}
|
|
|
|
|