Explores and exports all of Daggerfall’s 3D models, cities, and dungeons.
Works like a visual atlas for searching and exploring anywhere in Daggerfall’s world.
The code library that interfaces between Daggerfall’s DOS game files and Daggerfall Unity. The included Importer allow to explore specifics models and billboards (disable Billboard Batch) as well as towns and dungeons layouts. Your best option is to download Daggerfall Unity from Github (video tutorial), as it contains all the tools and it allows to test models directly in game.
Export from your modelling software
When exporting your model from a modelling software you need to take a few things in consideration:
- Models exported from Daggerfall Modelling are forty times bigger than they need to be in order to be used in Unity, so you need to scale them down by 0.025.
- Unity engine reads models as Y-up not Z-up. You can use this plugin for blender to address this.
- Your model can’t have more than 65,534 vertices. If you need, split your model in several parts and put them togheter inside the prefab.
- Unity supports different formats, but exporting to .fbx is suggested.
Import your model in Daggerfall
- Go to daggerfall-unity-master\Assets\Resources\Models and create a subfolder. Rename it with the ID of the model, then create another folder inside this one and place the .fbx file inside.
- Place the relative textures inside daggerfall-unity-master\Assets\Resources\Textures. You need to do so even if you’re using vanilla textures.
- Now open Unity and let it import all the new files. When it’s done, navigate to the model subfolder in the project window and create new materials, one for each texture you need to use.
- Drag your model in the scene view and assign materials to the model. Then place it in a prefab with the same name as the folder: /models/modelID/modelID.prefab. If the model has a winter version, create another prefab called modelID_winter.prefab.
- When you’re done, you can compile the project and look for your model in game.
Hint: Compile as a debug build to import models from Assets for quick testing, disable debug to compile as a release build which only imports from bundled mods (read Distribute Mods section for more information on how to release your models to the public).
- Go to \Assets\Resources\Flats and create a subfolder, named after the sprite texture we are replacing.
For example 205_0 for the texture 0-0 in archive 205.
- Place your model inside this folder (maybe in a subfolder called Mesh or Assets, for example), the texture you need to use in the usual Resources/Textures folder and create materials.
- Create the prefab, name it with the same ID as above and place it in the main subfolder.
In our case we will have /Flats/205_0/205_0.
- Compile as a debug build like to test your model in game.
- Models should have the origin in the same position as vanilla mesh.
Custom flats prefabs are placed in game assuming the origin of the model is at the base, where they touch the ground or the surface they are positioned on, so place it in this position.
- If the model is supposed to collide with the player, check Generate colliders in the mesh inspector inside the Unity editor.
- Using prefabs give us a lot of freedom as they allow combining more than one mesh, using particles and lights.
If your model is split in parts, import an .xfb file for each of them and set them in a single prefab.
- When you replace an exterior model, is a good idea to provide a LOD Group.
- Wind is natively supported for SpeedTrees and trees created with the Unity Tree Creator. Additionally, it can affect particle systems through the External Forces module.
- Why the difference in scale?
Using 1/40 scale (or * 0.025).
True world scale is 1/39.37007874015748 (or * 0.0254). Basically conversion is inches (Daggerfall) to metres (Unity).
1/40 scale has been carefully chosen as it is close to true scale but requires less floating-point precision
for tiling assets. It also produces numbers easier to remember for editor layouts and is easier to
calculate manually (i.e. just divide by 40 to convert native units to Unity units).
For example, an RMB block dimension is 4096 native units.
4096 / 40 = 102.4 (easy to remember for manual editor layouts, less precision required).
4096 * 0.0254 = 104.0384 (harder to remember for manual editor layouts, more precision required).
This means world is slightly smaller over large distances (13107.2m error across entire map width).
- Are custom models affected by user settings for filter type?
Yes, both vanilla and custom textures are affected by MainFilterMode.
Normally, models are instantiated with the same rotation as originals while flat replacements have a random rotation for increased variety. There are some situations, though, where a random rotation is not appropriate. Wall torches, for example, are camera-facing billboards in the original game, but when we replace them with a 3d model we want them to have a specific position; unfortunately this is not immediate because the rotation amount for every torch is not specified in the game: it’s simply not necessary for billboards.
To overcome this issue we can use a script which will find the position of the wall at run time and rotate the torch accordingly. This can be found in the inspector of the Unity editor and added as a component of the GameObject (Add Component).
The wall will be seeked inside this radius. Big values can cause wrong results.
Align To Wall
Make the GameObject parallel to non-straight walls.
Minor Angle To Ignore
Angles lower than this will be ignored.
The actual rotation is corrected by this value to take small inaccuracies into account.
Move Near Wall
Translate the GameObject so that it touches the wall.
Fix issue where GameObject clips with the wall if the origin is next to it.
Destroy On Bad Position
Remove the GameObject if it can’t be positioned correctly.
Daggerfall has dinamic changes during the day time flow; for example towns buildings have a light blue emission map for windows when the sun is up, while a yellow map is used at night.
To reproduce this behaviour on imported models we can use the component DayNight, which can also toggle lights and particles of lamps and torches.
Turn on lights and particles at night time, turn them off at day time.
- SelectedOnly: Toggle only selected lights and particle.
- All: Toggle all lights and particle in the prefab and its children.
Selected Particle Systems (only for SelectedOnly).
Selected Lights (only for SelectedOnly).
Update the color applied to the emissive material according to day time.
- NoColors: Does nothing.
- DaggerfallColors: Use Daggerfall colors.
- CustomColors: Use specified colors.
The index for the MeshRenderer of the material whose emission color will be dinamically changed (only for DaggerfallColors and CustomColors).
This is found from Inspector -> Mesh Renderer -> Materials. This material can (and typically should) have an emission map, while emission color and emission strength will be overridden with day and night colors and strengths.
The HDR color applied to the emission map at day time (only for CustomColors).
Daggerfall Unity default is #406E80.
The HDR color applied to the emission map at night time (only for CustomColors).
Daggerfall Unity default is #CC922D.
Transition from exterior to interior is implemented through a trigger placed in the same position as the door on the mesh. This trigger is indipendent from the mesh, so there aren’t any troubles with imported building as long as the door is in the same position as the original.
Nevertheless, sometime you may want to slightly alter the door position for aesthetic purposes. In this case it’s possible to include with your model both a textured door which is visible in the game and an invisible door in the correct position which acts as the collider for the trigger effect.
This is as simple as a planar mesh, with the same size of the door and enabled Generate Colliders. To achieve transparency set the material rendering mode to Cutout and albedo to a color with full alpha, for example #00000000.