13
Daggerfall Tools for Unity - Manual V1.2.41 | 10/02/2014 Devblog dfworkshop.net SVN code.google.com/p/daggerfall-unity Twitter twitter.com/dfinterkarma Email [email protected] Daggerfall Tools for Unity Thank you for downloading Daggerfall Tools for Unity. This asset is an API and suite of editor scripts for procedurally importing Daggerfall’s content into Unity3D. Getting Started Before using Daggerfall Tools for Unity, you will need the following: 1. A full install of Daggerfall. You can download Daggerfall for free from the following sites. http://www.elderscrolls.com/daggerfall/ http://www.uesp.net/wiki/Daggerfall:Files 2. Unity 4.6 or later (Free or Pro). http://unity3d.com/unity/download 3. Optional, but highly recommended is Daggerfall Modelling. This Windows-only exploring tool allows you to quickly search for and browse Daggerfall models, blocks, and locations. It will be very useful until similar search features are implemented in Daggerfall Tools for Unity. http://www.dfworkshop.net/?page_id=1045 (Download). https://code.google.com/p/daggerfallconnect/wiki/DaggerfallModelling (Online Manual). Note: Also install Daggerfall Modelling prerequisites as described in online manual link.

V1.2.41 | 10/02/2014 Email [email protected] … Tools... · 2015-08-14 · Daggerfall Tools for Unity uses a singleton class to interface with the DaggerfallConnect API

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: V1.2.41 | 10/02/2014 Email interkarma@dfworkshop.net … Tools... · 2015-08-14 · Daggerfall Tools for Unity uses a singleton class to interface with the DaggerfallConnect API

Daggerfall Tools for Unity - Manual V1.2.41 | 10/02/2014

Devblog dfworkshop.net SVN code.google.com/p/daggerfall-unity Twitter twitter.com/dfinterkarma Email [email protected]

Daggerfall Tools for Unity

Thank you for downloading Daggerfall Tools for Unity. This asset is an API and suite of editor scripts

for procedurally importing Daggerfall’s content into Unity3D.

Getting Started

Before using Daggerfall Tools for Unity, you will need the following:

1. A full install of Daggerfall. You can download Daggerfall for free from the following sites.

http://www.elderscrolls.com/daggerfall/

http://www.uesp.net/wiki/Daggerfall:Files

2. Unity 4.6 or later (Free or Pro).

http://unity3d.com/unity/download

3. Optional, but highly recommended is Daggerfall Modelling. This Windows-only exploring

tool allows you to quickly search for and browse Daggerfall models, blocks, and locations. It

will be very useful until similar search features are implemented in Daggerfall Tools for

Unity.

http://www.dfworkshop.net/?page_id=1045 (Download).

https://code.google.com/p/daggerfallconnect/wiki/DaggerfallModelling (Online Manual).

Note: Also install Daggerfall Modelling prerequisites as described in online manual link.

Page 2: V1.2.41 | 10/02/2014 Email interkarma@dfworkshop.net … Tools... · 2015-08-14 · Daggerfall Tools for Unity uses a singleton class to interface with the DaggerfallConnect API

Daggerfall Tools for Unity - Manual V1.2.41 | 10/02/2014

Devblog dfworkshop.net SVN code.google.com/p/daggerfall-unity Twitter twitter.com/dfinterkarma Email [email protected]

Using Daggerfall Tools for Unity

Importing Asset

After installing Daggerfall and Unity3D the next step is to import latest Daggerfall Tools for Unity

package.

1. Open Unity3D and start a new project.

2. Click Assets > Import Package > Custom Package. Browse to the “Daggerfall Tools for

Unity.unitypackage” file and click Open.

3. Ensure everything is selected and click Import. This will import Daggerfall Tools for Unity

into your Assets folder and compile scripts.

4. Alternatively double-click the .unitypackage file to install into your current project.

Prepare GameObject

Daggerfall Tools for Unity uses a singleton class to interface with the DaggerfallConnect API. Only

one instance of this script is required to import Daggerfall content from the editor or in code.

1. Create a new GameObject by clicking GameObject > Create Empty. Rename the new

GameObject to “DaggerfallUnity”.

2. Select your new DaggerfallUnity object in Hierarchy then click Add Component in the

Inspector. Browse to Scripts > Daggerfall Workshop > Daggerfall Unity to add the main

script and any prerequisites.

3. Alternatively there is a prefab DaggerfallUnity in the Prefabs sub-folder and a ready-made

empty scene in the Scenes sub-folder.

Page 3: V1.2.41 | 10/02/2014 Email interkarma@dfworkshop.net … Tools... · 2015-08-14 · Daggerfall Tools for Unity uses a singleton class to interface with the DaggerfallConnect API

Daggerfall Tools for Unity - Manual V1.2.41 | 10/02/2014

Devblog dfworkshop.net SVN code.google.com/p/daggerfall-unity Twitter twitter.com/dfinterkarma Email [email protected]

Set Arena2 Path

Before importing Daggerfall content, you must direct the script to your Daggerfall installation’s

Arena2 folder.

1. Click on the DaggerfallUnity game object in Hierarchy. Then in the Inspector, click Browse

and locate the Arena2 path of your Daggerfall installation.

Importing Content

Once you have set your Arena2 path, go to the Importer foldout in Inspector of your DaggerfallUnity

instance. Currently, Daggerfall Tools for Unity does not have full in-editor browsing. You will find

Daggerfall Modelling useful for locating IDs and names of content to import.

Models are imported using a unique ModelID. For example, ModelID 456 is the exterior of “Scourg

Barrow”.

Blocks are imported using a unique Block Name. City blocks end with .RMB and dungeon blocks end

with .RDB. For example, S0000999.RDB is the central block of Privateer’s Hold, and CUSTAA45.RMB

is the exterior of Castle Wayrest.

Cities and Dungeons are a bit more involved as some locations have both an exterior map and a

dungeon map. To import a city or dungeon enter in the format RegionName/LocationName to either

the City field or Dungeon field.

For example, entering Daggerfall/Daggerfall in the City Name field will import the above-ground city

of Daggerfall. Entering the same into the Dungeon Name field will import the dungeon within Castle

Page 4: V1.2.41 | 10/02/2014 Email interkarma@dfworkshop.net … Tools... · 2015-08-14 · Daggerfall Tools for Unity uses a singleton class to interface with the DaggerfallConnect API

Daggerfall Tools for Unity - Manual V1.2.41 | 10/02/2014

Devblog dfworkshop.net SVN code.google.com/p/daggerfall-unity Twitter twitter.com/dfinterkarma Email [email protected]

Daggerfall. If the target location has any apostrophes, be sure to enter exactly as shown in-game. For

example, entering Daggerfall/Privateer’s Hold into the dungeon field will spawn Privateer’s Hold.

Note: City Name and Dungeon Name fields are case-sensitive.

Once you have entered a model, block, or location, click the adjacent Import button to import that

resource into Unity. Imported content will be serialized with your scene.

Page 5: V1.2.41 | 10/02/2014 Email interkarma@dfworkshop.net … Tools... · 2015-08-14 · Daggerfall Tools for Unity uses a singleton class to interface with the DaggerfallConnect API

Daggerfall Tools for Unity - Manual V1.2.41 | 10/02/2014

Devblog dfworkshop.net SVN code.google.com/p/daggerfall-unity Twitter twitter.com/dfinterkarma Email [email protected]

Material Reader Options

The Material Reader is a required component of DaggerfallUnity. This script handles importing and

converting Daggerfall textures to Unity Materials. There are settings here which control how

materials are processed during import.

Atlas Textures. Combines billboards, ground textures, and animated textures into an atlas

for improved efficiency. Currently, animated textures must be atlased for animations to play.

It is recommended to always have this option enabled.

MipMaps. Control generation of mipmap textures on generated materials.

Compress Sky Textures. Enables texture compression for sky textures.

Main Filter Mode. Change the desired filter mode of imported textures. The options are

Point, Bilinear, and Trilinear. This setting will be applied whenever materials are rebuilt, such

as when applying new climate settings.

Sky Filter Mode. Set the desired filter mode for sky textures.

Default Shader. This is the name of shader applied to most materials imported from

Daggerfall. You can modify this to use your own shader instead. The shader is located using

Shader.Find() during import.

Billboard Shader. Same as above, but applied to billboard materials.

Self-Illumin Shader. Same as above, but applied to self-illuminated materials, such as the

windows.

Unlit Billboard Shader. Same as above, but applied to unlit billboard materials. This is used

by light textures, such as lamps and torches.

Page 6: V1.2.41 | 10/02/2014 Email interkarma@dfworkshop.net … Tools... · 2015-08-14 · Daggerfall Tools for Unity uses a singleton class to interface with the DaggerfallConnect API

Daggerfall Tools for Unity - Manual V1.2.41 | 10/02/2014

Devblog dfworkshop.net SVN code.google.com/p/daggerfall-unity Twitter twitter.com/dfinterkarma Email [email protected]

Unlit Texture Shader. Same as above, but for unlit textures. Used by fireplace hearth and

lava textures.

Window Colour & Brightness. These options are for setting window colour and brightness

(from 0.0 to 1.0) for window styles. You can set individual options for Day, Night, Fog, and

Custom windows.

Mesh Reader Options

The Mesh Reader is another required component of DaggerfallUnity. This script handles import and

conversion of Daggerfall’s 3D models to Unity Mesh format. It also has several code helpers for

importing other types of mesh resources, such as properly scaled billboard quads and correctly tiled

ground planes. There are only a couple of editor options for Mesh Reader at this time.

Add Mesh Tangents. This option calculates tangents for Daggerfall models as they are

imported. Tangents are used for shaders requiring a Normal Map. It is recommended this

option is left enabled.

Add Lightmap UVs. This option creates a secondary UV channel, required for lightmapping

environments with tiling textures. Enabling this option will greatly increase import times. It’s

not recommended to use this option unless lightmaps are required.

Note: It is required to set these options prior to importing mesh data.

World Time

The WorldTime component is a complete Daggerfall-styled Tamrielic calendar. It is instrumental in

managing seasons and time of day operations.

Page 7: V1.2.41 | 10/02/2014 Email interkarma@dfworkshop.net … Tools... · 2015-08-14 · Daggerfall Tools for Unity uses a singleton class to interface with the DaggerfallConnect API

Daggerfall Tools for Unity - Manual V1.2.41 | 10/02/2014

Devblog dfworkshop.net SVN code.google.com/p/daggerfall-unity Twitter twitter.com/dfinterkarma Email [email protected]

Year, Month, Day, Hour, Minute, Second are individual units of current time.

Time Scale scales the speed at which Tamrielic time elapses, and is unrelated to Unity’s

internal time scale. Increasing this value to something high like 5000 will make days flash by

in a few seconds. The default time scale is 10.

Show Debug String draws a simple time string at top-left of screen while game in running.

Sound Reader

SoundReader is the final required component of DaggerfallUnity. This script handle import and

conversion of Daggerfall’s audio sound effects. There are no editor options for the Sound Reader at

this time.

Page 8: V1.2.41 | 10/02/2014 Email interkarma@dfworkshop.net … Tools... · 2015-08-14 · Daggerfall Tools for Unity uses a singleton class to interface with the DaggerfallConnect API

Daggerfall Tools for Unity - Manual V1.2.41 | 10/02/2014

Devblog dfworkshop.net SVN code.google.com/p/daggerfall-unity Twitter twitter.com/dfinterkarma Email [email protected]

Daggerfall Unity Options

The DaggerfallUnity editor has several options available to control how content is imported and how

it behaves at runtime.

Page 9: V1.2.41 | 10/02/2014 Email interkarma@dfworkshop.net … Tools... · 2015-08-14 · Daggerfall Tools for Unity uses a singleton class to interface with the DaggerfallConnect API

Daggerfall Tools for Unity - Manual V1.2.41 | 10/02/2014

Devblog dfworkshop.net SVN code.google.com/p/daggerfall-unity Twitter twitter.com/dfinterkarma Email [email protected]

Combining

Combine RMB. Combines models in RMB blocks (city blocks) to reduce draw calls and

increase efficiency of scene. Will otherwise maintain the same native scene layout as

Daggerfall. It is recommended to leave this enabled.

Combine RDB. Combines models in RDB blocks (dungeon blocks) as above. It is

recommended to leave this enabled.

Scene Options

Set Static Flags. Sets appropriate objects as static. Ignores billboards and dynamic objects.

Add Colliders. Adds a mesh collider to imported objects. Daggerfall’s meshes are very

simple, about the complexity of normal physics meshes.

Default Sounds. Adds a DaggerfallAudioSource to any scene object which creates sounds,

such as torches, action objects, doors, and enemies.

Close City Gate. The gates of walked cities will default to closed. This can also be controlled

by Time & Space options.

Lights

Import Point Lights. Import point lights for cities and dungeons.

Animated. Adds a flickering range animation to point lights.

Tag. Set a custom tag for your lights. This enables you to manage scene lights as required.

Custom Script. Add a custom script to each light. This enables you to quickly attach your

own behaviour to imported lights.

Enemies

Import Enemies. Imports fixed enemies in dungeons (random enemies will be handed in a

future update). Each enemy comes with a script to handle correct orientation and animation

states.

CharacterController, Rigidbody, CapsuleCollider, NavMeshAgent. Attach the selected Unity

components to enemy at import. This will depend on how you choose to implement enemy

movement and AI.

Example AI. Add a suite of example scripts to every enemy, rigging them up for basic

movement and combat. Will also attach a CharacterController.

Tag. Set a custom tag for each enemy imported.

Custom Script. Attach a custom script to every enemy.

Advanced. Several preset options to apply when importing CharacterController and

Rigidbody components.

Page 10: V1.2.41 | 10/02/2014 Email interkarma@dfworkshop.net … Tools... · 2015-08-14 · Daggerfall Tools for Unity uses a singleton class to interface with the DaggerfallConnect API

Daggerfall Tools for Unity - Manual V1.2.41 | 10/02/2014

Devblog dfworkshop.net SVN code.google.com/p/daggerfall-unity Twitter twitter.com/dfinterkarma Email [email protected]

Time & Space

Automate Textures. Changes exterior textures based on climate, season, and time of day.

Automate Sky. Changes sky animation based on season, weather (to be implemented) and

time of day.

Automate City Lights. Point lights in cities will turn on and off based on time of day.

Climate Textures

After importing a city location, you can customise the climate and season directly from editor. To get

started, import a full city like Daggerfall/Daggerfall. By default this will have the climate settings

matching that location. Click on the DaggerfallCity game object in the Hierarchy.

Your Inspector then displays a summary of your location along with several controls for adjusting the

climate textures and window style. The metadata in About is generally only used by internal

systems. The Climate settings are where you can control climate from the editor.

Usage. Options are Disabled, Use Location, or Custom.

Page 11: V1.2.41 | 10/02/2014 Email interkarma@dfworkshop.net … Tools... · 2015-08-14 · Daggerfall Tools for Unity uses a singleton class to interface with the DaggerfallConnect API

Daggerfall Tools for Unity - Manual V1.2.41 | 10/02/2014

Devblog dfworkshop.net SVN code.google.com/p/daggerfall-unity Twitter twitter.com/dfinterkarma Email [email protected]

o Disabled. Turns off climate processing entirely.

o Use Location. Uses the location settings as shown in the About fields. Note that

resetting from cog will destroy location metadata.

o Custom. Full control over which climate settings are applied.

Season. Options are Summer, Winter, Rain. Applies index modifiers to textures for

simulating different in-game seasons. The Winter setting will enable snow textures, and Rain

will slightly darken the ground plane.

Climate. Options are Desert, Mountain, Temperate, Swamp. Applies index modifiers for

simulating different in-game climates. Note that some climates do not fully support all

seasons. For example, Swamp+Winter does not have a full complement of snow textures.

Daggerfall Tools for Unity will gracefully handle known invalid swaps.

Nature Flats. These are the trees, rocks, and shrubs used in combination with the climate.

You can set this however required, even in combinations not normally seen in-game.

Windows. Options are Disabled, Day, Night, Fog, Custom. Sets the window style of your city

location based on time of day and weather. Use the custom setting for unusual effects, and

set disabled to ignore window styles completely.

Above: A Winter scene with point lights and Night windows.

Dungeon Textures

You can manually set dungeon texture swaps via the Inspector when you have a dungeon selected.

Currently only the Custom option is implemented.

Page 12: V1.2.41 | 10/02/2014 Email interkarma@dfworkshop.net … Tools... · 2015-08-14 · Daggerfall Tools for Unity uses a singleton class to interface with the DaggerfallConnect API

Daggerfall Tools for Unity - Manual V1.2.41 | 10/02/2014

Devblog dfworkshop.net SVN code.google.com/p/daggerfall-unity Twitter twitter.com/dfinterkarma Email [email protected]

In brief, dungeon texture swaps work by modifying a table of base texture indices to a substituted

texture index. In-game, this is controlled by a random seed and random generator. Daggerfall Tools

for Unity currently does not implement authentic texture swaps based on location.

However it is possible to set your own custom swaps, or just click the Random button to generate a

new valid texture table at random. Be careful with custom swaps, as it’s possible to set an invalid or

inappropriate texture index. If you set an invalid swap, or just want to return back to start settings,

use the Reset button. Click Apply to apply your changes.

Other Tips

Camera Setup & Billboards

The default DaggerfallBillboard.cs script for billboard sprites (enemies, trees, etc.) will rotate to face

the editor camera in your currently selected viewport while in edit mode.

After hitting play, sprites will look for the camera tagged “MainCamera” and rotate to face this

camera in the Game window. If you change the default camera, don’t forget to set the MainCamera

tag on your first-person camera.

Global Scale

Daggerfall’s 3D objects natively use fixed-point arithmetic. A straight conversion to floating point

results in very large environments well beyond the normal Unity 2m player height. By default,

everything is scaled to 1/40 of original size. For reasons on this, check MeshReader.cs where

GlobalScale is defined.

If you would like to adjust the global scale play with GlobalScale field in MeshReader.cs. When

placing objects into the scene from code, don’t forget to multiply by GlobalScale so it will be aligned

with other objects in the scene. After changing GlobalScale, you will need to re-import content. It is

recommend to use the one scale throughout development.

It is not recommended to change the default GlobalScale, but it is important to know why it’s there.

Page 13: V1.2.41 | 10/02/2014 Email interkarma@dfworkshop.net … Tools... · 2015-08-14 · Daggerfall Tools for Unity uses a singleton class to interface with the DaggerfallConnect API

Daggerfall Tools for Unity - Manual V1.2.41 | 10/02/2014

Devblog dfworkshop.net SVN code.google.com/p/daggerfall-unity Twitter twitter.com/dfinterkarma Email [email protected]

First-Person Controller

Some of the architecture in Daggerfall is very steep. To ensure your first-person controller can

ascend stairs and ramps, try playing with the maximum slope and step height parameters. A

maximum slope of 75-85 degrees and a step height of 0.4-0.5 seems to work well in most cases.

You may also need to tune radius and height to ensure controller can fit through doors at bottom of

stairs and other tight spaces.

You will find example first-person controller (Player Motor) and mouse look (Player Mouse Look)

scripts in the Demos folder. There is also a premade Player prefab you can just drop into the scene.

Don’t forget to delete any other MainCamera objects.

When you hit play, you can explore your imported scene using WSAD to move, SHIFT to toggle run

(keybind required), SPACE to jump, and ESC to uncaptured mouse.

Enemy Mobiles

Daggerfall Tools for Unity provides a foundation for enemy mobile units. These are imported

wherever the appropriate editor marker is found. You could extend this foundation with spells,

resistances, new enemy types, AI behaviours, and so on. Example enemy scripts are in the Demos

folder. Currently is it not possible to instantiate an enemy directly from editor.

Lighting

Billboards normal are currently set to half way between Vector3.up and Vector3.forward. This

means they will pick up some lighting from in front and some lighting from above. This seems to

work well for three-point lighting rigs and point lighting. If you find your billboards are too dark in

some orientations, add a cheap directional light to illuminate them a little.

When using many point lights (common in cities) without benefit of Deferred Lighting from a Pro

license, you may need to increase the number of pixel lights available to your scene. Otherwise you

may find lights turning on and off at unexpected times in heavily lit areas. You can increase the Pixel

Light Count in Unity from Quality settings. This will impact on performance, so Deferred is

recommended if you have a Pro license.

Standalone Builds

You can include files from the Arena2 folder in your build by appending “.bytes” to the file and

copying into a Resources folder in your Unity project. When loading files from the API with

FileUsage.UseMemory (now default) the FileProxy class will search your Resources folder for an

available file of the same name (e.g. “arch3d.bsa.bytes”) and use that file instead. This will help you

to create builds for web and mobile platforms.

Standalone builds will be covered in detail in a future tutorial.