2014-12-11 12:55:35 +00:00
|
|
|
|
#region ================== Namespaces
|
|
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using CodeImp.DoomBuilder.GZBuilder.MD3;
|
2014-12-22 21:36:49 +00:00
|
|
|
|
using CodeImp.DoomBuilder.Rendering;
|
2014-12-11 12:55:35 +00:00
|
|
|
|
|
|
|
|
|
#endregion
|
2012-04-17 19:13:47 +00:00
|
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.GZBuilder.Data
|
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
|
internal sealed class ModelData
|
|
|
|
|
{
|
2015-12-17 10:07:28 +00:00
|
|
|
|
#region ================== Constants
|
|
|
|
|
|
2019-06-15 15:44:02 +00:00
|
|
|
|
// Keep sage order of extensions as in GZDoom's r_data\models\models.cpp FindGFXFile function. That doesn't
|
|
|
|
|
// list .dds, but just keep it in here
|
|
|
|
|
public static readonly string[] SUPPORTED_TEXTURE_EXTENSIONS = { ".png", ".jpg", ".tga", ".pcx", ".dds" };
|
2015-12-17 10:07:28 +00:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2014-12-11 12:55:35 +00:00
|
|
|
|
#region ================== Variables
|
|
|
|
|
|
|
|
|
|
private ModelLoadState loadstate;
|
2020-01-03 01:22:33 +00:00
|
|
|
|
private Vector3f scale;
|
2022-10-21 18:29:30 +00:00
|
|
|
|
private Vector3f rotationcenter;
|
2014-12-22 21:36:49 +00:00
|
|
|
|
private Matrix transform;
|
2018-05-27 05:53:54 +00:00
|
|
|
|
private Matrix transformrotation;
|
2014-12-22 21:36:49 +00:00
|
|
|
|
private Matrix transformstretched;
|
2014-12-11 12:55:35 +00:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Properties
|
|
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
|
internal List<string> ModelNames;
|
2016-07-18 12:05:19 +00:00
|
|
|
|
internal List<string> SkinNames;
|
|
|
|
|
internal List<Dictionary<int, string>> SurfaceSkinNames;
|
2015-11-17 12:22:49 +00:00
|
|
|
|
internal List<string> FrameNames;
|
|
|
|
|
internal List<int> FrameIndices;
|
2019-06-16 16:40:10 +00:00
|
|
|
|
internal string Path; // biwa
|
2012-04-17 19:13:47 +00:00
|
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
|
internal GZModel Model;
|
2012-04-17 19:13:47 +00:00
|
|
|
|
|
2020-01-03 01:22:33 +00:00
|
|
|
|
internal Vector3f Scale { get { return scale; } }
|
2022-10-21 18:29:30 +00:00
|
|
|
|
internal Vector3f RotationCenter { get { return rotationcenter; } set { rotationcenter = value; } }
|
2017-03-29 01:11:05 +00:00
|
|
|
|
internal Matrix Transform { get { /* return (General.Settings.GZStretchView ? transformstretched : transform); */ return transformstretched; } }
|
2018-05-27 05:53:54 +00:00
|
|
|
|
internal Matrix TransformRotation { get { return transformrotation; } }
|
2016-07-11 22:13:43 +00:00
|
|
|
|
internal bool OverridePalette; // Used for voxel models only
|
|
|
|
|
internal float AngleOffset; // Used for voxel models only
|
Model rendering (all modes): UDMF scale, pitch and roll are now displayed.
Thing Edit Form, UDMF: added controls for setting pitch, roll, scale, render style, fill color, alpha, health and score.
Visual mode, UDMF: UDMF scale is now applied when rendering sprites.
Added Thing Statistics form (Edit -> View Thing Types...), which shows all loaded thing types with some additional info.
Visual mode: sprites with negative ScaleX and positive ScaleY were not rendered properly.
Classic modes: display was not updated after loading a sprite.
Current testing engine change was not saved on closing the program when no other game configuration settings were changed.
2014-04-30 10:01:22 +00:00
|
|
|
|
internal bool InheritActorPitch;
|
2016-07-17 00:00:29 +00:00
|
|
|
|
internal bool UseActorPitch;
|
|
|
|
|
internal bool UseActorRoll;
|
2022-10-21 18:29:30 +00:00
|
|
|
|
internal bool UseRotationCenter;
|
2012-07-28 20:36:28 +00:00
|
|
|
|
|
2014-12-11 12:55:35 +00:00
|
|
|
|
internal bool IsVoxel;
|
|
|
|
|
|
2015-10-02 14:47:34 +00:00
|
|
|
|
// Hashing
|
|
|
|
|
private static int hashcounter;
|
|
|
|
|
private readonly int hashcode;
|
|
|
|
|
|
2015-09-16 12:10:43 +00:00
|
|
|
|
// Disposing
|
|
|
|
|
private bool isdisposed;
|
|
|
|
|
|
2014-12-11 12:55:35 +00:00
|
|
|
|
public ModelLoadState LoadState { get { return loadstate; } internal set { loadstate = value; } }
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Constructor / Disposer
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
internal ModelData()
|
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
|
ModelNames = new List<string>();
|
2016-07-18 12:05:19 +00:00
|
|
|
|
SkinNames = new List<string>();
|
|
|
|
|
SurfaceSkinNames = new List<Dictionary<int, string>>();
|
2015-11-17 12:22:49 +00:00
|
|
|
|
FrameNames = new List<string>();
|
|
|
|
|
FrameIndices = new List<int>();
|
2019-06-16 16:40:10 +00:00
|
|
|
|
Path = string.Empty;
|
2014-12-22 21:36:49 +00:00
|
|
|
|
transform = Matrix.Identity;
|
|
|
|
|
transformstretched = Matrix.Identity;
|
2015-10-02 14:47:34 +00:00
|
|
|
|
hashcode = hashcounter++;
|
2013-09-11 09:47:53 +00:00
|
|
|
|
}
|
2012-05-21 23:51:32 +00:00
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
internal void Dispose()
|
|
|
|
|
{
|
2015-09-16 12:10:43 +00:00
|
|
|
|
// Not already disposed?
|
|
|
|
|
if(!isdisposed)
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2015-09-16 12:10:43 +00:00
|
|
|
|
// Clean up
|
|
|
|
|
if(Model != null)
|
|
|
|
|
{
|
2015-12-28 15:01:53 +00:00
|
|
|
|
foreach(Mesh mesh in Model.Meshes) mesh.Dispose();
|
|
|
|
|
foreach(Texture t in Model.Textures) t.Dispose();
|
2015-09-16 12:10:43 +00:00
|
|
|
|
loadstate = ModelLoadState.None;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Done
|
|
|
|
|
isdisposed = true;
|
2013-09-11 09:47:53 +00:00
|
|
|
|
}
|
2013-07-29 08:50:50 +00:00
|
|
|
|
}
|
2014-12-11 12:55:35 +00:00
|
|
|
|
|
2020-01-03 01:22:33 +00:00
|
|
|
|
internal void SetTransform(Matrix rotation, Matrix offset, Vector3f scale)
|
2014-12-22 21:36:49 +00:00
|
|
|
|
{
|
|
|
|
|
this.scale = scale;
|
2018-05-27 05:53:54 +00:00
|
|
|
|
transformrotation = rotation * Matrix.Scaling(scale);
|
2016-07-17 00:00:29 +00:00
|
|
|
|
transform = rotation * Matrix.Scaling(scale) * offset;
|
2017-08-27 05:09:28 +00:00
|
|
|
|
transformstretched = Matrix.Scaling(1.0f, 1.0f, General.Map.Data.InvertedVerticalViewStretch) * transform;
|
2014-12-22 21:36:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-10-02 14:47:34 +00:00
|
|
|
|
//mxd. This greatly speeds up Dictionary lookups
|
|
|
|
|
public override int GetHashCode()
|
|
|
|
|
{
|
|
|
|
|
return hashcode;
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-11 12:55:35 +00:00
|
|
|
|
#endregion
|
2013-07-29 08:50:50 +00:00
|
|
|
|
}
|
2012-04-17 19:13:47 +00:00
|
|
|
|
}
|