From 9f507eb1b3ba8212f1d5cea2e9ab3cd859e9f1be Mon Sep 17 00:00:00 2001 From: igorseabra4 Date: Tue, 30 Aug 2022 20:21:34 -0300 Subject: [PATCH] bug fixes --- .../DynaTypes/RenderableDynas/DynaPointer.cs | 41 +++++++++++++++++-- .../Assets/Models/AssetRenderWareModel.cs | 14 ++++++- IndustrialPark/Assets/Shared/EntityAsset.cs | 6 +-- IndustrialPark/MainForm/MainForm.cs | 2 +- IndustrialPark/SharpDX/TextureManager.cs | 1 - 5 files changed, 55 insertions(+), 9 deletions(-) diff --git a/IndustrialPark/Assets/DYNA/DynaTypes/RenderableDynas/DynaPointer.cs b/IndustrialPark/Assets/DYNA/DynaTypes/RenderableDynas/DynaPointer.cs index 4c66d575..999f25c1 100644 --- a/IndustrialPark/Assets/DYNA/DynaTypes/RenderableDynas/DynaPointer.cs +++ b/IndustrialPark/Assets/DYNA/DynaTypes/RenderableDynas/DynaPointer.cs @@ -2,14 +2,49 @@ using IndustrialPark.Models; using SharpDX; using System.Collections.Generic; +using System.ComponentModel; using static IndustrialPark.ArchiveEditorFunctions; namespace IndustrialPark { - public class DynaPointer : RenderableRotatableDynaBase + public class DynaPointer : RenderableDynaBase, IRotatableAsset { - private const string dynaCategoryName = "pointer"; - public override string TypeString => dynaCategoryName; + private const string dynaCategoryName1 = "DYNA Placement"; + + protected float _yaw; + [Category(dynaCategoryName1)] + public AssetSingle Yaw + { + get => _yaw; + set { _yaw = value; CreateTransformMatrix(); } + } + + protected float _pitch; + [Category(dynaCategoryName1)] + public AssetSingle Pitch + { + get => _pitch; + set { _pitch = value; CreateTransformMatrix(); } + } + + protected float _roll; + [Category(dynaCategoryName1)] + public AssetSingle Roll + { + get => _roll; + set { _roll = value; CreateTransformMatrix(); } + } + + public override void CreateTransformMatrix() + { + world = Matrix.RotationYawPitchRoll( + MathUtil.DegreesToRadians(_yaw), + MathUtil.DegreesToRadians(_pitch), + MathUtil.DegreesToRadians(_roll)) * Matrix.Translation(_position); + CreateBoundingBox(); + } + + public override string TypeString => "pointer"; protected override short constVersion => 1; diff --git a/IndustrialPark/Assets/Models/AssetRenderWareModel.cs b/IndustrialPark/Assets/Models/AssetRenderWareModel.cs index d06b8b73..bd852c4d 100644 --- a/IndustrialPark/Assets/Models/AssetRenderWareModel.cs +++ b/IndustrialPark/Assets/Models/AssetRenderWareModel.cs @@ -58,7 +58,7 @@ public virtual void Setup(SharpRenderer renderer) public RenderWareModelFile GetRenderWareModelFile() => model; - [Category("Model Data"), Description("If IsNativeData is true, you cannot use the Export function.")] + [Browsable(false)] public bool IsNativeData => model != null && model.isNativeData; [Browsable(false)] @@ -70,6 +70,7 @@ public string[] Textures foreach (RWSection rws in ModelAsRWSections) if (rws is Clump_0010 clump) + { foreach (Geometry_000F geo in clump.geometryList.geometryList) if (geo.materialList != null) if (geo.materialList.materialList != null) @@ -78,6 +79,17 @@ public string[] Textures if (mat.texture.diffuseTextureName != null) if (!names.Contains(mat.texture.diffuseTextureName.stringString)) names.Add(mat.texture.diffuseTextureName.stringString); + } + else if (rws is World_000B world) + { + if (world.materialList != null) + if (world.materialList.materialList != null) + foreach (Material_0007 mat in world.materialList.materialList) + if (mat.texture != null) + if (mat.texture.diffuseTextureName != null) + if (!names.Contains(mat.texture.diffuseTextureName.stringString)) + names.Add(mat.texture.diffuseTextureName.stringString); + } return names.ToArray(); } diff --git a/IndustrialPark/Assets/Shared/EntityAsset.cs b/IndustrialPark/Assets/Shared/EntityAsset.cs index 61aa7927..708fe65f 100644 --- a/IndustrialPark/Assets/Shared/EntityAsset.cs +++ b/IndustrialPark/Assets/Shared/EntityAsset.cs @@ -51,7 +51,7 @@ public virtual AssetSingle PositionZ set { _position.Z = value; CreateTransformMatrix(); } } - protected AssetSingle _yaw; + protected float _yaw; [Category(categoryName)] public AssetSingle Yaw { @@ -59,7 +59,7 @@ public AssetSingle Yaw set { _yaw = MathUtil.DegreesToRadians(value); CreateTransformMatrix(); } } - protected AssetSingle _pitch; + protected float _pitch; [Category(categoryName)] public AssetSingle Pitch { @@ -67,7 +67,7 @@ public AssetSingle Pitch set { _pitch = MathUtil.DegreesToRadians(value); CreateTransformMatrix(); } } - protected AssetSingle _roll; + protected float _roll; [Category(categoryName)] public AssetSingle Roll { diff --git a/IndustrialPark/MainForm/MainForm.cs b/IndustrialPark/MainForm/MainForm.cs index e5a45fdf..96480fd3 100644 --- a/IndustrialPark/MainForm/MainForm.cs +++ b/IndustrialPark/MainForm/MainForm.cs @@ -1214,7 +1214,7 @@ private void SetAssetViewToolStripMenuItems(IEnumerable assetTypes) names.Add(assetType, text); } - foreach (var entry in names.OrderBy(f => f.Value.ToString())) + foreach (var entry in names.OrderBy(f => f.Value)) { var field = assetViewTypes[entry.Key].GetField("dontRender"); var dontRender = (bool)field.GetValue(null); diff --git a/IndustrialPark/SharpDX/TextureManager.cs b/IndustrialPark/SharpDX/TextureManager.cs index e14fc01b..580ce775 100644 --- a/IndustrialPark/SharpDX/TextureManager.cs +++ b/IndustrialPark/SharpDX/TextureManager.cs @@ -39,7 +39,6 @@ public static ShaderResourceView GetTextureFromDictionary(uint assetID) foreach (string s in Textures.Keys) if (Functions.BKDRHash(s) == assetID) return Textures[s]; - return SharpRenderer.whiteDefault; }