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;
|
|
|
|
|
internal List<string> TextureNames;
|
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; } }
|
|
|
|
|
internal Matrix Transform { get { return (General.Settings.GZStretchView ? transformstretched : transform); } }
|
|
|
|
|
internal bool OverridePalette; //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;
|
|
|
|
|
internal bool InheritActorRoll;
|
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>();
|
|
|
|
|
TextureNames = new List<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)
|
|
|
|
|
{
|
|
|
|
|
foreach (Mesh mesh in Model.Meshes) mesh.Dispose();
|
|
|
|
|
foreach (Texture t in Model.Textures) t.Dispose();
|
|
|
|
|
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;
|
2015-03-26 21:31:46 +00:00
|
|
|
|
this.transform = rotation * Matrix.Scaling(scale) * offset;
|
|
|
|
|
this.transformstretched = rotation * Matrix.Scaling(scale.X, scale.Y, scale.Z * Renderer3D.GZDOOM_INVERTED_VERTICAL_VIEW_STRETCH) * offset;
|
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
|
|
|
|
}
|