Add depth buffer support to sprites and sequences.

This commit is contained in:
Paul Chote
2015-10-01 18:55:54 +01:00
parent 2634643d91
commit 2915db67c4
15 changed files with 44 additions and 39 deletions

View File

@@ -79,6 +79,7 @@ namespace OpenRA.Mods.Common.Graphics
public int Facings { get; private set; }
public int Tick { get; private set; }
public int ZOffset { get; private set; }
public float ZRamp { get; private set; }
public int ShadowStart { get; private set; }
public int ShadowZOffset { get; private set; }
public int[] Frames { get; private set; }
@@ -119,6 +120,7 @@ namespace OpenRA.Mods.Common.Graphics
ShadowStart = LoadField(d, "ShadowStart", -1);
ShadowZOffset = LoadField(d, "ShadowZOffset", DefaultShadowSpriteZOffset).Length;
ZOffset = LoadField(d, "ZOffset", WDist.Zero).Length;
ZRamp = LoadField(d, "ZRamp", 0);
Tick = LoadField(d, "Tick", 40);
transpose = LoadField(d, "Transpose", false);
Frames = LoadField<int[]>(d, "Frames", null);
@@ -139,7 +141,7 @@ namespace OpenRA.Mods.Common.Graphics
"{0}: Sequence {1}.{2}: UseClassicFacingFudge is only valid for 32 facings"
.F(info.Nodes[0].Location, sequence, animation));
var offset = LoadField(d, "Offset", float2.Zero);
var offset = LoadField(d, "Offset", float3.Zero);
var blendMode = LoadField(d, "BlendMode", BlendMode.Alpha);
MiniYaml combine;
@@ -159,7 +161,7 @@ namespace OpenRA.Mods.Common.Graphics
var subSrc = GetSpriteSrc(modData, tileSet, sequence, animation, sub.Key, sd);
var subSprites = cache[subSrc].Select(
s => new Sprite(s.Sheet,
FlipRectangle(s.Bounds, subFlipX, subFlipY),
FlipRectangle(s.Bounds, subFlipX, subFlipY), ZRamp,
new float2(subFlipX ? -s.Offset.X : s.Offset.X, subFlipY ? -s.Offset.Y : s.Offset.Y) + subOffset + offset,
s.Channel, blendMode));
@@ -182,7 +184,7 @@ namespace OpenRA.Mods.Common.Graphics
var src = GetSpriteSrc(modData, tileSet, sequence, animation, info.Value, d);
sprites = cache[src].Select(
s => new Sprite(s.Sheet,
FlipRectangle(s.Bounds, flipX, flipY),
FlipRectangle(s.Bounds, flipX, flipY), ZRamp,
new float2(flipX ? -s.Offset.X : s.Offset.X, flipY ? -s.Offset.Y : s.Offset.Y) + offset,
s.Channel, blendMode)).ToArray();
}