int maxPluginTest::DoExport(const TCHAR *name,ExpInterface *ei,Interface *i, BOOL suppressPrompts, DWORD options)
{
//TODO: Implement the actual file Export here and
// return TRUE If the file is exported properly
/*
if(!suppressPrompts)
DialogBoxParam(hInstance,
MAKEINTRESOURCE(IDD_PANEL),
GetActiveWindow(),
maxPluginTestOptionsDlgProc, (LPARAM)this);
*/
if (BeginWriting(name))
{
// Interface* can also be accessed by GetCOREInterface()
INode* pRootNode = i->GetRootNode();
//Export tree.
Export(pRootNode);
EndWriting();
return TRUE; // We have successfully exported to our file!
}
// If we are here, something in the export failed.
return FALSE;
}
void maxPluginTest::Export(INode* pNode, int iTreeDepth /* = 0 */)
{
// First step to export: What are we exporting?
// Here we are going to export the basic scene tree,
// identifying each node by name.
MCHAR* pNodeName = pNode->GetName();
int nChildren = pNode->NumberOfChildren();
// Write out this node as [NodeName] : XX Children
Write(iTreeDepth, "[%s] : %i children", pNodeName, nChildren);
// Recursively call the children
iTreeDepth++;
for (int i = 0; i < nChildren; i++)
{
Export(pNode->GetChildNode(i), iTreeDepth);
}
}
bool maxPluginTest::BeginWriting(const char *pPath)
{
// Check we are not currently writing
DbgAssert(m_pFile == NULL);
errno_t lErr = fopen_s(&m_pFile, pPath, "w");
return ( lErr == 0 );
}
void maxPluginTest::EndWriting()
{
DbgAssert(m_pFile != NULL);
fclose(m_pFile);
m_pFile = NULL;
}
void maxPluginTest::Write(int indent, const char* pMsg, ...)
{
DbgAssert(m_pFile != NULL);
// first, write in the indent
for (int i = 0; i < indent; i++) fprintf_s(m_pFile, "\t");
// Write the message, passing in our variable
// parameters to a function that wraps printf
va_list vargs;
va_start(vargs, pMsg);
vfprintf_s(m_pFile, pMsg, vargs);
va_end(vargs);
// Finish the line
fprintf_s(m_pFile, "\n");
}