Class MeshReader
Imports Daggerfall models into Unity as Mesh objects. Should only be attached to DaggerfallUnity (for which it is a required component).
Namespace: DaggerfallWorkshop
Assembly: Assembly-CSharp.dll
Syntax
[RequireComponent(typeof(DaggerfallUnity))]
public class MeshReader : MonoBehaviour
Fields
| Improve this Doc View SourceAddMeshLightmapUVs
Declaration
public bool AddMeshLightmapUVs
Field Value
Type | Description |
---|---|
Boolean |
AddMeshTangents
Declaration
public bool AddMeshTangents
Field Value
Type | Description |
---|---|
Boolean |
GlobalScale
Declaration
public const float GlobalScale = 0.025F
Field Value
Type | Description |
---|---|
Single |
Properties
| Improve this Doc View SourceIsReady
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 SourceClearCache()
Clears model cache dictionary, forcing models to reload.
Declaration
public void ClearCache()
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |