コード例 #1
0
void VFSPlugin_LWO::read_colr(long length)
{
	//	Read the base colour of the surface and store it in the material object
	Colour4f *c = ReadColour(3);

	m_vb->SetColour(c);

	//	Read the envelope
	long vxlength;
	long envelope = ReadVariableLength(&vxlength);

	length -= (vxlength + sizeof(float)*3);

	//	Delete all temporary memory
	delete c;
}
コード例 #2
0
ファイル: xpoilflt.cpp プロジェクト: Amadiro/xara-cairo
BOOL PluginOILFilter::BuildCapabilityTree(wxString strXmlFilename, CapabilityTree* pCapTree)
{
	// First we need to load the XML into an XML DOM object

	// Set Parser flags here?
//	hRes = pDoc->setProperty(CComBSTR(_T("SelectionLanguage")), CComVariant(_T("XPath")));
//	hRes = pDoc->put_async(VARIANT_FALSE);
//	hRes = pDoc->put_preserveWhiteSpace(VARIANT_TRUE);
//	hRes = pDoc->put_validateOnParse(VARIANT_FALSE);
//	hRes = pDoc->put_resolveExternals(VARIANT_FALSE);

	BOOL bOK = TRUE;
    xmlDocPtr doc;

	// If string param contains xml (like original Windows version)
//	wxCharBuffer buf = strXML.mb_str(wxConvUTF8);
//	doc = xmlParseDoc((const xmlChar*)buf.data());	// buf will be deallocated when it goes out of scope

	// If string param gives xml filename (like new LX version)
	wxCharBuffer buf = strXmlFilename.ToAscii();
	doc = xmlParseFile(buf.data());					// buf will be deallocated when it goes out of scope
#if _DEBUG
	if (doc==NULL)
		doc = xmlParseFile("/tmp/XaraLX/capstest.xml");
#endif
	ERROR1IF(doc==NULL, FALSE, _R(IDE_XPF_BADXML));

	// The name of the root element should be XPFilterConfig

	xmlNodePtr node = xmlDocGetRootElement(doc);
	wxString strName = CXMLUtils::ConvertToWXString(node->name);
	if (strName!=_T("XPFilterConfig"))
		ERROR1(FALSE, _R(IDE_XPF_BADXML));

	xmlNodePtr pChild = node->children;
	INT32 Phase =0;

	// There are 7 phases to the parsing
	// We will loop round until we run out of child elements
	// After parsing a node the phase counter will be set to the phase just parsed
	// If an element should have already been parsed (using the phase counter)
	// then an error will be indicated

	while (pChild && bOK)
	{
		wxString strChildName = CXMLUtils::ConvertToWXString(pChild->name);
		
		if (strChildName == _T("#text") || xmlNodeIsText(pChild))
		{
			// ignore it
		}
		else if (strChildName == _T("Private"))
		{
			if (Phase > 0)
			{
				ERROR1(FALSE, _R(IDE_XPF_BADXML_PHASE0));
			}
			// Ignore the entire element
			Phase = 1;
		}
		else if (strChildName == _T("Options"))
		{
			if (Phase > 1)
			{
				ERROR1(FALSE, _R(IDE_XPF_BADXML_PHASE1));
			}
			bOK = ReadOptions(pChild, pCapTree);		// Read the options attributes
			Phase = 2;
		}
		else if (strChildName == _T("Rasterise"))
		{
			if (Phase > 2)
			{
				ERROR1(FALSE, _R(IDE_XPF_BADXML_PHASE2));
			}
			bOK = ReadRasterise(pChild, pCapTree);		// Read the dpi and alpha attributes
			Phase = 3;
		}
		else if (strChildName == _T("Spread"))
		{
			if (Phase > 3)
			{
				ERROR1(FALSE, _R(IDE_XPF_BADXML_PHASE3));
			}
			bOK = ReadSpread(pChild, pCapTree);		// Read the as attribute
			Phase = 4;
		}
		else if (strChildName == _T("Objects"))
		{
			if (Phase > 4)
			{
				ERROR1(FALSE, _R(IDE_XPF_BADXML_PHASE4));
			}
			bOK = ReadObjects(pChild, pCapTree);		// Build the tree of XPFCapability derived objects
			Phase = 5;
		}
		else if (strChildName == _T("Attributes"))
		{
			if (Phase > 5)
			{
				ERROR1(FALSE, _R(IDE_XPF_BADXML_PHASE5));
			}
			bOK = ReadAttributes(pChild, pCapTree);	// Build the tree of XPFCapability derived objects
			Phase = 6;
		}
		else if (strChildName == _T("Colour"))
		{
			if (Phase > 6)
			{
				ERROR1(FALSE, _R(IDE_XPF_BADXML_PHASE6));
			}
			bOK = ReadColour(pChild, pCapTree);		// Build the tree of XPFColour objects
			Phase = 7;
		}
		else
		{
			ERROR1(FALSE, _R(IDE_XPF_BADXML_UNEXPECTED_PHASE));
		}

		pChild = pChild->next;
	}

	xmlFreeDoc(doc);

	return bOK;
}