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;
|
2012-04-17 19:13:47 +00:00
|
|
|
|
using SlimDX;
|
|
|
|
|
using SlimDX.Direct3D9;
|
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
|
|
|
|
|
|
|
|
|
|
public static readonly string[] SUPPORTED_TEXTURE_EXTENSIONS = { ".jpg", ".tga", ".png", ".dds", ".pcx" };
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2014-12-11 12:55:35 +00:00
|
|
|
|
#region ================== Variables
|
|
|
|
|
|
|
|
|
|
private ModelLoadState loadstate;
|
2014-12-22 21:36:49 +00:00
|
|
|
|
private Vector3 scale;
|
|
|
|
|
private Matrix transform;
|
|
|
|
|
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;
|
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
|
|
|
|
|
2014-12-22 21:36:49 +00:00
|
|
|
|
internal Vector3 Scale { get { return scale; } }
|
2017-03-29 01:11:05 +00:00
|
|
|
|
internal Matrix Transform { get { /* return (General.Settings.GZStretchView ? transformstretched : transform); */ return transformstretched; } }
|
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;
|
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>();
|
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
|
|
|
|
|
2014-12-22 21:36:49 +00:00
|
|
|
|
internal void SetTransform(Matrix rotation, Matrix offset, Vector3 scale)
|
|
|
|
|
{
|
|
|
|
|
this.scale = 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
|
|
|
|
}
|