The Story of MdlVis, Warcraft III Model Editor

MdlVis is a crooked, but still pretty popular model editor for WarcraftIII. Editing meshes, texturing, working with the skeleton, arranging key frames, creating animations, importing and merging models - all this in a single file weighing 500Kb. In addition, MdlVis was the only utility capable of converting models from World of Warcraft to the format of WarcraftIII.
The story of the editor is under the cut.


Game of the new millennium

The third Warcraft reached our city at the turn of 2004-2005. More precisely, it was possible to get it earlier, but only in the form of a pirate with a crooked translation, ripped rollers and thrown out cards.
And suddenly the world turned upside down. Erys Arthas flaunted at every computer store. In Warcraft, they cut themselves in every computer club. Many even forked out to buy new computers, if the old ones did not suddenly pull the toy.
Warcraft III is generally the first computer game that seriously hooked me. And the first one that came into my hands in a licensed form. Prior to this, it was considered standard when games go on discs of 100 rubles each. apiece, they are installed once, they are buggy, and besides setup.exe, there is certainly a crack directory and a keygen.exe file on that disk.
Immediately, the buyer at a glance realized that we had a license: two boxes in stylish packaging, plus all this is covered with a film, i.e. discs are not opened and not used. Inside was a license key. The price really bit, 580 rubles., But everyone took and did not complain: the game was worth it.
Take at least the quality of the translation. It was simply mesmerizing. Until then, I did not suspect that this was possible at all: all the inscriptions, even in the screensavers, were translated, and the translation was human, not machine. All characters, all units are re-voiced. In general, then it seemed unrealistically cool. Even years later, at least something similar did not lie in stores, and even then, amid all the Fargus and Akell, normal localization caused a feeling close to euphoria.
(The second time I got the same high-quality localization only after 2007, and it was Sudeki).

Modmaking

The map editor of the toy is simply gorgeous. I especially liked the opportunity to create videos on the Warcraft engine. Then they were not made only by the lazy. Kinematic cards were transferred from hand to hand on floppy disks or downloaded from the network (by those who had this network at all. Surprisingly, even a simple home telephone didn’t reach every home then). There were simply music videos, and individual multi-stories, and even entire animated series (for example, “The Tale of the Lich Ilyich and the Conquest of Elven Mineral Waters”).
I was fascinated by the approach itself: nothing needs to be drawn frame-by-frame, as in ordinary cartoons. It is enough just to arrange the scenery and our virtual actors, and then just command them what to do: sit down, stand up, go over to that tree, swing the sword - and then they themselves, using standard animations, did all this. Then, for some reason, I was sure that in a couple of years, when this technology would develop, in general, all the cartoons would be done that way, and creating a cartoon would be no more difficult than writing a story. The future seemed so near and so attractive ...
But, starting to engage in modmaking, I ran into a problem: very often in the game there were simply no suitable models. The game editor allowed importing models created by third-party developers, but there was another problem: there was no normal tool for creating these very models.
Blizzards offered the so-called ArtTools. This is a plugin for 3DSMax 5th version. Yes, it was Max5 that was required. It did not work with either version 4 or version 6. Well, I couldn’t get this 3DSMax then. I ran around all the shops, looked at all the ruins ... No. But torrents at those speeds and networks could only dream of. It is enough to say only that I first went online only in 2004. And at that time I got into the network through a university gateway, where even downloading 5MB was a whole problem. The jump of the same ArtTools, which weighed about 30MB, took almost the whole day.
And, what is most annoying: often it was not even required a completely new model. I just wanted to tweak the existing one. Well, there, remove the elf’s cloak, or turn the lantern on the pillar upside down ...
Is there really no suitable tool for such simple, necessary actions? It turned out, no. There really was a toolbox from Oinkerwinkle, but the editor there looked like this:
VertexModify
Yes, no rotation, just the simplest projections.
And then I remembered that actually I know how to program a little.

Coding

Well, "I can" - perhaps, it is said a lot. Just superficial knowledge of Delphi and a little deeper - assembler, but under DOS. The latter was studied by Yurov's textbook read to the holes. On the other hand, I thought, I don’t need a 3DSMax clone, but an essentially simple program. That's exactly the same as VertexModify, only with the possibility of free rotation of the camera.
I formulated the basic requirements for the program:
  • It should weigh as little as possible so that it can be conveniently sent over the network
  • It should run on any machine where Warcraft III starts. Better even where War doesn't go
  • It should look exactly like VertexModify, only easier and with the ability to rotate the camera.


I chose Delphi5 as the programming language. Why exactly the fifth? Because this is where dynamic arrays first appear, and the size of the finished binaries is still relatively small (later on the forum they repeatedly asked why the empty form compiled in Delphi2005 weighs more than my entire editor).
Also, the question arose of choosing an API: OpenGL or DirectX. I think everyone has already guessed what I chose. Yes, the DX code seemed dumb and overly complicated to me. “For some reason, the COM interfaces were screwed there, Microsoft is definitely an evil empire,” I thought. But in OGL everything is clear, simple, understandable and guaranteed to work everywhere in general, while DX may still not be installed. Or installed, but the wrong version. In general, GL is the best.
How wrong I was then ...

The first difficulty was the format of the models. Warcraft models come in two forms: binary (MDX), which actually was imported into cards, and text (MDL). No data on the binary format existed at all, but the text was partially described, and it was with him that all modmaker editors worked. They transferred from one format to another model with a special tool (Yobguls converter), the author of which the device also did not know the formats, but simply used for conversion pieces of Warcraft code ripped directly from the binary. Naturally, the rip worked unstable in terms of departures, but it converted absolutely everything.
In general, I also decided to work specifically with MDL. And proudly called his program "MDL Visualizer", giving the project the name MdlVis .
The half-heartedness of the MDL documentation did not bother me at all: I was planning to work only with geometry, i.e. vertices and mesh. And there are all kinds of animations, textures, materials, cameras, particle sources, trace sources, light sources, sound effects, etc. objects did not interest me. Only sections of geometry were loaded into memory, and then they were also rewritten, and I did not touch everything else.

Start

Kodil in his free time, in the evenings, often staying up late. The initial version of the program was born exactly one month after the first line went to the code editor.
About
Window "about the program" of one of the initial versions of the editor.

Having worked a little with the resulting program, I decided to share it with other mod-makers.
In those days, Blizzard did not even think about coming to Russia, so the largest Russian-speaking community was located on the site blizzard.ru.
It was there that I laid out my editor, designating the assembly as an alpha version.
The reviews were not long in coming. At first they were very negative: as expected, the program was very buggy, it hung and had a very unintuitive interface, and I somehow did not care about the tutorials for it.
Nevertheless, MdlVis, in comparison with VertexModify, did provide a much more visual way of working with models. Therefore, although experienced mod-makers only frowned, newcomers fought selflessly with program glitches.
In the meantime, I mastered texturing in parallel with bugfixes.
The textures in Warcraft III came in BLP format, which was a pretty distorted BMP hybrid with JPEG. To decode the textures, Blizzards used the Intel codec. Accordingly, I had a choice: write the decoding procedure myself or use the ijl15.dll library, which was installed by default with Warcraft. I chose the second way: why produce glitches and increase exe size if the required module is guaranteed to be on the computer of each modmaker?
Nevertheless, taking care of those who for some reason did not have access to the game, made the ijl15.dll download dynamic. MdlVis checked for the presence of this module, and if it was not found, it still started, it simply did not allow the display of textures.
I designated the fixed version as beta.
Around the same time, I received a letter from another game resource, xgm.ru, asking me to post an editor. I agreed.
If blizzard.ru was a community site, then xgm was positioned precisely as a mod-making site: fewer ordinary players, but more mod-makers. Therefore, in the future it was he who became my main work site.
The beta version of the editor, laid out on both resources at once, befell the fate of alpha:

Beat me with sticks, but for now this is just a promising project, but certainly not better than Vertex Modify, and especially Merger animations.
Pretty obscure interface (for me). The non-working option "general view", no, it certainly works, but then the computer hangs. Impossible selection modes, I still couldn’t remove the selection.
The only thing that pleased was at least some perspective.
In general - for revision.


Of course, I ruled bugs, but not too actively, because I was struck by a new titanic idea: add an animation editor to the program! Even it took a lot of time to simply play these very animations. I had to shovel a bunch of material, figuring out what quaternions are, how they are interpolated, and what skeletal animation is. Here for the first time I regretted a little that I did not choose DX - there everything is done with a couple of clicks, because All functions for working with quaternions and matrices are in the library. I had to stuff all this math with pens. At that time, he mastered it only partially - he could not realize the interpolation by Bezier curves, which were also set by tilt angles, as did Hermite splines. As a result, models using these types of interpolation looked rather twitchy in MdlVis.
Well, at least something is better than nothing at all.
So, in May 2005. finally released the first (1.0) version of MdlVis. As usual, glitches were immediately found in it (in particular, textures in the tga format were loaded upside down for some reason), so in hot pursuit a couple of bug fixes had to be released (1.01, 1.02). After that, the editor finally became efficient and began to slowly but surely gain popularity among modmakers.
Animeditor
Animation Editor in MdlVis

The first version of MdlVis already knew how to work with the clipboard and even allowed you to copy fragments from one model to another, along with all the materials. True, not without shamanism: in order to insert a fragment from another model, it was necessary to first select one and exactly one point (the so-called insertion point), to which the inserted fragment was “attached”, copying all its movements.
So, if it was planned to insert a sword, then a point was marked on the hands. If a head or helmet was inserted, a point on the neck, etc. Agree, the actions are not quite intuitive.
Despite the fact that all this was described in great detail in the FAQ for the program, the question “how to attach the Arthas dryad’s head” soon became one of the most popular on the forum. He was asked again and again, literally pissing the moders off ...

Meanwhile, on the ruins, among other pirates, a disk with the fifth 3DSMax was mysteriously discovered. Having joyfully grabbed it, I immediately ran to install Art Tools, and very soon the full description of the MDL format literally fell into my hands. Now I loaded not only the sections with which the editor worked directly, but also the whole model. So, it is time to implement the work with the binary format, getting rid of the Yobgul's converter and turning MdlVis into a universal combine of the designer.
In general, as it turned out, the community is not only a generator of ideas, which I myself would never have thought of, but also an excellent source of information. If you need to get some docks, articles, algorithms, rare materials - just throw a cry. One had only to say that I really need MDX docks, how they magically materialized for me.
The binary format turned out to be much simpler than the text format: when you do not need to parse, but simply map structures, it’s such a buzz ...
And the August version of the editor already allowed to load MDX, at the same time supporting MDL / MDX conversion. The import of 3DS models was also added there, but this function turned out to be unclaimed. It became clear that MdlVis is used precisely for quick and easy editing of existing models.

Support

But the community has its drawbacks: in particular, people are rather reluctant to report minor bugs. If everything fell at all, and falls steadily on this model, then yes, they will report. And if it falls once out of ten, or a little crashes, most likely I will not know about this. No matter how he swore at the forum, nothing helped. He even expressed the idea that it would be nice to distribute MdlVis as Shareware, where the registration key would be sent in exchange for a bug report.
But there were glitches. Moreover, a significant part of them turned out to be connected not with the editor himself, but ... with video drivers. The OpenGL standard actually turned out to be a complete lack of a standard. Some vendors interpreted its specification so peculiarly that I just had eyes on my forehead. Cards from ATI and their Chinese clones were especially different, among which, for example, I came across an instance that does not support double buffering. As a result, the 3D-engine over time has become overgrown with a web of numerous tricks, hacks and checks for each sneeze, just to make it all work on the numerous "zoo" of video cards. And this despite the fact that I then used pure OpenGL1.0, without any extensions whatsoever!
The modelers themselves added difficulties. Since the editor was still very limited, they often edited text-based MDLs right in Notepad. This resulted in something that was not provided for by the specification, and it was interpreted incorrectly by the editor (i.e., not like in the engine of the game itself). I had to adjust. I spent a lot of time generating the wildest combinations of flags and elements, “feeding” all this to War and watching his reaction.
MdlVis itself was also not stable. When I started it, I didn’t plan that it would grow so much (in a figurative sense, of course - the entire editor’s binary didn’t reach the 500k line until the very end, and it always went with a single file, without additional dependencies). As a result, there was no architecture there, the memory flowed into all the holes, Access violations fell out in packs, and each corrected bug could easily activate a couple of new ones.
I also encountered another, completely unexpected problem: I did not have time for modeling! Programming devoured time in any quantities, and the situation was absurd: I created an editor specifically to hit people with cool maps, but in the end, completely different people modeled it.
But, despite all the difficulties, MdlVis was approaching the peak of his fame. Moreover, the end of 2005 is the heyday of Warcraft III. Cards were issued in packs, packs of models were compiled, kinematics contests were held, projects multiplied like mushrooms after rain. People experimented with the gameplay, creating incredible, fantastic maps (like FPS on the WC3 engine). Work was in full swing.

Wow! It's coming ...

And then he came. The first of the gods of the new era, the online era. The harbinger of the apocalypse and death of singles per se.
World of warcraft .
More precisely, he appeared even earlier, but in Russia he was familiar only by hearsay and emulators personally raised on their own desktops. Not with the then networks to cut into it. Only Muscovites were more or less lucky; there, according to rumors with the Internet, it was already relatively good back then.
In general, at that time WoW was useless for Russian gamers. But there were models in it. And what! High-poly, with tons of super-quality animations, with detailed textures. And, which is especially valuable, everything is on the subject of Warcraft. The idea of ​​ripping these models in the MDX format was literally in the air.
So, a script for importing M2 (format of WoW models) into 3DSMax, written by one of the craftsmen, appeared, but it worked so crookedly that not everyone managed to launch it. In addition, he imported only meshes and a skeleton, which in addition needed to be clipped to the vertices manually.
And then Blizzard released a new WoW patch, and the script generally stopped working.
The situation was complicated by the fact that I did not have the opportunity to either download WoW (the grid was upgraded, yes, but still dial-up from 33.8kbit / s at the peak), nor buy it. And here again the community came to the rescue. At my request, the mail was inundated with models and textures, as well as screenshots of how all this should look in the game. Somewhere they got a draft of documentation on the M2 format. As it turned out later, those docks were largely untrue.
I spent weeks in the HEX editor, understanding the intricacies of the new format. The WoW engine turned out to be much more advanced than the WC3 engine, so many features of the M2 models simply had no analogues in MDX. I had to improvise: to figure out how, based on the analysis of M2, essentially from scratch to generate the most similar MDX model.
I had to tinker with the texture format, BLP2. A whole set of compression algorithms was used there, from JPEG to DXT (I encountered the latter for the first time, and also smoked forums for a long time, figuring out how it is generally decoded).
And now the historical moment has come: November 9, 2005. MdlVis 1.2 released. The first program in the world that can convert WoW models and textures for the third Warcraft.
I myself was so imbued with the importance of the moment that I even wrote a detailed tutorial where I chewed literally every detail of the process.
To say that the converter turned out to be in demand is simply to say nothing. Forums exploded. People converted models for days on end, setting themselves seem to be the goal of converting all WoW content as a whole.
Moreover, the English-speaking community suddenly found out about MdlVis. This surprised me somewhat: until now, I somehow did not even think about the fact that there are also players and modmakers abroad, and that there are even more of them than in Russia. Therefore, the editor was made exclusively for the Russian-speaking audience. Interface, readme, FAQ and tutorials - everything was in Russian. A non-intuitive interface almost completely eliminated the likelihood of understanding the program by typing.
However, on wc3search and a number of other resources, an English-language tutorial on converting WoW models appeared (in the style of “now click on the third row of hieroglyphs in the menu from the top, then we don’t read it - just click on the left button ...”), and at the same time - the models themselves .
The latter, however, disappeared the next day with wc3search, but a topic appeared with a flame: “Is it legal to use models from WoW in WC3 mods”?
I remember then laughed at this discussion for a long time. He even threw the whole branch on his own working folder, it really hurt the mood. Oh yes, Blizzard will certainly be offended that fans stole models from one of their games in order to insert them into another of the same company and on the same topic. In those days, it sounded like a joke, because we all sincerely believed that signs like ©, tm, ® are intended solely to make the name look more solid.
Wow model
The WoW model imported into the MdlVis MdlVis

workspace, by the way, came under a “no” license. That is, it could not even have crossed my mind to demand money for it, or at least add a multi-kilometer header with the text of a free license to each source file.
Be that as it may, the flame widened, and Blizzard kept a meaningful silence. Either they were speechless, or (most likely) they really didn't care.
However, two weeks later their support nevertheless replied that it was possible to upload it, but not to Battle.net cards. A month later - what is possible in battle.net, but only if the model with all the textures does not exceed 1Mb. And then they completely waved their hands, all the more so as by that time only DotA remained from the whole Battle.net.
I faced the problem of optimization: it was necessary to push hefty WoW models into the declared 1Mb.
The issue of reducing the size was resolved gradually and leisurely, by collecting various tricks and hacks. For example, numbers in MDX were given 4-byte floats. Two of the four bytes, as it turned out, can be zeroed out painlessly, which led only to a decrease in accuracy and usually did not affect the quality of the model. But in the archive, such models were already shrinking much better ... Well, everything is in the same style.
Models that were excessively “stolen” in this way normally ate both the game and MdlVis, however, third-party modeling tools fell on them only on the way. As a result, there was nothing to edit such models except my program, the community began to be indignant, and I had to add a “canonizer” to the editor - an antihack that brought the models back to their standard form, albeit by increasing their size.
In addition to M2, WoW used another format, WMO. If in M2 mostly models of different active mobs were stored, then in WMO lay the environment. Pillars, buildings, even entire cities. The structure of WMO resembled a mini-map: it contained a description of how to assemble the model from pieces and links to "building blocks".
In the end, not without the help of the community, I also figured out this format, adding its support to the next version of the editor.

Competition

Around the same time, MdlVis has a competitor: Warcraft III Model Editor (W3ME). This one was written in C ++, it came immediately with open sources, used DirectX, the English language of the interface, and weighed six times more than MdlVis'a (in those days I was very proud of this miniature editor).
The author of W3ME is clearly not new to programming, and he was familiar with architecture firsthand: very clear, understandable even without comment, readable code, high modularity and incredible stability. W3ME turned out to be a kind of antipode of MdlVis, everything was the other way around: DirectX vs. OpenGL, C ++ vs Delphi, modularity vs spaghetti. Even the functions for which each of the editors was sharpened did not match: W3ME allowed working with particle sources, skeleton, animations, but there were no convenient tools for editing meshes there. In MdlVis, on the contrary, editing meshes was not difficult, but the poor and buggy animation editor left much to be desired.
It was then that I made another mistake: I decided to rewrite the MdlVis animation editor from scratch, so as not only to copy, but also to surpass the functionality of W3ME, leaving no chance to the competitor.
In those days, I still did not know about version control systems, so I acted on the principle of "the next version is a build of the current state of the code." And when they informed me about the next bugs in MdlVis, I could not fix them, since that would mean putting the version without the animation editor at all (it was completely removed from the code, but a new one was just created). The same Git would easily solve my problem, but I didn’t even know about it then, and there was nobody to tell.
And then Blizzards released the next WoW patch, where they changed the format of the models, so that they stopped opening with the converter. In general, fixes became inevitable. The next version of MdlVis came out patched. Less bugs, the ability to convert a new format of WoW models ... but no animation editor. At all.
At this time, the W3ME author took seriously the mesh editor. His program began to catch up with MdlVis, so I had to push too. Mathematics again became the main problem: I had to collect information about the types of interpolation, to understand Hermite splines, and to search for algorithms.
In the end, the animation editor still appeared in MdlVis. It really turned out to be significantly more functional than in W3ME, but it was still distinguished by the same spaghetti architecture, and therefore regularly led to the crash of the program.

Bug search

And a new problem: a lot of irreproducible glitches have accumulated in bug reports. That is, everything worked for me like a clock, but for the user exactly the same actions for some reason led to a crash. What to do?
Having smoked a little forums, I decided to add the ability to remove minidumps to the VEH program. Then, having received a dump from the user, it will be possible to load it into the debugger and at least try to understand what caused the problem.
No sooner said than done. MdlVis 1.39 came out with new functionality. All exceptions were additionally caught by VEH, and a dump was removed in the handler. At the same time, I again took into account that there is no VEH, nor work with dumps in Win98. Therefore, MdlVis first checked for the presence of the necessary functions, loading the required modules dynamically. If the system did not support VEH and dumps, MdlVis worked fine anyway, just without this extra functionality.
The principle of "maximum compatibility" and paranoid checks of everything in a row, which I adhered to from the very beginning of development, paid off when Windows Vista came out. W3ME immediately refused to run it, so the modmakers had to wait almost two weeks for the fix, and MdlVis worked without any problems.
So, the new version went to the people. And immediately it caused complaints: if MdlVis often crashed, then the working directory was quickly clogged with tons of dumps. But instead of describing the bug, it turned out to be quite simple to attach a dump, and finding the cause of the fall became much easier and more pleasant.
It was thanks to the dumps that I was able to identify and fix a lot of previously unreproduced bugs. Most of them were caught by 1.39c, which is still considered the most stable of all versions.

The fate of the editor

What happened next? And then - graduate school, dissertation, defense, job search, work itself. There was less and less time on MdlVis, and Warcraft was gradually losing popularity, degenerating to Battle.net and Dota.
But rumors circulated about the imminent release of StarcraftII. I already licked my lips in advance: after all, it will be possible to remake MdlVis already under the Starcraft model! Surely they will give us a much more powerful map editor, a more powerful engine, and in general Blizzards 100% are preparing the next revolution. But I didn’t take into account that “soon” in the understanding of Blizzard is a loose concept. And when StarcraftII came out, it suddenly turned out that online had taken over the world. Now, in addition to casuals, there is only MMO. Singles are dead, modmakers are not interesting to anyone, and there is not the slightest sense of developing an editor.

Key mistakes and conclusions

Here are my main mistakes made during the development and support of MdlVis:
  • Wild development . Nevertheless, architecture must be planned first, and not later. And cover the code with unit tests at least in the smallest possible amount.
  • Documentation . Docks should be written before, and not after, the code. And then edit, if you couldn’t write the code for the dock. Nasty documentation has long been the hallmark of OpenSource, and you should not continue this tradition, expecting the community to figure it out and write the tutorials. When half of the “caming sun” sections are on the docks, and the second half is outdated for a couple of years and does not correspond to reality, the user has a depressing impression.
  • The OpenGL . He completely discouraged me from contacting any “standards” that did not have a single owner, capable of pushing a clear, unambiguous implementation and tapping the cap to all alternatively seeing ones. If a technology is being developed by a committee or consortium, you must run away from it like from a plague. So, starting a new project, I will now definitely choose DirectX instead of OpenGL, and Flash instead of JS + HTML + CSS (on which even hello world can’t be done without a dozen hacks).
    Also, now I will be pretty suspicious of such a “cross-platform” code, which consists of # define / # ifdef for 90%, and the remaining 10% are underscores.
  • Pursuit of size. The fact that MdlVis got into 500k is certainly cool, but useless. Screw volumes and network speeds are growing so rapidly that it’s not a problem for a user to download 500 MB. Therefore, all the endless hacks and optimizations in size do not make sense. For example, Windows XP fit into 1GB, and Win8 already requires 20GB, even a suspicion creeps in that it was written in C #. And nothing works, everyone is happy.
  • Rewriting code. Every now and then succumbed to the desire to "take and rewrite", as if replacing one piece of structureless code with another would change something the same. As a result, each rewriting led only to a loss of time and a whole bunch of additional bugs.
  • The pursuit of versatility . In 2005, it was already foolish to equate Win98 with all sorts of “special” systems.


Despite numerous mistakes, I just got tremendous experience in running my own project and interacting with the community, and a lot of pleasure from the process. IMHO, everyone who is fond of programming should go through this at least once.
It’s easy to start: just find a large, united community, become a part of it and start coding an instrument that you really, really miss. Yes, the first version will be weak and buggy. But then the community itself will tell you in which direction to move.

Also popular now: