X File material referencing support fix

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
JoeWright
Posts: 74
Joined: Mon Dec 08, 2003 3:51 pm

X File material referencing support fix

Post by JoeWright »

Here's the code to introduce material referencing in X files (e.g. from Panda Exporter).

In CXFileReader.h somewhere within the class, e.g. after the definition of SXMeshMaterialList:

Code: Select all

	struct SXTemplateMaterial
	{
		core::stringc Name; // template name from X File
		SXMaterial Material; // material
	};
In CXFileReader.h somewhere within the private section of the class:

Code: Select all

	core::array<SXTemplateMaterial> TemplateMaterials; // material array

In CXFileReader::parseDataObject() after the AnimateSet bit:

Code: Select all

	else
	if (objectName == "Material")
	{
		TemplateMaterials.push_back(SXTemplateMaterial());
		TemplateMaterials[TemplateMaterials.size()-1].Name=getNextToken();
		return parseDataObjectMaterial(TemplateMaterials[TemplateMaterials.size()-1].Material);
	}
In CXFileReader::parseDataObjectMeshMaterialList() after the "}" but:

Code: Select all

		else
		if (objectName == "{")
		{
			objectName = getNextToken();
			for (u32 i=0; i<TemplateMaterials.size(); ++i)
				if (TemplateMaterials[i].Name == objectName)
				{
					mlist.Materials.push_back(TemplateMaterials[i].Material);
				}
			getNextToken(); // skip }
		}
Enjoy!

Joe
Koogz

Post by Koogz »

Excuse my ignorance, I am beginer and need some explanations.
Source code files (CXFileReader.h) are inside zipped folder in source directory. What do I have to do? Unzip them and change and zip them again? Update dll? I understand what files and parts of code I have to change but what to do with them to affect my project.

Thanks
Flatline
Posts: 49
Joined: Fri Sep 03, 2004 7:46 am
Location: England

Post by Flatline »

As I explained in the thread you created, you need to actually recompile the DLL in order to update the bug fixes.
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

Nice, thanks for that posting.
Electron
Posts: 874
Joined: Sun Mar 14, 2004 12:05 am
Location: Massachusetts USA

Post by Electron »

Anyone know if this is in nx++, or should I post it up there?
You do a lot of programming? Really? I try to get some in, but the debugging keeps me pretty busy.

Crucible of Stars
Post Reply