mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-02-07 16:31:34 +00:00
Added, Visual mode: thing sprites are now angle-dependent.
This commit is contained in:
parent
c861f8ecff
commit
c3392f8399
4 changed files with 325 additions and 265 deletions
|
@ -95,21 +95,16 @@ namespace CodeImp.DoomBuilder
|
||||||
|
|
||||||
#region ================== Methods
|
#region ================== Methods
|
||||||
|
|
||||||
public static void Write(string text)
|
public static void SetText(string text) { Write(DebugMessageType.INFO, text, false); } // Useful to display frequently updated text without flickering
|
||||||
{
|
public static void WriteLine(string text) { Write(DebugMessageType.INFO, text + Environment.NewLine, true); }
|
||||||
Write(DebugMessageType.INFO, text);
|
public static void WriteLine(DebugMessageType type, string text) { Write(type, text + Environment.NewLine, true); }
|
||||||
}
|
public static void Write(string text) { Write(DebugMessageType.INFO, text, true); }
|
||||||
|
public static void Write(DebugMessageType type, string text) { Write(type, text, true); }
|
||||||
public static void WriteLine(string text)
|
public static void Write(DebugMessageType type, string text, bool append)
|
||||||
{
|
|
||||||
Write(DebugMessageType.INFO, text + Environment.NewLine);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void Write(DebugMessageType type, string text)
|
|
||||||
{
|
{
|
||||||
if(me != null && me.InvokeRequired)
|
if(me != null && me.InvokeRequired)
|
||||||
{
|
{
|
||||||
me.Invoke(new Action<DebugMessageType, string>(Write), new object[] { type, text });
|
me.Invoke(new Action<DebugMessageType, string, bool>(Write), new object[] { type, text, append });
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -117,16 +112,11 @@ namespace CodeImp.DoomBuilder
|
||||||
messages.Add(new KeyValuePair<DebugMessageType, string>(type, text));
|
messages.Add(new KeyValuePair<DebugMessageType, string>(type, text));
|
||||||
if(me != null && (me.filters & type) == type)
|
if(me != null && (me.filters & type) == type)
|
||||||
{
|
{
|
||||||
me.AddMessage(type, text, true);
|
me.AddMessage(type, text, true, append);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void WriteLine(DebugMessageType type, string text)
|
|
||||||
{
|
|
||||||
Write(type, text + Environment.NewLine);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void Clear()
|
public static void Clear()
|
||||||
{
|
{
|
||||||
if(me != null && me.InvokeRequired)
|
if(me != null && me.InvokeRequired)
|
||||||
|
@ -226,12 +216,13 @@ namespace CodeImp.DoomBuilder
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddMessage(DebugMessageType type, string text, bool scroll)
|
private void AddMessage(DebugMessageType type, string text, bool scroll, bool append)
|
||||||
{
|
{
|
||||||
text = textheaders[type] + text;
|
text = textheaders[type] + text;
|
||||||
console.SelectionStart = console.TextLength;
|
console.SelectionStart = console.TextLength;
|
||||||
console.SelectionColor = textcolors[type];
|
console.SelectionColor = textcolors[type];
|
||||||
console.AppendText(text);
|
if(append) console.AppendText(text);
|
||||||
|
else console.Text = text;
|
||||||
if(scroll && autoscroll.Checked) console.ScrollToCaret();
|
if(scroll && autoscroll.Checked) console.ScrollToCaret();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,7 +248,7 @@ namespace CodeImp.DoomBuilder
|
||||||
{
|
{
|
||||||
if((filters & pair.Key) == pair.Key && CheckTextFilter(pair.Value, searchbox.Text))
|
if((filters & pair.Key) == pair.Key && CheckTextFilter(pair.Value, searchbox.Text))
|
||||||
{
|
{
|
||||||
AddMessage(pair.Key, pair.Value, false);
|
AddMessage(pair.Key, pair.Value, false, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1107,6 +1107,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
||||||
// Render things collected
|
// Render things collected
|
||||||
foreach(VisualThing t in thingspass)
|
foreach(VisualThing t in thingspass)
|
||||||
{
|
{
|
||||||
|
t.UpdateSpriteFrame(); // Set correct texture, geobuffer and triangles count
|
||||||
if(t.Texture is UnknownImage) continue;
|
if(t.Texture is UnknownImage) continue;
|
||||||
|
|
||||||
// Change blend mode?
|
// Change blend mode?
|
||||||
|
@ -1720,7 +1721,13 @@ namespace CodeImp.DoomBuilder.Rendering
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Gather regular things
|
// Gather regular things
|
||||||
else if(t.Texture != null) //Must have a texture!
|
else
|
||||||
|
{
|
||||||
|
//mxd. Set correct texture, geobuffer and triangles count
|
||||||
|
t.UpdateSpriteFrame();
|
||||||
|
|
||||||
|
//Must have a texture!
|
||||||
|
if(t.Texture != null)
|
||||||
{
|
{
|
||||||
//mxd
|
//mxd
|
||||||
switch(t.RenderPass)
|
switch(t.RenderPass)
|
||||||
|
@ -1744,6 +1751,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
||||||
throw new NotImplementedException("Thing rendering of " + t.RenderPass + " render pass is not implemented!");
|
throw new NotImplementedException("Thing rendering of " + t.RenderPass + " render pass is not implemented!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//mxd. Add to the plain list
|
//mxd. Add to the plain list
|
||||||
allthings.Add(t);
|
allthings.Add(t);
|
||||||
|
|
|
@ -48,17 +48,18 @@ namespace CodeImp.DoomBuilder.VisualModes
|
||||||
//mxd. Info
|
//mxd. Info
|
||||||
protected ThingTypeInfo info;
|
protected ThingTypeInfo info;
|
||||||
|
|
||||||
// Texture
|
// Textures
|
||||||
private ImageData texture;
|
protected ImageData[] textures;
|
||||||
|
|
||||||
// Geometry
|
// Geometry
|
||||||
private WorldVertex[] vertices;
|
private WorldVertex[][] vertices;
|
||||||
private VertexBuffer geobuffer;
|
private VertexBuffer[] geobuffers;
|
||||||
private VertexBuffer cagebuffer; //mxd
|
private VertexBuffer cagebuffer; //mxd
|
||||||
private int cagelength; //mxd
|
private int cagelength; //mxd
|
||||||
private bool updategeo;
|
private bool updategeo;
|
||||||
private bool updatecage; //mxd
|
private bool updatecage; //mxd
|
||||||
private int triangles;
|
private int[] triangles;
|
||||||
|
private int spriteframe; //mxd
|
||||||
|
|
||||||
// Rendering
|
// Rendering
|
||||||
private RenderPass renderpass;
|
private RenderPass renderpass;
|
||||||
|
@ -97,17 +98,17 @@ namespace CodeImp.DoomBuilder.VisualModes
|
||||||
|
|
||||||
#region ================== Properties
|
#region ================== Properties
|
||||||
|
|
||||||
internal VertexBuffer GeometryBuffer { get { return geobuffer; } }
|
internal VertexBuffer GeometryBuffer { get { return geobuffers[spriteframe]; } }
|
||||||
internal VertexBuffer CageBuffer { get { return cagebuffer; } } //mxd
|
internal VertexBuffer CageBuffer { get { return cagebuffer; } } //mxd
|
||||||
internal int CageLength { get { return cagelength; } } //mxd
|
internal int CageLength { get { return cagelength; } } //mxd
|
||||||
internal bool NeedsUpdateGeo { get { return updategeo; } }
|
internal bool NeedsUpdateGeo { get { return updategeo; } }
|
||||||
internal int Triangles { get { return triangles; } }
|
internal int Triangles { get { return triangles[spriteframe]; } }
|
||||||
internal Matrix Position { get { return position; } }
|
internal Matrix Position { get { return position; } }
|
||||||
internal Color4 CageColor { get { return cagecolor; } }
|
internal Color4 CageColor { get { return cagecolor; } }
|
||||||
public ThingTypeInfo Info { get { return info; } } //mxd
|
public ThingTypeInfo Info { get { return info; } } //mxd
|
||||||
|
|
||||||
//mxd
|
//mxd
|
||||||
internal int VertexColor { get { return vertices.Length > 0 ? vertices[0].c : 0;} }
|
internal int VertexColor { get { return vertices.Length > 0 && vertices[0].Length > 0 ? vertices[0][0].c : 0; } }
|
||||||
public int CameraDistance { get { return cameradistance; } }
|
public int CameraDistance { get { return cameradistance; } }
|
||||||
public float FogFactor { get { return fogfactor; } }
|
public float FogFactor { get { return fogfactor; } }
|
||||||
public Vector3 Center
|
public Vector3 Center
|
||||||
|
@ -142,7 +143,7 @@ namespace CodeImp.DoomBuilder.VisualModes
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Image to use as texture on the geometry.
|
/// Image to use as texture on the geometry.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ImageData Texture { get { return texture; } set { texture = value; } }
|
public ImageData Texture { get { return textures[spriteframe]; } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Disposed or not?
|
/// Disposed or not?
|
||||||
|
@ -186,8 +187,12 @@ namespace CodeImp.DoomBuilder.VisualModes
|
||||||
if(!isdisposed)
|
if(!isdisposed)
|
||||||
{
|
{
|
||||||
// Clean up
|
// Clean up
|
||||||
if(geobuffer != null) geobuffer.Dispose();
|
if(geobuffers != null) //mxd
|
||||||
geobuffer = null;
|
{
|
||||||
|
foreach(VertexBuffer buffer in geobuffers) buffer.Dispose();
|
||||||
|
geobuffers = null;
|
||||||
|
}
|
||||||
|
|
||||||
if(cagebuffer != null) cagebuffer.Dispose(); //mxd
|
if(cagebuffer != null) cagebuffer.Dispose(); //mxd
|
||||||
cagebuffer = null; //mxd
|
cagebuffer = null; //mxd
|
||||||
|
|
||||||
|
@ -213,8 +218,18 @@ namespace CodeImp.DoomBuilder.VisualModes
|
||||||
public void UnloadResource()
|
public void UnloadResource()
|
||||||
{
|
{
|
||||||
// Trash geometry buffers
|
// Trash geometry buffers
|
||||||
if(geobuffer != null) geobuffer.Dispose();
|
if(geobuffers != null) //mxd
|
||||||
geobuffer = null;
|
{
|
||||||
|
foreach(VertexBuffer buffer in geobuffers) buffer.Dispose();
|
||||||
|
geobuffers = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(textures != null) //mxd
|
||||||
|
{
|
||||||
|
foreach(ImageData texture in textures) texture.Dispose();
|
||||||
|
textures = null;
|
||||||
|
}
|
||||||
|
|
||||||
if(cagebuffer != null) cagebuffer.Dispose(); //mxd
|
if(cagebuffer != null) cagebuffer.Dispose(); //mxd
|
||||||
cagebuffer = null; //mxd
|
cagebuffer = null; //mxd
|
||||||
updategeo = true;
|
updategeo = true;
|
||||||
|
@ -256,17 +271,27 @@ namespace CodeImp.DoomBuilder.VisualModes
|
||||||
}
|
}
|
||||||
|
|
||||||
// This sets the vertices for the thing sprite
|
// This sets the vertices for the thing sprite
|
||||||
protected void SetVertices(ICollection<WorldVertex> verts, Plane floor, Plane ceiling)
|
protected void SetVertices(WorldVertex[][] verts, Plane floor, Plane ceiling)
|
||||||
{
|
{
|
||||||
// Copy vertices
|
// Copy vertices
|
||||||
vertices = new WorldVertex[verts.Count];
|
vertices = new WorldVertex[verts.Length][];
|
||||||
verts.CopyTo(vertices, 0);
|
triangles = new int[verts.Length];
|
||||||
triangles = vertices.Length / 3;
|
|
||||||
|
//mxd
|
||||||
|
for(int i = 0; i < verts.Length; i++)
|
||||||
|
{
|
||||||
|
vertices[i] = new WorldVertex[verts[i].Length];
|
||||||
|
verts[i].CopyTo(vertices[i], 0);
|
||||||
|
triangles[i] = vertices[i].Length / 3;
|
||||||
|
}
|
||||||
|
|
||||||
updategeo = true;
|
updategeo = true;
|
||||||
|
|
||||||
//mxd. Do some GLOOME shenanigans...
|
//mxd. Do some GLOOME shenanigans...
|
||||||
if(triangles < 2) return;
|
for(int c = 0; c < vertices.Length; c++)
|
||||||
float localcenterz = vertices[1].z * 0.5f;
|
{
|
||||||
|
if(triangles[c] < 2) continue;
|
||||||
|
float localcenterz = vertices[c][1].z * 0.5f;
|
||||||
Matrix m;
|
Matrix m;
|
||||||
|
|
||||||
switch(info.RenderMode)
|
switch(info.RenderMode)
|
||||||
|
@ -274,12 +299,12 @@ namespace CodeImp.DoomBuilder.VisualModes
|
||||||
// TODO: Currently broken in GLOOME...
|
// TODO: Currently broken in GLOOME...
|
||||||
case Thing.SpriteRenderMode.WALL_SPRITE:
|
case Thing.SpriteRenderMode.WALL_SPRITE:
|
||||||
m = Matrix.Translation(0f, 0f, -localcenterz) * Matrix.RotationY(Thing.RollRad) * Matrix.RotationZ(thing.Angle) * Matrix.Translation(0f, 0f, localcenterz);
|
m = Matrix.Translation(0f, 0f, -localcenterz) * Matrix.RotationY(Thing.RollRad) * Matrix.RotationZ(thing.Angle) * Matrix.Translation(0f, 0f, localcenterz);
|
||||||
for(int i = 0; i < vertices.Length; i++)
|
for(int i = 0; i < vertices[c].Length; i++)
|
||||||
{
|
{
|
||||||
Vector4 transformed = Vector3.Transform(new Vector3(vertices[i].x, vertices[i].y, vertices[i].z), m);
|
Vector4 transformed = Vector3.Transform(new Vector3(vertices[c][i].x, vertices[c][i].y, vertices[c][i].z), m);
|
||||||
vertices[i].x = transformed.X;
|
vertices[c][i].x = transformed.X;
|
||||||
vertices[i].y = transformed.Y;
|
vertices[c][i].y = transformed.Y;
|
||||||
vertices[i].z = transformed.Z;
|
vertices[c][i].z = transformed.Z;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -290,12 +315,12 @@ namespace CodeImp.DoomBuilder.VisualModes
|
||||||
|
|
||||||
m = Matrix.Translation(0f, 0f, -localcenterz) * floorrotation * Matrix.Translation(0f, 0f, localcenterz);
|
m = Matrix.Translation(0f, 0f, -localcenterz) * floorrotation * Matrix.Translation(0f, 0f, localcenterz);
|
||||||
|
|
||||||
for(int i = 0; i < vertices.Length; i++)
|
for(int i = 0; i < vertices[c].Length; i++)
|
||||||
{
|
{
|
||||||
Vector4 transformed = Vector3.Transform(new Vector3(vertices[i].x, vertices[i].y, vertices[i].z), m);
|
Vector4 transformed = Vector3.Transform(new Vector3(vertices[c][i].x, vertices[c][i].y, vertices[c][i].z), m);
|
||||||
vertices[i].x = transformed.X;
|
vertices[c][i].x = transformed.X;
|
||||||
vertices[i].y = transformed.Y;
|
vertices[c][i].y = transformed.Y;
|
||||||
vertices[i].z = transformed.Z;
|
vertices[c][i].z = transformed.Z;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: this won't work on things with AbsoluteZ flag
|
// TODO: this won't work on things with AbsoluteZ flag
|
||||||
|
@ -320,8 +345,8 @@ namespace CodeImp.DoomBuilder.VisualModes
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply it
|
// Apply it
|
||||||
for(int i = 0; i < vertices.Length; i++)
|
for(int i = 0; i < vertices[c].Length; i++)
|
||||||
vertices[i].z = floor.GetZ(vertices[i].x + Thing.Position.x, vertices[i].y + Thing.Position.y) + voffset;
|
vertices[c][i].z = floor.GetZ(vertices[c][i].x + Thing.Position.x, vertices[c][i].y + Thing.Position.y) + voffset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -333,12 +358,12 @@ namespace CodeImp.DoomBuilder.VisualModes
|
||||||
|
|
||||||
m = Matrix.Translation(0f, 0f, -localcenterz) * ceilrotation * Matrix.Translation(0f, 0f, localcenterz);
|
m = Matrix.Translation(0f, 0f, -localcenterz) * ceilrotation * Matrix.Translation(0f, 0f, localcenterz);
|
||||||
|
|
||||||
for(int i = 0; i < vertices.Length; i++)
|
for(int i = 0; i < vertices[c].Length; i++)
|
||||||
{
|
{
|
||||||
Vector4 transformed = Vector3.Transform(new Vector3(vertices[i].x, vertices[i].y, vertices[i].z), m);
|
Vector4 transformed = Vector3.Transform(new Vector3(vertices[c][i].x, vertices[c][i].y, vertices[c][i].z), m);
|
||||||
vertices[i].x = transformed.X;
|
vertices[c][i].x = transformed.X;
|
||||||
vertices[i].y = transformed.Y;
|
vertices[c][i].y = transformed.Y;
|
||||||
vertices[i].z = transformed.Z;
|
vertices[c][i].z = transformed.Z;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: this won't work on things with AbsoluteZ flag
|
// TODO: this won't work on things with AbsoluteZ flag
|
||||||
|
@ -363,8 +388,8 @@ namespace CodeImp.DoomBuilder.VisualModes
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply it
|
// Apply it
|
||||||
for(int i = 0; i < vertices.Length; i++)
|
for(int i = 0; i < vertices[c].Length; i++)
|
||||||
vertices[i].z = ceiling.GetZ(vertices[i].x + Thing.Position.x, vertices[i].y + Thing.Position.y) + voffset;
|
vertices[c][i].z = ceiling.GetZ(vertices[c][i].x + Thing.Position.x, vertices[c][i].y + Thing.Position.y) + voffset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -373,17 +398,18 @@ namespace CodeImp.DoomBuilder.VisualModes
|
||||||
if(info.RollSprite)
|
if(info.RollSprite)
|
||||||
{
|
{
|
||||||
m = Matrix.Translation(0f, 0f, -localcenterz) * Matrix.RotationY(Thing.RollRad) * Matrix.Translation(0f, 0f, localcenterz);
|
m = Matrix.Translation(0f, 0f, -localcenterz) * Matrix.RotationY(Thing.RollRad) * Matrix.Translation(0f, 0f, localcenterz);
|
||||||
for(int i = 0; i < vertices.Length; i++)
|
for(int i = 0; i < vertices[c].Length; i++)
|
||||||
{
|
{
|
||||||
Vector4 transformed = Vector3.Transform(new Vector3(vertices[i].x, vertices[i].y, vertices[i].z), m);
|
Vector4 transformed = Vector3.Transform(new Vector3(vertices[c][i].x, vertices[c][i].y, vertices[c][i].z), m);
|
||||||
vertices[i].x = transformed.X;
|
vertices[c][i].x = transformed.X;
|
||||||
vertices[i].y = transformed.Y;
|
vertices[c][i].y = transformed.Y;
|
||||||
vertices[i].z = transformed.Z;
|
vertices[c][i].z = transformed.Z;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// This updates the visual thing
|
// This updates the visual thing
|
||||||
public virtual void Update()
|
public virtual void Update()
|
||||||
|
@ -391,23 +417,27 @@ namespace CodeImp.DoomBuilder.VisualModes
|
||||||
// Do we need to update the geometry buffer?
|
// Do we need to update the geometry buffer?
|
||||||
if(updategeo)
|
if(updategeo)
|
||||||
{
|
{
|
||||||
// Trash geometry buffer
|
//mxd. Trash geometry buffers
|
||||||
if(geobuffer != null) geobuffer.Dispose();
|
if(geobuffers != null)
|
||||||
geobuffer = null;
|
foreach(VertexBuffer geobuffer in geobuffers) geobuffer.Dispose();
|
||||||
|
|
||||||
// Any vertics?
|
// Any vertics?
|
||||||
if(vertices.Length > 0)
|
if(vertices.Length > 0)
|
||||||
|
{
|
||||||
|
geobuffers = new VertexBuffer[vertices.Length];
|
||||||
|
for(int i = 0; i < vertices.Length; i++)
|
||||||
{
|
{
|
||||||
// Make a new buffer
|
// Make a new buffer
|
||||||
geobuffer = new VertexBuffer(General.Map.Graphics.Device, WorldVertex.Stride * vertices.Length,
|
geobuffers[i] = new VertexBuffer(General.Map.Graphics.Device, WorldVertex.Stride * vertices[i].Length,
|
||||||
Usage.WriteOnly | Usage.Dynamic, VertexFormat.None, Pool.Default);
|
Usage.WriteOnly | Usage.Dynamic, VertexFormat.None, Pool.Default);
|
||||||
|
|
||||||
// Fill the buffer
|
// Fill the buffer
|
||||||
DataStream bufferstream = geobuffer.Lock(0, WorldVertex.Stride * vertices.Length, LockFlags.Discard);
|
DataStream bufferstream = geobuffers[i].Lock(0, WorldVertex.Stride * vertices[i].Length, LockFlags.Discard);
|
||||||
bufferstream.WriteRange(vertices);
|
bufferstream.WriteRange(vertices[i]);
|
||||||
geobuffer.Unlock();
|
geobuffers[i].Unlock();
|
||||||
bufferstream.Dispose();
|
bufferstream.Dispose();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//mxd. Check if thing is light
|
//mxd. Check if thing is light
|
||||||
CheckLightState();
|
CheckLightState();
|
||||||
|
@ -708,6 +738,15 @@ namespace CodeImp.DoomBuilder.VisualModes
|
||||||
boundingBox[8] = new Vector3D(position_v3.X + width, position_v3.Y + width, Center.Z + h2);
|
boundingBox[8] = new Vector3D(position_v3.X + width, position_v3.Y + width, Center.Z + h2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//mxd. This updates the sprite frame to be rendered
|
||||||
|
internal void UpdateSpriteFrame()
|
||||||
|
{
|
||||||
|
if(textures.Length != 8)
|
||||||
|
spriteframe = 0;
|
||||||
|
else
|
||||||
|
spriteframe = (General.ClampAngle((int)Angle2D.RadToDeg((General.Map.VisualCamera.Position - thing.Position).GetAngleXY()) - thing.AngleDoom + 292)) / 45; // Convert to [0..7] range; 292 == 270 + 45/2
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This is called when the thing must be tested for line intersection. This should reject
|
/// This is called when the thing must be tested for line intersection. This should reject
|
||||||
/// as fast as possible to rule out all geometry that certainly does not touch the line.
|
/// as fast as possible to rule out all geometry that certainly does not touch the line.
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
|
|
||||||
private bool isloaded;
|
private bool isloaded;
|
||||||
private bool nointeraction; //mxd
|
private bool nointeraction; //mxd
|
||||||
private ImageData sprite;
|
private ImageData[] sprites;
|
||||||
private float cageradius2;
|
private float cageradius2;
|
||||||
private Vector2D pos2d;
|
private Vector2D pos2d;
|
||||||
private Vector3D boxp1;
|
private Vector3D boxp1;
|
||||||
|
@ -76,11 +76,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
//mxd. When true, the thing can be moved below floor/above ceiling
|
//mxd. When true, the thing can be moved below floor/above ceiling
|
||||||
nointeraction = (info.Actor != null && info.Actor.GetFlagValue("nointeraction", false));
|
nointeraction = (info.Actor != null && info.Actor.GetFlagValue("nointeraction", false));
|
||||||
|
|
||||||
// Find sprite texture
|
//mxd. Find sprite textures
|
||||||
if(info.Sprite.Length > 0)
|
sprites = new ImageData[info.SpriteFrame.Length];
|
||||||
|
for(int i = 0; i < info.SpriteFrame.Length; i++)
|
||||||
{
|
{
|
||||||
sprite = General.Map.Data.GetSpriteImage(info.Sprite);
|
sprites[i] = General.Map.Data.GetSpriteImage(info.SpriteFrame[i].Sprite);
|
||||||
if(sprite != null) sprite.AddReference();
|
if(sprites[i] != null) sprites[i].AddReference();
|
||||||
}
|
}
|
||||||
|
|
||||||
//mxd
|
//mxd
|
||||||
|
@ -191,8 +192,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
sizeless = false;
|
sizeless = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sprite != null)
|
|
||||||
{
|
|
||||||
Plane floor = new Plane(); //mxd
|
Plane floor = new Plane(); //mxd
|
||||||
Plane ceiling = new Plane(); //mxd
|
Plane ceiling = new Plane(); //mxd
|
||||||
if(Thing.Sector != null)
|
if(Thing.Sector != null)
|
||||||
|
@ -274,7 +273,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//mxd. Create verts for all sprite angles
|
||||||
|
WorldVertex[][] allverts = new WorldVertex[info.SpriteFrame.Length][];
|
||||||
|
base.textures = new ImageData[info.SpriteFrame.Length];
|
||||||
|
|
||||||
|
for(int i = 0; i < sprites.Length; i++)
|
||||||
|
{
|
||||||
// Check if the texture is loaded
|
// Check if the texture is loaded
|
||||||
|
ImageData sprite = sprites[i];
|
||||||
sprite.LoadImage();
|
sprite.LoadImage();
|
||||||
isloaded = sprite.IsImageLoaded;
|
isloaded = sprite.IsImageLoaded;
|
||||||
if(isloaded)
|
if(isloaded)
|
||||||
|
@ -282,7 +288,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
float offsetx = 0.0f;
|
float offsetx = 0.0f;
|
||||||
float offsety = 0.0f;
|
float offsety = 0.0f;
|
||||||
|
|
||||||
base.Texture = sprite;
|
base.textures[i] = sprite;
|
||||||
|
|
||||||
// Determine sprite size and offset
|
// Determine sprite size and offset
|
||||||
float radius = sprite.ScaledWidth * 0.5f;
|
float radius = sprite.ScaledWidth * 0.5f;
|
||||||
|
@ -304,30 +310,34 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
// Make vertices
|
// Make vertices
|
||||||
WorldVertex[] verts = new WorldVertex[6];
|
WorldVertex[] verts = new WorldVertex[6];
|
||||||
|
|
||||||
|
//mxd. Sprite mirroring
|
||||||
|
float ul = (info.SpriteFrame[i].Mirror ? 1f : 0f);
|
||||||
|
float ur = (info.SpriteFrame[i].Mirror ? 0f : 1f);
|
||||||
|
|
||||||
if(sizeless) //mxd
|
if(sizeless) //mxd
|
||||||
{
|
{
|
||||||
float hh = height / 2;
|
float hh = height / 2;
|
||||||
verts[0] = new WorldVertex(-radius + offsetx, 0.0f, offsety - hh, sectorcolor, 0.0f, 1.0f);
|
verts[0] = new WorldVertex(-radius + offsetx, 0.0f, offsety - hh, sectorcolor, ul, 1.0f);
|
||||||
verts[1] = new WorldVertex(-radius + offsetx, 0.0f, hh + offsety, sectorcolor, 0.0f, 0.0f);
|
verts[1] = new WorldVertex(-radius + offsetx, 0.0f, hh + offsety, sectorcolor, ul, 0.0f);
|
||||||
verts[2] = new WorldVertex(+radius + offsetx, 0.0f, hh + offsety, sectorcolor, 1.0f, 0.0f);
|
verts[2] = new WorldVertex(+radius + offsetx, 0.0f, hh + offsety, sectorcolor, ur, 0.0f);
|
||||||
verts[3] = verts[0];
|
verts[3] = verts[0];
|
||||||
verts[4] = verts[2];
|
verts[4] = verts[2];
|
||||||
verts[5] = new WorldVertex(+radius + offsetx, 0.0f, offsety - hh, sectorcolor, 1.0f, 1.0f);
|
verts[5] = new WorldVertex(+radius + offsetx, 0.0f, offsety - hh, sectorcolor, ur, 1.0f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
verts[0] = new WorldVertex(-radius + offsetx, 0.0f, offsety, sectorcolor, 0.0f, 1.0f);
|
verts[0] = new WorldVertex(-radius + offsetx, 0.0f, offsety, sectorcolor, ul, 1.0f);
|
||||||
verts[1] = new WorldVertex(-radius + offsetx, 0.0f, height + offsety, sectorcolor, 0.0f, 0.0f);
|
verts[1] = new WorldVertex(-radius + offsetx, 0.0f, height + offsety, sectorcolor, ul, 0.0f);
|
||||||
verts[2] = new WorldVertex(+radius + offsetx, 0.0f, height + offsety, sectorcolor, 1.0f, 0.0f);
|
verts[2] = new WorldVertex(+radius + offsetx, 0.0f, height + offsety, sectorcolor, ur, 0.0f);
|
||||||
verts[3] = verts[0];
|
verts[3] = verts[0];
|
||||||
verts[4] = verts[2];
|
verts[4] = verts[2];
|
||||||
verts[5] = new WorldVertex(+radius + offsetx, 0.0f, offsety, sectorcolor, 1.0f, 1.0f);
|
verts[5] = new WorldVertex(+radius + offsetx, 0.0f, offsety, sectorcolor, ur, 1.0f);
|
||||||
}
|
}
|
||||||
SetVertices(verts, floor, ceiling);
|
allverts[i] = verts;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
base.Texture = General.Map.Data.Hourglass3D;
|
base.textures[i] = General.Map.Data.Hourglass3D;
|
||||||
|
|
||||||
// Determine sprite size
|
// Determine sprite size
|
||||||
float radius = Math.Min(thingradius, thingheight / 2f);
|
float radius = Math.Min(thingradius, thingheight / 2f);
|
||||||
|
@ -341,10 +351,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
verts[3] = verts[0];
|
verts[3] = verts[0];
|
||||||
verts[4] = verts[2];
|
verts[4] = verts[2];
|
||||||
verts[5] = new WorldVertex(+radius, 0.0f, 0.0f, sectorcolor, 1.0f, 1.0f);
|
verts[5] = new WorldVertex(+radius, 0.0f, 0.0f, sectorcolor, 1.0f, 1.0f);
|
||||||
SetVertices(verts, floor, ceiling);
|
allverts[i] = verts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//mxd
|
||||||
|
SetVertices(allverts, floor, ceiling);
|
||||||
|
|
||||||
// Determine position
|
// Determine position
|
||||||
Vector3D pos = Thing.Position;
|
Vector3D pos = Thing.Position;
|
||||||
if(Thing.Type == 9501)
|
if(Thing.Type == 9501)
|
||||||
|
@ -439,10 +452,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
{
|
{
|
||||||
if(!IsDisposed)
|
if(!IsDisposed)
|
||||||
{
|
{
|
||||||
if(sprite != null)
|
if(sprites != null) //mxd
|
||||||
{
|
{
|
||||||
sprite.RemoveReference();
|
foreach(ImageData sprite in sprites) sprite.RemoveReference();
|
||||||
sprite = null;
|
sprites = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
base.Dispose();
|
base.Dispose();
|
||||||
|
@ -462,11 +475,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
//mxd. When true, the thing can be moved below floor/above ceiling
|
//mxd. When true, the thing can be moved below floor/above ceiling
|
||||||
nointeraction = (info.Actor != null && info.Actor.GetFlagValue("nointeraction", false));
|
nointeraction = (info.Actor != null && info.Actor.GetFlagValue("nointeraction", false));
|
||||||
|
|
||||||
// Find sprite texture
|
//mxd. Find sprite textures
|
||||||
if(info.Sprite.Length > 0)
|
sprites = new ImageData[info.SpriteFrame.Length];
|
||||||
|
for(int i = 0; i < info.SpriteFrame.Length; i++)
|
||||||
{
|
{
|
||||||
sprite = General.Map.Data.GetSpriteImage(info.Sprite);
|
sprites[i] = General.Map.Data.GetSpriteImage(info.SpriteFrame[i].Sprite);
|
||||||
if(sprite != null) sprite.AddReference();
|
if(sprites[i] != null) sprites[i].AddReference();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup visual thing
|
// Setup visual thing
|
||||||
|
@ -478,13 +492,20 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
{
|
{
|
||||||
if(!isloaded)
|
if(!isloaded)
|
||||||
{
|
{
|
||||||
// Rebuild sprite geometry when sprite is loaded
|
//mxd. Rebuild sprite geometry when all sprites are loaded
|
||||||
if(sprite.IsImageLoaded)
|
bool allloaded = true;
|
||||||
|
foreach(ImageData sprite in sprites)
|
||||||
{
|
{
|
||||||
Setup();
|
if(!sprite.IsImageLoaded)
|
||||||
|
{
|
||||||
|
allloaded = false;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(allloaded) Setup();
|
||||||
|
}
|
||||||
|
|
||||||
// Let the base update
|
// Let the base update
|
||||||
base.Update();
|
base.Update();
|
||||||
}
|
}
|
||||||
|
@ -757,13 +778,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
//mxd
|
//mxd
|
||||||
public void OnChangeScale(int incrementX, int incrementY)
|
public void OnChangeScale(int incrementX, int incrementY)
|
||||||
{
|
{
|
||||||
if(!General.Map.UDMF || !sprite.IsImageLoaded) return;
|
if(!General.Map.UDMF || sprites == null || !sprites[0].IsImageLoaded) return;
|
||||||
|
|
||||||
if((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket))
|
if((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket))
|
||||||
undoticket = mode.CreateUndo("Change thing scale");
|
undoticket = mode.CreateUndo("Change thing scale");
|
||||||
|
|
||||||
float scaleX = Thing.ScaleX;
|
float scaleX = Thing.ScaleX;
|
||||||
float scaleY = Thing.ScaleY;
|
float scaleY = Thing.ScaleY;
|
||||||
|
ImageData sprite = sprites[0];
|
||||||
|
|
||||||
if(incrementX != 0)
|
if(incrementX != 0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue