Sunday, 17 February 2013

Mesh improvement - loading data from binary files

Overall, this assignment is much more easier than previous two assignments. The only challenge I faced is writing/reading binary data. I had no experience in reading or writing binary files before. However there are a lot of sources teaching to do it. This left the only thing I need to do is moving my MeshParser into my MeshBuilder then output the data as binary. Writing the output data from MayaExporter into my-mesh-data-format is not hard at all.

I tried as much as possible to left everything in my code the same as previous code. My MeshParser still hold the information of total vertices, total primitives, vertex data, and index buffer. The only thing different in this parser is instead of parsing from readable file, now it is read from binary data. For this reason, I decided to output the file from Maya in TXT and output the binary file as TXT.


I created total three new simple meshes using Maya: cone, sphere and platonic solid. I tried to put sphere into my scene however DirectX seemed to complain that the mesh array is out of range.

More entities with Maya

Everything went smoothly in C++ part the only big and headache problem I have is in Maya plug-in. For some unknown reason I couldn't import my debug-built plug-in into Maya. Maya complained: pluginWin.mel line 665: The parameter is incorrect. This was really annoying and frustrating. All the information I found on internet didn't give me a nice solution at all. Thankfully, JP helped me figured it out. He told me that: The error "The parameter is incorrect" is a Windows error that happens when you try to load a DLL, and not a Maya thing at all. In other words, Maya is just passing on the error that Windows is reporting. This means that there's something wrong with your DLL and Windows can't load it. He had also found tons of links that suggested something to do with Windows 7 Service Pack 1, but no one had any clear answers on what that could be.

My first thought was it because I built it in a driver different from where Maya was located? And... voila! The plug-in built in the same drive as Maya worked! This added more frustrate, why did the very same code couldn't run when built in different drive?? Even funnier, both drive gave different plug-in size. The contain, when I compared with WinMerge, were also different.

This is the MLL address JP checked for me. cs6963_C was the one built in C drive and cs6963_F was the one built in another drive with FAT32 format. Both gave different address. Strange, right?

Again, JP helped me pointed it out that both drive might be formatted in different format. And yes it was! C drive, where my Maya2013 x64 was located and where I built the success code was formatted in NTFS. While the other drive was formatted in FAT32!!! So my conclusion was Maya2013 x64 plug-in can only be built in NTFS formatted-drive.

Anyways, debugging this Maya plug-in was indeed annoying and frustrating. However, through this process I learnt more about Maya plug-in and DLL. Indeed we learnt more by debugging/made error than doing everything perfectly. ^___________^

To see my meshes more clearly, I changed the light control. Now my new controls are:
Camera: [W][A][S][D] + [Q]: +Z and [E]: -Z
Light: [I][J][K][L] + [U]: +Z and [O]: -Z

1 comment:

  1. I found the problem with my sphere. It is caused by my binary file reader. For some unknown reason, when my total vertices or total primitives is above 255, it will be assumed as negative number. I had solved this for the latest assignment: assignment 8 (normal and environment map)

    ReplyDelete