mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-31 12:50:52 +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
|
||||
|
||||
public static void Write(string text)
|
||||
{
|
||||
Write(DebugMessageType.INFO, text);
|
||||
}
|
||||
|
||||
public static void WriteLine(string text)
|
||||
{
|
||||
Write(DebugMessageType.INFO, text + Environment.NewLine);
|
||||
}
|
||||
|
||||
public static void Write(DebugMessageType type, 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); }
|
||||
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 Write(DebugMessageType type, string text, bool append)
|
||||
{
|
||||
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
|
||||
{
|
||||
|
@ -117,16 +112,11 @@ namespace CodeImp.DoomBuilder
|
|||
messages.Add(new KeyValuePair<DebugMessageType, string>(type, text));
|
||||
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()
|
||||
{
|
||||
if(me != null && me.InvokeRequired)
|
||||
|
@ -226,12 +216,13 @@ namespace CodeImp.DoomBuilder
|
|||
#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;
|
||||
console.SelectionStart = console.TextLength;
|
||||
console.SelectionColor = textcolors[type];
|
||||
console.AppendText(text);
|
||||
if(append) console.AppendText(text);
|
||||
else console.Text = text;
|
||||
if(scroll && autoscroll.Checked) console.ScrollToCaret();
|
||||
}
|
||||
|
||||
|
@ -257,7 +248,7 @@ namespace CodeImp.DoomBuilder
|
|||
{
|
||||
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
|
||||
foreach(VisualThing t in thingspass)
|
||||
{
|
||||
t.UpdateSpriteFrame(); // Set correct texture, geobuffer and triangles count
|
||||
if(t.Texture is UnknownImage) continue;
|
||||
|
||||
// Change blend mode?
|
||||
|
@ -1720,7 +1721,13 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
}
|
||||
}
|
||||
// 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
|
||||
switch(t.RenderPass)
|
||||
|
@ -1744,6 +1751,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
throw new NotImplementedException("Thing rendering of " + t.RenderPass + " render pass is not implemented!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//mxd. Add to the plain list
|
||||
allthings.Add(t);
|
||||
|
|
|
@ -48,17 +48,18 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
//mxd. Info
|
||||
protected ThingTypeInfo info;
|
||||
|
||||
// Texture
|
||||
private ImageData texture;
|
||||
// Textures
|
||||
protected ImageData[] textures;
|
||||
|
||||
// Geometry
|
||||
private WorldVertex[] vertices;
|
||||
private VertexBuffer geobuffer;
|
||||
private WorldVertex[][] vertices;
|
||||
private VertexBuffer[] geobuffers;
|
||||
private VertexBuffer cagebuffer; //mxd
|
||||
private int cagelength; //mxd
|
||||
private bool updategeo;
|
||||
private bool updatecage; //mxd
|
||||
private int triangles;
|
||||
private int[] triangles;
|
||||
private int spriteframe; //mxd
|
||||
|
||||
// Rendering
|
||||
private RenderPass renderpass;
|
||||
|
@ -97,17 +98,17 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
|
||||
#region ================== Properties
|
||||
|
||||
internal VertexBuffer GeometryBuffer { get { return geobuffer; } }
|
||||
internal VertexBuffer GeometryBuffer { get { return geobuffers[spriteframe]; } }
|
||||
internal VertexBuffer CageBuffer { get { return cagebuffer; } } //mxd
|
||||
internal int CageLength { get { return cagelength; } } //mxd
|
||||
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 Color4 CageColor { get { return cagecolor; } }
|
||||
public ThingTypeInfo Info { get { return info; } } //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 float FogFactor { get { return fogfactor; } }
|
||||
public Vector3 Center
|
||||
|
@ -142,7 +143,7 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
/// <summary>
|
||||
/// Image to use as texture on the geometry.
|
||||
/// </summary>
|
||||
public ImageData Texture { get { return texture; } set { texture = value; } }
|
||||
public ImageData Texture { get { return textures[spriteframe]; } }
|
||||
|
||||
/// <summary>
|
||||
/// Disposed or not?
|
||||
|
@ -186,8 +187,12 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
if(!isdisposed)
|
||||
{
|
||||
// Clean up
|
||||
if(geobuffer != null) geobuffer.Dispose();
|
||||
geobuffer = null;
|
||||
if(geobuffers != null) //mxd
|
||||
{
|
||||
foreach(VertexBuffer buffer in geobuffers) buffer.Dispose();
|
||||
geobuffers = null;
|
||||
}
|
||||
|
||||
if(cagebuffer != null) cagebuffer.Dispose(); //mxd
|
||||
cagebuffer = null; //mxd
|
||||
|
||||
|
@ -213,8 +218,18 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
public void UnloadResource()
|
||||
{
|
||||
// Trash geometry buffers
|
||||
if(geobuffer != null) geobuffer.Dispose();
|
||||
geobuffer = null;
|
||||
if(geobuffers != null) //mxd
|
||||
{
|
||||
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
|
||||
cagebuffer = null; //mxd
|
||||
updategeo = true;
|
||||
|
@ -256,17 +271,27 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
}
|
||||
|
||||
// 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
|
||||
vertices = new WorldVertex[verts.Count];
|
||||
verts.CopyTo(vertices, 0);
|
||||
triangles = vertices.Length / 3;
|
||||
vertices = new WorldVertex[verts.Length][];
|
||||
triangles = new int[verts.Length];
|
||||
|
||||
//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;
|
||||
|
||||
//mxd. Do some GLOOME shenanigans...
|
||||
if(triangles < 2) return;
|
||||
float localcenterz = vertices[1].z * 0.5f;
|
||||
for(int c = 0; c < vertices.Length; c++)
|
||||
{
|
||||
if(triangles[c] < 2) continue;
|
||||
float localcenterz = vertices[c][1].z * 0.5f;
|
||||
Matrix m;
|
||||
|
||||
switch(info.RenderMode)
|
||||
|
@ -274,12 +299,12 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
// TODO: Currently broken in GLOOME...
|
||||
case Thing.SpriteRenderMode.WALL_SPRITE:
|
||||
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);
|
||||
vertices[i].x = transformed.X;
|
||||
vertices[i].y = transformed.Y;
|
||||
vertices[i].z = transformed.Z;
|
||||
Vector4 transformed = Vector3.Transform(new Vector3(vertices[c][i].x, vertices[c][i].y, vertices[c][i].z), m);
|
||||
vertices[c][i].x = transformed.X;
|
||||
vertices[c][i].y = transformed.Y;
|
||||
vertices[c][i].z = transformed.Z;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -290,12 +315,12 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
|
||||
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);
|
||||
vertices[i].x = transformed.X;
|
||||
vertices[i].y = transformed.Y;
|
||||
vertices[i].z = transformed.Z;
|
||||
Vector4 transformed = Vector3.Transform(new Vector3(vertices[c][i].x, vertices[c][i].y, vertices[c][i].z), m);
|
||||
vertices[c][i].x = transformed.X;
|
||||
vertices[c][i].y = transformed.Y;
|
||||
vertices[c][i].z = transformed.Z;
|
||||
}
|
||||
|
||||
// TODO: this won't work on things with AbsoluteZ flag
|
||||
|
@ -320,8 +345,8 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
}
|
||||
|
||||
// Apply it
|
||||
for(int i = 0; i < vertices.Length; i++)
|
||||
vertices[i].z = floor.GetZ(vertices[i].x + Thing.Position.x, vertices[i].y + Thing.Position.y) + voffset;
|
||||
for(int i = 0; i < vertices[c].Length; i++)
|
||||
vertices[c][i].z = floor.GetZ(vertices[c][i].x + Thing.Position.x, vertices[c][i].y + Thing.Position.y) + voffset;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -333,12 +358,12 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
|
||||
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);
|
||||
vertices[i].x = transformed.X;
|
||||
vertices[i].y = transformed.Y;
|
||||
vertices[i].z = transformed.Z;
|
||||
Vector4 transformed = Vector3.Transform(new Vector3(vertices[c][i].x, vertices[c][i].y, vertices[c][i].z), m);
|
||||
vertices[c][i].x = transformed.X;
|
||||
vertices[c][i].y = transformed.Y;
|
||||
vertices[c][i].z = transformed.Z;
|
||||
}
|
||||
|
||||
// TODO: this won't work on things with AbsoluteZ flag
|
||||
|
@ -363,8 +388,8 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
}
|
||||
|
||||
// Apply it
|
||||
for(int i = 0; i < vertices.Length; i++)
|
||||
vertices[i].z = ceiling.GetZ(vertices[i].x + Thing.Position.x, vertices[i].y + Thing.Position.y) + voffset;
|
||||
for(int i = 0; i < vertices[c].Length; i++)
|
||||
vertices[c][i].z = ceiling.GetZ(vertices[c][i].x + Thing.Position.x, vertices[c][i].y + Thing.Position.y) + voffset;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -373,17 +398,18 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
if(info.RollSprite)
|
||||
{
|
||||
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);
|
||||
vertices[i].x = transformed.X;
|
||||
vertices[i].y = transformed.Y;
|
||||
vertices[i].z = transformed.Z;
|
||||
Vector4 transformed = Vector3.Transform(new Vector3(vertices[c][i].x, vertices[c][i].y, vertices[c][i].z), m);
|
||||
vertices[c][i].x = transformed.X;
|
||||
vertices[c][i].y = transformed.Y;
|
||||
vertices[c][i].z = transformed.Z;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This updates the visual thing
|
||||
public virtual void Update()
|
||||
|
@ -391,23 +417,27 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
// Do we need to update the geometry buffer?
|
||||
if(updategeo)
|
||||
{
|
||||
// Trash geometry buffer
|
||||
if(geobuffer != null) geobuffer.Dispose();
|
||||
geobuffer = null;
|
||||
//mxd. Trash geometry buffers
|
||||
if(geobuffers != null)
|
||||
foreach(VertexBuffer geobuffer in geobuffers) geobuffer.Dispose();
|
||||
|
||||
// Any vertics?
|
||||
if(vertices.Length > 0)
|
||||
{
|
||||
geobuffers = new VertexBuffer[vertices.Length];
|
||||
for(int i = 0; i < vertices.Length; i++)
|
||||
{
|
||||
// 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);
|
||||
|
||||
// Fill the buffer
|
||||
DataStream bufferstream = geobuffer.Lock(0, WorldVertex.Stride * vertices.Length, LockFlags.Discard);
|
||||
bufferstream.WriteRange(vertices);
|
||||
geobuffer.Unlock();
|
||||
DataStream bufferstream = geobuffers[i].Lock(0, WorldVertex.Stride * vertices[i].Length, LockFlags.Discard);
|
||||
bufferstream.WriteRange(vertices[i]);
|
||||
geobuffers[i].Unlock();
|
||||
bufferstream.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
//mxd. Check if thing is light
|
||||
CheckLightState();
|
||||
|
@ -708,6 +738,15 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
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>
|
||||
/// 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.
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
private bool isloaded;
|
||||
private bool nointeraction; //mxd
|
||||
private ImageData sprite;
|
||||
private ImageData[] sprites;
|
||||
private float cageradius2;
|
||||
private Vector2D pos2d;
|
||||
private Vector3D boxp1;
|
||||
|
@ -76,11 +76,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
//mxd. When true, the thing can be moved below floor/above ceiling
|
||||
nointeraction = (info.Actor != null && info.Actor.GetFlagValue("nointeraction", false));
|
||||
|
||||
// Find sprite texture
|
||||
if(info.Sprite.Length > 0)
|
||||
//mxd. Find sprite textures
|
||||
sprites = new ImageData[info.SpriteFrame.Length];
|
||||
for(int i = 0; i < info.SpriteFrame.Length; i++)
|
||||
{
|
||||
sprite = General.Map.Data.GetSpriteImage(info.Sprite);
|
||||
if(sprite != null) sprite.AddReference();
|
||||
sprites[i] = General.Map.Data.GetSpriteImage(info.SpriteFrame[i].Sprite);
|
||||
if(sprites[i] != null) sprites[i].AddReference();
|
||||
}
|
||||
|
||||
//mxd
|
||||
|
@ -191,8 +192,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
sizeless = false;
|
||||
}
|
||||
|
||||
if(sprite != null)
|
||||
{
|
||||
Plane floor = new Plane(); //mxd
|
||||
Plane ceiling = new Plane(); //mxd
|
||||
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
|
||||
ImageData sprite = sprites[i];
|
||||
sprite.LoadImage();
|
||||
isloaded = sprite.IsImageLoaded;
|
||||
if(isloaded)
|
||||
|
@ -282,7 +288,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
float offsetx = 0.0f;
|
||||
float offsety = 0.0f;
|
||||
|
||||
base.Texture = sprite;
|
||||
base.textures[i] = sprite;
|
||||
|
||||
// Determine sprite size and offset
|
||||
float radius = sprite.ScaledWidth * 0.5f;
|
||||
|
@ -304,30 +310,34 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Make vertices
|
||||
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
|
||||
{
|
||||
float hh = height / 2;
|
||||
verts[0] = new WorldVertex(-radius + offsetx, 0.0f, offsety - hh, sectorcolor, 0.0f, 1.0f);
|
||||
verts[1] = new WorldVertex(-radius + offsetx, 0.0f, hh + offsety, sectorcolor, 0.0f, 0.0f);
|
||||
verts[2] = new WorldVertex(+radius + offsetx, 0.0f, hh + offsety, sectorcolor, 1.0f, 0.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, ul, 0.0f);
|
||||
verts[2] = new WorldVertex(+radius + offsetx, 0.0f, hh + offsety, sectorcolor, ur, 0.0f);
|
||||
verts[3] = verts[0];
|
||||
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
|
||||
{
|
||||
verts[0] = new WorldVertex(-radius + offsetx, 0.0f, offsety, sectorcolor, 0.0f, 1.0f);
|
||||
verts[1] = new WorldVertex(-radius + offsetx, 0.0f, height + offsety, sectorcolor, 0.0f, 0.0f);
|
||||
verts[2] = new WorldVertex(+radius + offsetx, 0.0f, height + offsety, sectorcolor, 1.0f, 0.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, ul, 0.0f);
|
||||
verts[2] = new WorldVertex(+radius + offsetx, 0.0f, height + offsety, sectorcolor, ur, 0.0f);
|
||||
verts[3] = verts[0];
|
||||
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
|
||||
{
|
||||
base.Texture = General.Map.Data.Hourglass3D;
|
||||
base.textures[i] = General.Map.Data.Hourglass3D;
|
||||
|
||||
// Determine sprite size
|
||||
float radius = Math.Min(thingradius, thingheight / 2f);
|
||||
|
@ -341,10 +351,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
verts[3] = verts[0];
|
||||
verts[4] = verts[2];
|
||||
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
|
||||
Vector3D pos = Thing.Position;
|
||||
if(Thing.Type == 9501)
|
||||
|
@ -439,10 +452,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
if(!IsDisposed)
|
||||
{
|
||||
if(sprite != null)
|
||||
if(sprites != null) //mxd
|
||||
{
|
||||
sprite.RemoveReference();
|
||||
sprite = null;
|
||||
foreach(ImageData sprite in sprites) sprite.RemoveReference();
|
||||
sprites = null;
|
||||
}
|
||||
|
||||
base.Dispose();
|
||||
|
@ -462,11 +475,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
//mxd. When true, the thing can be moved below floor/above ceiling
|
||||
nointeraction = (info.Actor != null && info.Actor.GetFlagValue("nointeraction", false));
|
||||
|
||||
// Find sprite texture
|
||||
if(info.Sprite.Length > 0)
|
||||
//mxd. Find sprite textures
|
||||
sprites = new ImageData[info.SpriteFrame.Length];
|
||||
for(int i = 0; i < info.SpriteFrame.Length; i++)
|
||||
{
|
||||
sprite = General.Map.Data.GetSpriteImage(info.Sprite);
|
||||
if(sprite != null) sprite.AddReference();
|
||||
sprites[i] = General.Map.Data.GetSpriteImage(info.SpriteFrame[i].Sprite);
|
||||
if(sprites[i] != null) sprites[i].AddReference();
|
||||
}
|
||||
|
||||
// Setup visual thing
|
||||
|
@ -478,13 +492,20 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
if(!isloaded)
|
||||
{
|
||||
// Rebuild sprite geometry when sprite is loaded
|
||||
if(sprite.IsImageLoaded)
|
||||
//mxd. Rebuild sprite geometry when all sprites are loaded
|
||||
bool allloaded = true;
|
||||
foreach(ImageData sprite in sprites)
|
||||
{
|
||||
Setup();
|
||||
if(!sprite.IsImageLoaded)
|
||||
{
|
||||
allloaded = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(allloaded) Setup();
|
||||
}
|
||||
|
||||
// Let the base update
|
||||
base.Update();
|
||||
}
|
||||
|
@ -757,13 +778,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
//mxd
|
||||
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))
|
||||
undoticket = mode.CreateUndo("Change thing scale");
|
||||
|
||||
float scaleX = Thing.ScaleX;
|
||||
float scaleY = Thing.ScaleY;
|
||||
ImageData sprite = sprites[0];
|
||||
|
||||
if(incrementX != 0)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue