- Joined
- Nov 3, 2006
- Messages
- 8,102
Animated DNC Light Models
DNC (DayNightCycle) is a model made to simulate day/night cycle behavior. It occured to me, one day, that I could make one with much more contrast than the original, Blizzard ones, have. I started editing values in Magos' model editor, just to realize that the editor doesn't save those values, but discards them. Then I thought, no biggie, I will just write everything I have in MDL, and then convert it to MDX, using Guesst's MDLX converter. It did save animated light and intensity values, but now I've had to deal with a different problem: all lights were set to Ambient, and in order for this to work, they must be directional.
I've realized that this is a common problem people don't actually know about, but just think that their generated lights simply "don't work". Truth be told, light nodes are immensely simple in Warcraft III, but those two great tools do not cope too well with them.
So, here's what we need to make our DNC model:
- Guesst's MDLX converter
- Magos' model editor
- ANY text processor (I used notepad here)
- ANY hex editor (I used this free one)
- Possibly Yobgul's converter
- Luck (to deal with the hex editor and don't mess up anything)
- .MDL base for DNC (that I have created myself for the purpose of this
tutorial) View attachment DNCUnit.mdl - Helper Model (that I have also created so that you can set rotation and position values more easily) View attachment HelperModel.mdx
Step 1: Choosing rotation and position
When you want to create a custom DNC model, you must also think about where you want your light to come from. This is pretty hard to do in .MDL alone, especially if you are not familiar with the way coordinates/rotation works in model files.
First go to "Windows > Animation Controller" and set it to play the "Stand" animation.
Now, open the "HelperModel.mdx" that I have provided, go to "Windows > Node Manager", right-click "LightSource" and then "Edit Node". Here you can open "Translation" or "Rotation". First you should set "Rotation" values.
When you open the "rotation" window you will see some zeros and ones.
0:{0,0,0,1} is what you get. Changing the first value changes the roll of your light while changing the second one changes its pitch. If you want a pure left-to-right light, for example, you will only change the first value. If you want to change the rotation further, change the second one. If you want the light to come from the camera eye, you will have to edit both. Basically, you can leave the third and fourth values intact. When satisfied with the angle, copy values (like 0:{0.3, 0.1, 0, 1} for example) to a blank text file, you will need this later.
Now you need to change the light object's position.
Experiment with 0:{0,0,0} values until you're satisfied with the position of light source. Keep ind mind that Z (the last value) should be around 450, as set by Blizzard, but it is important to mention that the first two values do matter a lot. Since you've set rotation in the helper model, now you should also change the X and Y coordinates so that the light's beam (the spike on your HelperModel.mdx) hits the center. Once you've set the values properly, copy them (in my case 0:{-80,-80,450}) to the text file you opened to paste rotation data.
Step 2: Setting up the actual model file
Open the file DNCUnit.mdl in your text processor and follow the instructions provided there. You will have to create two files, one for units (actually, objects), and the other one for the terrain.
Step 3: MDX Conversion
This step can go two ways, either you'll use Yobgul's converter, or Guesst's. With Yobgul's converter, all you need to do is to convert it (and hope it doesn't give you errors without converting the file) OR you will have to use Guesst's tool, which leads to the hex editing stage. What's the catch, why would anybody use Guesst's if it requires more work? Because Yobgul's converter makes perfect Blizzard conversions, by using Blizzard's native .dll files. However, it requires the retail ones, before any patching has occurred, and they can be found in the war3.mpq archive. Not to mention Yobgul's converter won't convert the file at all if you, for example, put the order of some parameters or tags wrong (which all other converters tolerate) and there's few people I know who have been able to properly run it in 2012, on 64bit windows 7. The knowledge about Yobgul's capabilities largely comes from our resident .mdl master, Rao Dao Zao, so a lot of credits to as far as that is concerned. So there you go, if you can get your hands on Yobgul's converter, make it work, make it actually convert the model, you won't need the next, Hex editing stage. In case you are not very lucky with Yobgul's...
Convert your model to MDX using the Guesst's MDLX converter. Just open the tool, click convert, and find your model file, the .mdx version will be saved in the same folder. Aside from being handier and fixing a lot of stuff for you, Guesst's converter also 'fixes' something it shouldn't...
Step 4: Hex editing
Since Guesst's converter doesn't process light node's type properly, you will have to do so yourself. Not a biggie, though, unless you get lost in the model data. Open up the hex editor, and pay attention to any block that may reassemble this:
When you find it, click on the first character after "yyyy" (or "FF FF FF FF" in hex) on the right. Then, when you see what you've selected on the left, double click it on the left window, this lets you change the value via hex. You have two fields that you must edit, and you need to edit the first one to "01" and the second one to "02".
Once done, you've done half the job. Now, if the "@?" (or "40 3F" in hex) block isn't directly below the "FF FF FF FF" one, do not mind, search for it, keep in mind that it can't be more than two rows farther. Once found, use the same technique to edit values just after the said block to "01" and "00", respectively.
Do this for both models you're supposed to have, the DNCUnit.mdx and the DNCTerrain.mdx one.
Step 5: Import into the map and use
Once everything is set, you can start testing your models.
Just import those two models you made into the map, and use the custom script
JASS:
call SetDayNightModels("DNC\\DNCTerrain.mdx", "DNC\\DNCUnit.mdx")
Now you can load the map, play around and see if you need to change something, after reading the tutorial, you will have the knowledge to know what is wrong, so fixing will be easy. Here's the result, as provided by Anvil, since the video has compromised youtube quality, you can instead check the attached map out:
Attachments
Last edited: