Show / Hide Table of Contents

Class MeshReader

Imports Daggerfall models into Unity as Mesh objects. Should only be attached to DaggerfallUnity (for which it is a required component).

Inheritance
Object
Object
Component
Behaviour
MonoBehaviour
MeshReader
Namespace: DaggerfallWorkshop
Assembly: Assembly-CSharp.dll
Syntax
[RequireComponent(typeof(DaggerfallUnity))]
public class MeshReader : MonoBehaviour

Fields

| Improve this Doc View Source

AddMeshLightmapUVs

Declaration
public bool AddMeshLightmapUVs
Field Value
Type Description
Boolean
| Improve this Doc View Source

AddMeshTangents

Declaration
public bool AddMeshTangents
Field Value
Type Description
Boolean
| Improve this Doc View Source

GlobalScale

Declaration
public const float GlobalScale = 0.025F
Field Value
Type Description
Single

Properties

| Improve this Doc View Source

IsReady

Gets true if file reading is ready. You should always check this before loading model data or meshes.

Declaration
public bool IsReady { get; }
Property Value
Type Description
Boolean

Methods

| Improve this Doc View Source

ClearCache()

Clears model cache dictionary, forcing models to reload.

Declaration
public void ClearCache()
| Improve this Doc View Source

GetBillboardMesh(Rect, Int32, Int32, out Vector2)

Get a Unity quad mesh from texture to use as billboard. Will be scaled based on size settings in texture.

Declaration
public Mesh GetBillboardMesh(Rect rect, int archive, int record, out Vector2 sizeOut)
Parameters
Type Name Description
Rect rect

UV rect of material.

Int32 archive

Texture archive index. Only used to calculate size.

Int32 record

Texture record index. Only used to calculate size.

Vector2 sizeOut

Size of billboard in world units.

Returns
Type Description
Mesh

Mesh object or null.

| Improve this Doc View Source

GetCombinedMesh(DaggerfallUnity, ModelCombiner, out CachedMaterial[], out Int32[], out Boolean, Boolean, Boolean)

Gets Unity Mesh from previously combined model data.

Declaration
public Mesh GetCombinedMesh(DaggerfallUnity dfUnity, ModelCombiner combiner, out CachedMaterial[] cachedMaterialsOut, out int[] textureKeysOut, out bool hasAnimationsOut, bool solveTangents = false, bool lightmapUVs = false)
Parameters
Type Name Description
DaggerfallUnity dfUnity

DaggerfallUnity singleon for loading content.

ModelCombiner combiner

ModelCombiner to build from.

CachedMaterial[] cachedMaterialsOut

Array of cached materials in order of submesh.

Int32[] textureKeysOut

Array of original texture keys in order of submesh.

Boolean hasAnimationsOut

True if one or more materials have animations.

Boolean solveTangents

Solve tangents for this mesh.

Boolean lightmapUVs

Add secondary lightmap UVs to this mesh.

Returns
Type Description
Mesh

Mesh object or null.

| Improve this Doc View Source

GetMesh(DaggerfallUnity, UInt32, out CachedMaterial[], out Int32[], out Boolean, Boolean, Boolean)

Gets Unity Mesh from Daggerfall model.

Declaration
public Mesh GetMesh(DaggerfallUnity dfUnity, uint modelID, out CachedMaterial[] cachedMaterialsOut, out int[] textureKeysOut, out bool hasAnimationsOut, bool solveTangents = false, bool lightmapUVs = false)
Parameters
Type Name Description
DaggerfallUnity dfUnity

DaggerfallUnity singleon for loading content.

UInt32 modelID

Daggerfall model ID to load..

CachedMaterial[] cachedMaterialsOut

Array of cached materials in order of submesh.

Int32[] textureKeysOut

Array of original texture keys in order of submesh.

Boolean hasAnimationsOut

True if one or more materials have animations.

Boolean solveTangents

Solve tangents for this mesh.

Boolean lightmapUVs

Add secondary lightmap UVs to this mesh.

Returns
Type Description
Mesh

Mesh object or null.

| Improve this Doc View Source

GetModelData(UInt32, out ModelData)

Loads model data.

Declaration
public bool GetModelData(uint id, out ModelData modelData)
Parameters
Type Name Description
UInt32 id

Key of source mesh.

ModelData modelData

ModelData out.

Returns
Type Description
Boolean

True if successful.

| Improve this Doc View Source

GetScaledBillboardSize(Int32, Int32)

Gets scaled billboard size based on scaling in texture file.

Declaration
public Vector2 GetScaledBillboardSize(int archive, int record)
Parameters
Type Name Description
Int32 archive

Texture archive index.

Int32 record

Texture record index.

Returns
Type Description
Vector2

Final scaled size.

| Improve this Doc View Source

GetSimpleBillboardMesh(Vector2)

Gets a most basic quad.

Declaration
public Mesh GetSimpleBillboardMesh(Vector2 size)
Parameters
Type Name Description
Vector2 size

Size of quad in Unity units (not Daggerfall units).

Returns
Type Description
Mesh

Mesh object.

| Improve this Doc View Source

GetSimpleGroundPlaneMesh(ref DFBlock, out Color32[], Boolean, Boolean)

Gets a simple ground plane mesh. This is only used for RMB block layouts, not for terrain system.

Declaration
public Mesh GetSimpleGroundPlaneMesh(ref DFBlock blockData, out Color32[] tileMap, bool solveTangents = false, bool lightmapUVs = false)
Parameters
Type Name Description
DFBlock blockData

BlockData for tiles layout.

Color32[] tileMap

Tilemap Color32 array for shader.

Boolean solveTangents
Boolean lightmapUVs
Returns
Type Description
Mesh

Mesh.

| Improve this Doc View Source

TangentSolver(Mesh)

Solve tangents for the given mesh.

Declaration
public static void TangentSolver(Mesh mesh)
Parameters
Type Name Description
Mesh mesh

Mesh to solve tangents for.

Extension Methods

MBExtensions.Invoke(MonoBehaviour, Action, Single)
MBExtensions.Invoke<T>(MonoBehaviour, Action<T>, T, Single)
MBExtensions.Invoke<T1, T2>(MonoBehaviour, Action<T1, T2>, T1, T2, Single)
MBExtensions.Invoke<T1, T2, T3>(MonoBehaviour, Action<T1, T2, T3>, T1, T2, T3, Single)
MBExtensions.Invoke<T1, T2, T3, T4>(MonoBehaviour, Action<T1, T2, T3, T4>, T1, T2, T3, T4, Single)
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX