예제 #1
0
unsigned int MaterialList::addMaterial(const char* directory, const char* prefix, const char* materialName)
{
	char filename[256];
	physx::string::sprintf_s(filename, 256, "%s/%s%s", directory, prefix, materialName);

	XmlParser parser((unsigned int)mPaths.size());
	FAST_XML::FastXml* fastXml = FAST_XML::createFastXml(&parser);
	if (fastXml != NULL)
	{
		physx::PxFileBuffer fileBuffer(filename, physx::PxFileBuf::OPEN_READ_ONLY);

		fastXml->processXml(fileBuffer);

		int errorLineNumber = 0;
		const char* xmlError = fastXml->getError(errorLineNumber);
		
		if (xmlError != NULL)
		{
			if (strncmp(xmlError, "User aborted", 12) == 0)
			{

			}
			else
			{
#ifdef PX_WINDOWS
				char error[512];
				sprintf_s(error, 512, "%s\n%s", filename, xmlError);
				::MessageBox(NULL, error, "MaterialList XML Parse error", MB_OK);
#endif
			}
		}

		fastXml->release();
	}

	if (parser.isMaterial())
	{
		char saneFileName[128];
		physx::string::sprintf_s(saneFileName, 128, "%s%s", prefix, materialName);

		if (mMaterialNames.find(saneFileName) != mMaterialNames.end())
		{
			PX_ASSERT(!"Duplicated material name found");
		}
		else
		{
			mMaterialNames[saneFileName] = parser.getMaterialInfo();
			return 1;
		}
	}

	return 0;
}
예제 #2
0
	TestFastXML(physx::PxFileBuf &stream)
	{
		mDepth = 0;
		FAST_XML::FastXml *xml = FAST_XML::createFastXml(this);
		PX_ASSERT(xml);
		if ( xml )
		{
			printf("Processing XML file once\r\n");
			xml->processXml(stream,true);
			xml->release();
		}
	}