Example #1
0
static void SaveColorFile(HWND hWnd,TSTR &name)
   {
    MaxSDK::Util::TextFile::Writer file;	

   	Interface14 *iface = GetCOREInterface14();
	UINT codepage  = iface-> DefaultTextSaveCodePage(true); //dll\PaintLayerMod\ColorPaletteTool.cpp :: SaveColorFile, UTF8 allowed, keep to same.

   if(!file.Open(fname, false, MaxSDK::Util::TextFile::Writer::WRITE_BOM | codepage )){
      TSTR buf2 = GetString(IDS_RB_COLORCLIPBOARD);
      TSTR buf1;
      buf1.printf(GetString(IDS_RB_CANTOPENFILE),fname);       
      MessageBox(hWnd,buf1,buf2,MB_ICONEXCLAMATION);
      return;
      }

   for (int i=0; i<12; i++) {
      int r, g, b;
      IColorSwatch *cs = GetIColorSwatch(GetDlgItem(hWnd,csIDs[i]));
      COLORREF col = cs->GetColor();
      ReleaseIColorSwatch(cs);
      r = GetRValue(col); g = GetGValue(col); b = GetBValue(col);
      file.Printf(_T("%d %d %d\n"), r, g, b);
      }  

   for (int i=0; i<12; i++) {
      IColorSwatch *cs = GetIColorSwatch(GetDlgItem(hWnd,csIDs[i]));
      AColor col = cs->GetAColor();
      ReleaseIColorSwatch(cs);
      file.Printf(_T("%f %f %f %f\n"), col.r, col.g, col.b, col.a);
   }  

   SetupTitle(hWnd,name);
   file.Close();
   }
Example #2
0
int FaceDataExport::DoExport(const TCHAR *name,ExpInterface *ei,Interface *i, BOOL suppressPrompts, DWORD options) {
	exportSelected = (options & SCENE_EXPORT_SELECTED) ? true : false;
	Interface14 *iface = GetCOREInterface14();
	UINT codepage  = iface-> DefaultTextSaveCodePage(true);
	if(!fileStream.Open(name, false, MaxSDK::Util::TextFile::Writer::WRITE_BOM | codepage )) return 0;
	fileStream.Printf(_T("FaceFloats Export 1.1\n\n"));
	int numChildren = i->GetRootNode()->NumberOfChildren();
	for (int idx=0; idx<numChildren; idx++) {
		nodeEnum(i->GetRootNode()->GetChildNode(idx), i);
	}
	fileStream.Close();

	return TRUE;
}
Example #3
0
BOOL FaceDataExport::nodeEnum(INode* node,Interface *ip) {	
	if(!exportSelected || node->Selected()) {
		ObjectState os = node->EvalWorldState(ip->GetTime());

		IFaceDataMgr *pFDMgr = NULL;
		if (os.obj->IsSubClassOf(triObjectClassID)) {
			TriObject *tobj = (TriObject *)os.obj;
			Mesh* mesh = &tobj->GetMesh();
			pFDMgr = static_cast<IFaceDataMgr*>(mesh->GetInterface( FACEDATAMGR_INTERFACE ));
		} else if (os.obj->IsSubClassOf (polyObjectClassID)) {
			PolyObject *pobj = (PolyObject *)os.obj;
			MNMesh *mesh = &pobj->GetMesh();
			pFDMgr = static_cast<IFaceDataMgr*>(mesh->GetInterface( FACEDATAMGR_INTERFACE ));
		}
		if (pFDMgr == NULL) return FALSE;

		SampleFaceData* SampleDataChan = NULL; 
		IFaceDataChannel* fdc = pFDMgr->GetFaceDataChan( FACE_MAXSAMPLEUSE_CLSID );
		if ( fdc != NULL ) SampleDataChan = dynamic_cast<SampleFaceData*>(fdc);
		if ( SampleDataChan == NULL) {
			fileStream.Printf(_T("Node %s does not have our Face Data\n"),node->GetName());
			return false;
		}

		//OK so We have Face data lets dump it out..
		fileStream.Printf(_T("\nNode %s has %d faces with FaceFloats\n"),node->GetName(), SampleDataChan->Count());
		for(ULONG i=0;i<SampleDataChan->Count();i++) {
			float data = SampleDataChan->data[i];
			fileStream.Printf(_T("Face %d, float %f\n"),i,data);
		}
	}

	// Recurse through this node's children, if any
	for (int c = 0; c < node->NumberOfChildren(); c++) {
		if (!nodeEnum(node->GetChildNode(c), ip)) return FALSE;
	}

	return TRUE;
}
Example #4
0
void PrettyPrint(const TCHAR* name, CComPtr<IXMLDOMDocument> pXMLDoc)
{
	// perform formatting XSLT transform to get indented XML output
	CComPtr<IXMLDOMDocument> pXSLDoc;
	BSTR outputXML = NULL;
	HRESULT hr = CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER,  IID_IXMLDOMDocument, (void**)&pXSLDoc);
	if (SUCCEEDED(hr)) {
		// load indenting XSL doc 
		VARIANT_BOOL result;
		CComBSTR indentXSL(
			"<xsl:stylesheet version=\"1.0\""
			"      xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">"
			"   <xsl:output method=\"xml\"/>"
			"   <xsl:param name=\"indent-increment\" select=\"'\t'\" />"
			"   <xsl:template match=\"node()\">"
			"      <xsl:param name=\"indent\" select=\"'&#xA;'\"/>"
			"      <xsl:value-of select=\"$indent\"/>"
			"      <xsl:copy>"
			"        <xsl:copy-of select=\"@*\" />"
			"        <xsl:apply-templates>"
			"          <xsl:with-param name=\"indent\""
			"               select=\"concat($indent, $indent-increment)\"/>"
			"        </xsl:apply-templates>"
			"        <xsl:if test=\"node()\">"
			"          <xsl:value-of select=\"$indent\"/>"
			"        </xsl:if>"
			"      </xsl:copy>"
			"   </xsl:template>"
//			"   <xsl:template match=\"comment()|processing-instruction()\">"
//			"      <xsl:copy />"
//			"   </xsl:template>"
//			"   <!-- WARNING: this is dangerous. Handle with care -->"
//			"   <xsl:template match=\"text()[normalize-space(.)='']\"/>"
			"</xsl:stylesheet>"
			);
		hr = pXSLDoc->loadXML(indentXSL, &result);
		if (SUCCEEDED(hr)) {
			// perform transform
			hr = pXMLDoc->transformNode(pXSLDoc, &outputXML);
		}
	}

	// output transformed XML if previous sequence succeeded, else normal XMLDoc save
	if (SUCCEEDED(hr)) {
		MaxSDK::Util::TextFile::Writer out;
		//Need UTF8
		if (out.Open(name, false, CP_UTF8))
		{
			// hack the UTF-16 back to UTF-8 (there probably is a way to mod the stylesheet to do this)
			wchar_t* enc = wcsstr(outputXML, L"\"UTF-16\"");
			if (enc != NULL) memcpy(enc, L"\"utf-8\" ", 8 * sizeof(wchar_t));
			// convert BSTR to MBCS for output
			// write the XML

			out.Write(outputXML);
			out.Close();
		}
		SysFreeString(outputXML);
	}
	else
	{
		// for a360 support - allows binary diff syncing
		MaxSDK::Util::Path storageNamePath(name);
		storageNamePath.SaveBaseFile();

		// save the XML graph out to the export file
		pXMLDoc->save(CComVariant(name));
	}

	
}