Pages: [1]
  Print  
Author Topic: Project Stormwind  (Read 1504 times)
Kjasi
Community Artist
Legionnaire
*
Offline Offline

Posts: 484


PWNing with Lightwave since 1997!


« on: February 19, 2010, 01:57:46 pm »

I've decided to start writing a plug-in for Lightwave that reads WoW Data. I came up with the concept for Project Stormwind almost 2 years ago, but my coding skills have only recently let me do something about it. I've started the coding process with the file-type that's the hardest to find a decent converter for; ADT files. Once completed, I will begin work on M2 and WMO files.

Project Stormwind
Progress
Project Step
% Complete
Master Loader Plugin
6.76%
Load from MPQ Files
0.00%
Read BLP Files
12.37%
Read ADT Files
34.46%
Read WMO Files
5.41%
Read M2 Files
0.00%
Lightwave Code to Learn
       41.67%
Total
14.38%

Update: 2010/04/20
More redefinition of what needs to be done, so some of the numbers have changed without much work going into them.

I managed to install an MPQ access library (the same one used in WoW Model Viewer) into the plugin, along with the support libraries. Haven't had a chance to write accessing functions, so I haven't been able to test their functionality, but they installed and compiled just fine into the .p file.

I've been spending quite a bit of time working on the Master Plugin's interface, including what it needs to have and how best to make it happen. The Lightwave SDK has been helpful, but lately work has been getting in the way of any actual updates to the plugin. Fortunately, it looks like we got a job in that will let me get Lightwave CORE, so I'll definitely port the plugin to that structure when I get it!

No new screen shots.


Screenshots:


Disclaimer: This project is aimed at two things: 1) Helping me learn how to properly program, and 2) Allow Machinima makers access to WoW's 3D files for uses within the usage rights given by Blizzard. Other uses are not authorized, and I will take no responsibility if you break the EULA by using my plugin.
« Last Edit: April 20, 2010, 06:18:39 pm by Kjasi » Logged

My Deviant Art Page - All my WoW still-image work is on this site.
My YouTube Channel - All my video stuff is here.
Project Stormwind - Complete: 14.38%
MadSquirrel
First Sergeant
*
Offline Offline

Posts: 58


WWW
« Reply #1 on: February 20, 2010, 12:58:11 am »

I had the same problem when writing my Blender import tool.
You can check the code here : http://www.wowmodelviewer.org/forum/index.php?topic=5218.msg37049#msg37049
That's python, but rather easy to understand. If you are lucky you may also find comments in there Wink
If you have questions, PM me.
Logged

Kjasi
Community Artist
Legionnaire
*
Offline Offline

Posts: 484


PWNing with Lightwave since 1997!


« Reply #2 on: February 20, 2010, 01:37:50 am »

Cool, thanks!
Logged

My Deviant Art Page - All my WoW still-image work is on this site.
My YouTube Channel - All my video stuff is here.
Project Stormwind - Complete: 14.38%
Kjasi
Community Artist
Legionnaire
*
Offline Offline

Posts: 484


PWNing with Lightwave since 1997!


« Reply #3 on: February 24, 2010, 04:48:46 am »

Okay, so I'm on my third redesign of the code, and I'm very happy with what I have so far, but I'm running into a major problem...

I'm trying to cycle through the code to gather all the data I need for the ADT files, but when I run it, it continuously cycles through the while function. Here:
Code: Select All  
while (!feof(file)){
// Read Data
fread(str,1,4,file);
fread(&size,4,1,file);
flipcc(str);
str[4] = 0;

if (size == 0)
continue;

// Set the next location
fpos_t fPos;
fgetpos(file,&fPos);
long nextPos = (long)(fPos + size);

if (strncmp(str,"MHDR",4) == 0) { // Header Information
msgf->info("Header", NULL );
Header.init(this);
}else if (strncmp(str,"MCIN",4) == 0) { // Index List
msgf->info("Index", NULL );
MCINChunk(this);
}else if (strncmp(str,"MTEX",4) == 0) { // Texture List
msgf->info("Textures", NULL );
}else if (strncmp(str,"MMDX",4) == 0) { // Model List
}else if (strncmp(str,"MWMO",4) == 0) { // WMO List
}else if (strncmp(str,"MDDF",4) == 0) { // Model Placement Info
}else if (strncmp(str,"MODF",4) == 0) { // WMO Placement Info
}else if (strncmp(str,"MH2O",4) == 0 && WaterType < 2) { // WotLK Water Chunk
WaterType = 1;
}else if (strncmp(str,"MFBO",4) == 0) { // Flying Bounding Box
}else if (strncmp(str,"MTFX",4) == 0) { // Texture Effects
}else if (strncmp(str,"MCNK",4) == 0) { // Chunk Data
}

// Go to next section
fseek(file,nextPos,SEEK_SET);
}
msgf->info("Starting Chunk Data...", NULL );
The code reads all the data, but it somehow gets stuck after all the MCNKs, and therefore never completes the while (!feof(file)), allowing access to processing the MCNK data.

I'm not quite sure what's wrong, so if anyone has an idea, let me know! I've spent about two hours on this, and it virtually matches what WoW Map Viewer has for this same section...
Logged

My Deviant Art Page - All my WoW still-image work is on this site.
My YouTube Channel - All my video stuff is here.
Project Stormwind - Complete: 14.38%
MadSquirrel
First Sergeant
*
Offline Offline

Posts: 58


WWW
« Reply #4 on: February 24, 2010, 06:09:53 am »

"size" is unsigned ?
Are you sure "fseek" toggles the feof ? (I don't remember what language it was, but I remember a case where the eof flag was set only after a read command)

Do not hesitate to log ! In that case, just before the "if ... else if" part, you can log/display str, fPos, size, nextPos, so you can see where it fails.
I remember some of the chunks can have wrong size. If you log these values, you will see it.
Logged

Joey
First Sergeant
*
Offline Offline

Posts: 16


« Reply #5 on: February 24, 2010, 10:09:21 am »

shouldnt there be a close like

fclose( file );

at the end?
Logged

what should i say?
Kjasi
Community Artist
Legionnaire
*
Offline Offline

Posts: 484


PWNing with Lightwave since 1997!


« Reply #6 on: February 24, 2010, 03:26:45 pm »

"size" is unsigned ?
Are you sure "fseek" toggles the feof ? (I don't remember what language it was, but I remember a case where the eof flag was set only after a read command)

Do not hesitate to log ! In that case, just before the "if ... else if" part, you can log/display str, fPos, size, nextPos, so you can see where it fails.
I remember some of the chunks can have wrong size. If you log these values, you will see it.
size is size_t, but just to be safe, I made it uint32.

You were right. I checked fseek AND fsetpos and BOTH of them clear the EofF flag when called. So I set the while up with a boolean and added a line at the end of the while statement to check for the end of the file and then set the boolean to true. This part works fine now.

And I would log, but I don't know how to set it up to do that, and I don't know if it would work with a Lightwave Plugin... That's why I have the msgf->info("Header", NULL ); lines in there. They're kind of a logging system, but with pop-ups. It's really helped me figure out a lot of problems.

shouldnt there be a close like fclose( file ); at the end?
There is, but this function isn't the end of the file data read. Otherwise, I'd be opening and close the same file multiple times to get all the data.
Logged

My Deviant Art Page - All my WoW still-image work is on this site.
My YouTube Channel - All my video stuff is here.
Project Stormwind - Complete: 14.38%
Kjasi
Community Artist
Legionnaire
*
Offline Offline

Posts: 484


PWNing with Lightwave since 1997!


« Reply #7 on: February 27, 2010, 07:46:14 pm »

First off, logging with lightwave plugins work. I wrote a simple logging class (based on one I found online) and it's working. It helped me find a MAJOR problem.

One of the issues I've been facing has been the height field hasn't been reading correctly... Not sure what was causing it, so I ran through everything so many times, did searches on the internet, until I finally realized the problem...

I had fp = fopen(local->filename, "r" ); when I NEEDED to have fp = fopen(local->filename, "rb" ); I wasn't reading the data in binary mode.

I feel stupid... ^_^'

So, now I've got the points to be correct. Now I need to build the polygons from those points.
Logged

My Deviant Art Page - All my WoW still-image work is on this site.
My YouTube Channel - All my video stuff is here.
Project Stormwind - Complete: 14.38%
Kjasi
Community Artist
Legionnaire
*
Offline Offline

Posts: 484


PWNing with Lightwave since 1997!


« Reply #8 on: February 28, 2010, 01:26:33 am »

Finished a lot of code, (now that I'm reading the right data) and now ADT Polygons are loaded!

Chunks still generate extra points that have to be merged, but it's only 4096 points per ADT file... Thinking of letting it slide...

Gonna assign some base surface properties, load the UV data, followed by adding the holes, THEN I start trying to figure out how to read the textures embedded in the ADT files!

Then I might play with BLP files a bit... Gonna need them soon...
Logged

My Deviant Art Page - All my WoW still-image work is on this site.
My YouTube Channel - All my video stuff is here.
Project Stormwind - Complete: 14.38%
Grongar
Sergeant
*
Offline Offline

Posts: 5


« Reply #9 on: June 22, 2010, 11:02:21 pm »

Hey Kjasi.  How are things?  I'm just wondering how this project is coming along?  I'm interested in how the development is going and whether or not you have a working importer for Lightwave yet?
I am just new to LW so any tools that are available would help out a heap.  I'm keen to get stuck in and work with the models etc.

I might be ambitious but I'm keen to import WSG.
« Last Edit: June 22, 2010, 11:06:21 pm by Grongar » Logged
Kjasi
Community Artist
Legionnaire
*
Offline Offline

Posts: 484


PWNing with Lightwave since 1997!


« Reply #10 on: June 23, 2010, 06:54:43 pm »

Haven't really had the time to work on programming lately. Lot of RL issues, but some of them are not gone, so I'm hoping to get some more work done soon.

A lot of the work is currently paused while I get MPQ support added.

But to answer your question, I have a "working" version, but it's very early alpha, so I'm not ready to release it yet. And right now, all it does is load some of the basic ADT file data. Things I want to do next: Get the ADT loader to build surfaces automatically. This requires getting the plugin to either load pre-exported image files (either TGA or BLP) or read the MPQ and auto-load/export the images. In the long run, the latter is the better choice. After that, I need to teach it not only to create a new surface, but how to properly build the final texture.

And that's just what I have to do to get the ADTs to fully load.
Logged

My Deviant Art Page - All my WoW still-image work is on this site.
My YouTube Channel - All my video stuff is here.
Project Stormwind - Complete: 14.38%
Grongar
Sergeant
*
Offline Offline

Posts: 5


« Reply #11 on: June 23, 2010, 10:06:13 pm »

Thanks for the update!!!

Based on other forums and posts that you have made, I am assuming you are still using C++ to code the plugin?
Logged
Pinkhair
Artist
Legionnaire
*
Offline Offline

Posts: 497



WWW
« Reply #12 on: June 24, 2010, 11:57:48 am »

You could create a subdivided mesh object and create a displacement and a surface node to load an adt, instead of having the plugin build the surface...  That's basically how I did my 'whole kalimdor' model.
Logged
Kjasi
Community Artist
Legionnaire
*
Offline Offline

Posts: 484


PWNing with Lightwave since 1997!


« Reply #13 on: June 24, 2010, 11:04:53 pm »

The plugin build the mesh no problem, it's the images/materials that are the issue.

And yes, I'm using C++ for coding it. Although it has to be compiled in C, since that's what Lightwave Plugins run with. So in actuality, the plugin uses both.
Logged

My Deviant Art Page - All my WoW still-image work is on this site.
My YouTube Channel - All my video stuff is here.
Project Stormwind - Complete: 14.38%
Pages: [1]
  Print  
 
Jump to: