Added a flag ShowShadow in WithVoxelBarrel, WithVoxelBody, WithVoxelTurret, WithVoxelUnloadBody and WithVoxelWalkerBody

This commit is contained in:
abc013
2016-09-20 13:34:05 +02:00
parent c9474a857a
commit b9d1f373fe
7 changed files with 33 additions and 14 deletions

View File

@@ -21,14 +21,16 @@ namespace OpenRA.Graphics
public readonly Func<IEnumerable<WRot>> RotationFunc; public readonly Func<IEnumerable<WRot>> RotationFunc;
public readonly Func<bool> DisableFunc; public readonly Func<bool> DisableFunc;
public readonly Func<uint> FrameFunc; public readonly Func<uint> FrameFunc;
public readonly bool ShowShadow;
public VoxelAnimation(Voxel voxel, Func<WVec> offset, Func<IEnumerable<WRot>> rotation, Func<bool> disable, Func<uint> frame) public VoxelAnimation(Voxel voxel, Func<WVec> offset, Func<IEnumerable<WRot>> rotation, Func<bool> disable, Func<uint> frame, bool showshadow)
{ {
Voxel = voxel; Voxel = voxel;
OffsetFunc = offset; OffsetFunc = offset;
RotationFunc = rotation; RotationFunc = rotation;
DisableFunc = disable; DisableFunc = disable;
FrameFunc = frame; FrameFunc = frame;
ShowShadow = showshadow;
} }
} }
} }

View File

@@ -212,8 +212,9 @@ namespace OpenRA.Graphics
lightAmbientColor, lightDiffuseColor, color.TextureMidIndex, normals.TextureMidIndex); lightAmbientColor, lightDiffuseColor, color.TextureMidIndex, normals.TextureMidIndex);
// Disable shadow normals by forcing zero diffuse and identity ambient light // Disable shadow normals by forcing zero diffuse and identity ambient light
Render(rd, Util.MatrixMultiply(shadow, t), lightDirection, if (v.ShowShadow)
ShadowAmbient, ShadowDiffuse, shadowPalette.TextureMidIndex, normals.TextureMidIndex); Render(rd, Util.MatrixMultiply(shadow, t), lightDirection,
ShadowAmbient, ShadowDiffuse, shadowPalette.TextureMidIndex, normals.TextureMidIndex);
} }
} }
})); }));

View File

@@ -29,6 +29,9 @@ namespace OpenRA.Mods.Common.Traits.Render
[Desc("Visual offset")] [Desc("Visual offset")]
public readonly WVec LocalOffset = WVec.Zero; public readonly WVec LocalOffset = WVec.Zero;
[Desc("Defines if the Voxel should have a shadow.")]
public readonly bool ShowShadow = true;
public override object Create(ActorInitializer init) { return new WithVoxelBarrel(init.Self, this); } public override object Create(ActorInitializer init) { return new WithVoxelBarrel(init.Self, this); }
public IEnumerable<VoxelAnimation> RenderPreviewVoxels( public IEnumerable<VoxelAnimation> RenderPreviewVoxels(
@@ -53,7 +56,7 @@ namespace OpenRA.Mods.Common.Traits.Render
Func<WVec> barrelOffset = () => body.LocalToWorld((t.Offset + LocalOffset.Rotate(quantizedTurret())).Rotate(quantizedBody())); Func<WVec> barrelOffset = () => body.LocalToWorld((t.Offset + LocalOffset.Rotate(quantizedTurret())).Rotate(quantizedBody()));
yield return new VoxelAnimation(voxel, barrelOffset, () => new[] { turretOrientation(), orientation() }, yield return new VoxelAnimation(voxel, barrelOffset, () => new[] { turretOrientation(), orientation() },
() => false, () => 0); () => false, () => 0, ShowShadow);
} }
} }
@@ -82,7 +85,7 @@ namespace OpenRA.Mods.Common.Traits.Render
var rv = self.Trait<RenderVoxels>(); var rv = self.Trait<RenderVoxels>();
rv.Add(new VoxelAnimation(VoxelProvider.GetVoxel(rv.Image, Info.Sequence), rv.Add(new VoxelAnimation(VoxelProvider.GetVoxel(rv.Image, Info.Sequence),
BarrelOffset, BarrelRotation, BarrelOffset, BarrelRotation,
() => IsTraitDisabled || !buildComplete, () => 0)); () => IsTraitDisabled || !buildComplete, () => 0, info.ShowShadow));
} }
WVec BarrelOffset() WVec BarrelOffset()

View File

@@ -23,6 +23,9 @@ namespace OpenRA.Mods.Common.Traits.Render
{ {
public readonly string Sequence = "idle"; public readonly string Sequence = "idle";
[Desc("Defines if the Voxel should have a shadow.")]
public readonly bool ShowShadow = true;
public override object Create(ActorInitializer init) { return new WithVoxelBody(init.Self, this); } public override object Create(ActorInitializer init) { return new WithVoxelBody(init.Self, this); }
public IEnumerable<VoxelAnimation> RenderPreviewVoxels( public IEnumerable<VoxelAnimation> RenderPreviewVoxels(
@@ -32,7 +35,7 @@ namespace OpenRA.Mods.Common.Traits.Render
var voxel = VoxelProvider.GetVoxel(image, "idle"); var voxel = VoxelProvider.GetVoxel(image, "idle");
yield return new VoxelAnimation(voxel, () => WVec.Zero, yield return new VoxelAnimation(voxel, () => WVec.Zero,
() => new[] { body.QuantizeOrientation(orientation(), facings) }, () => new[] { body.QuantizeOrientation(orientation(), facings) },
() => false, () => 0); () => false, () => 0, ShowShadow);
} }
} }
@@ -49,7 +52,7 @@ namespace OpenRA.Mods.Common.Traits.Render
var voxel = VoxelProvider.GetVoxel(rv.Image, info.Sequence); var voxel = VoxelProvider.GetVoxel(rv.Image, info.Sequence);
rv.Add(new VoxelAnimation(voxel, () => WVec.Zero, rv.Add(new VoxelAnimation(voxel, () => WVec.Zero,
() => new[] { body.QuantizeOrientation(self, self.Orientation) }, () => new[] { body.QuantizeOrientation(self, self.Orientation) },
() => IsTraitDisabled, () => 0)); () => IsTraitDisabled, () => 0, info.ShowShadow));
// Selection size // Selection size
var rvi = self.Info.TraitInfo<RenderVoxelsInfo>(); var rvi = self.Info.TraitInfo<RenderVoxelsInfo>();

View File

@@ -26,6 +26,9 @@ namespace OpenRA.Mods.Common.Traits.Render
[Desc("Turreted 'Turret' key to display")] [Desc("Turreted 'Turret' key to display")]
public readonly string Turret = "primary"; public readonly string Turret = "primary";
[Desc("Defines if the Voxel should have a shadow.")]
public readonly bool ShowShadow = true;
public override object Create(ActorInitializer init) { return new WithVoxelTurret(init.Self, this); } public override object Create(ActorInitializer init) { return new WithVoxelTurret(init.Self, this); }
public IEnumerable<VoxelAnimation> RenderPreviewVoxels( public IEnumerable<VoxelAnimation> RenderPreviewVoxels(
@@ -44,7 +47,7 @@ namespace OpenRA.Mods.Common.Traits.Render
var turretFacing = Turreted.TurretFacingFromInit(init, t.InitialFacing, Turret); var turretFacing = Turreted.TurretFacingFromInit(init, t.InitialFacing, Turret);
Func<WRot> turretBodyOrientation = () => WRot.FromYaw(WAngle.FromFacing(turretFacing()) - orientation().Yaw); Func<WRot> turretBodyOrientation = () => WRot.FromYaw(WAngle.FromFacing(turretFacing()) - orientation().Yaw);
yield return new VoxelAnimation(voxel, turretOffset, yield return new VoxelAnimation(voxel, turretOffset,
() => new[] { turretBodyOrientation(), body.QuantizeOrientation(orientation(), facings) }, () => false, () => 0); () => new[] { turretBodyOrientation(), body.QuantizeOrientation(orientation(), facings) }, () => false, () => 0, ShowShadow);
} }
} }
@@ -69,7 +72,7 @@ namespace OpenRA.Mods.Common.Traits.Render
var rv = self.Trait<RenderVoxels>(); var rv = self.Trait<RenderVoxels>();
rv.Add(new VoxelAnimation(VoxelProvider.GetVoxel(rv.Image, Info.Sequence), rv.Add(new VoxelAnimation(VoxelProvider.GetVoxel(rv.Image, Info.Sequence),
() => turreted.Position(self), TurretRotation, () => turreted.Position(self), TurretRotation,
() => IsTraitDisabled || !buildComplete, () => 0)); () => IsTraitDisabled || !buildComplete, () => 0, info.ShowShadow));
} }
IEnumerable<WRot> TurretRotation() IEnumerable<WRot> TurretRotation()

View File

@@ -28,6 +28,9 @@ namespace OpenRA.Mods.TS.Traits.Render
[Desc("Voxel sequence name to use when undocked from a refinery.")] [Desc("Voxel sequence name to use when undocked from a refinery.")]
public readonly string IdleSequence = "idle"; public readonly string IdleSequence = "idle";
[Desc("Defines if the Voxel should have a shadow.")]
public readonly bool ShowShadow = true;
public object Create(ActorInitializer init) { return new WithVoxelUnloadBody(init.Self, this); } public object Create(ActorInitializer init) { return new WithVoxelUnloadBody(init.Self, this); }
public IEnumerable<VoxelAnimation> RenderPreviewVoxels( public IEnumerable<VoxelAnimation> RenderPreviewVoxels(
@@ -37,7 +40,7 @@ namespace OpenRA.Mods.TS.Traits.Render
var voxel = VoxelProvider.GetVoxel(image, "idle"); var voxel = VoxelProvider.GetVoxel(image, "idle");
yield return new VoxelAnimation(voxel, () => WVec.Zero, yield return new VoxelAnimation(voxel, () => WVec.Zero,
() => new[] { body.QuantizeOrientation(orientation(), facings) }, () => new[] { body.QuantizeOrientation(orientation(), facings) },
() => false, () => 0); () => false, () => 0, ShowShadow);
} }
} }
@@ -56,7 +59,7 @@ namespace OpenRA.Mods.TS.Traits.Render
rv.Add(new VoxelAnimation(idleVoxel, () => WVec.Zero, rv.Add(new VoxelAnimation(idleVoxel, () => WVec.Zero,
() => new[] { body.QuantizeOrientation(self, self.Orientation) }, () => new[] { body.QuantizeOrientation(self, self.Orientation) },
() => Docked, () => Docked,
() => 0)); () => 0, info.ShowShadow));
// Selection size // Selection size
var rvi = self.Info.TraitInfo<RenderVoxelsInfo>(); var rvi = self.Info.TraitInfo<RenderVoxelsInfo>();
@@ -67,7 +70,7 @@ namespace OpenRA.Mods.TS.Traits.Render
rv.Add(new VoxelAnimation(unloadVoxel, () => WVec.Zero, rv.Add(new VoxelAnimation(unloadVoxel, () => WVec.Zero,
() => new[] { body.QuantizeOrientation(self, self.Orientation) }, () => new[] { body.QuantizeOrientation(self, self.Orientation) },
() => !Docked, () => !Docked,
() => 0)); () => 0, info.ShowShadow));
} }
public int2 SelectionSize(Actor self) { return size; } public int2 SelectionSize(Actor self) { return size; }

View File

@@ -24,7 +24,11 @@ namespace OpenRA.Mods.TS.Traits.Render
{ {
public class WithVoxelWalkerBodyInfo : ITraitInfo, IRenderActorPreviewVoxelsInfo, Requires<RenderVoxelsInfo>, Requires<IMoveInfo>, Requires<IFacingInfo> public class WithVoxelWalkerBodyInfo : ITraitInfo, IRenderActorPreviewVoxelsInfo, Requires<RenderVoxelsInfo>, Requires<IMoveInfo>, Requires<IFacingInfo>
{ {
[Desc("The speed of the walker's legs.")]
public readonly int TickRate = 5; public readonly int TickRate = 5;
[Desc("Defines if the Voxel should have a shadow.")]
public readonly bool ShowShadow = true;
public object Create(ActorInitializer init) { return new WithVoxelWalkerBody(init.Self, this); } public object Create(ActorInitializer init) { return new WithVoxelWalkerBody(init.Self, this); }
public IEnumerable<VoxelAnimation> RenderPreviewVoxels( public IEnumerable<VoxelAnimation> RenderPreviewVoxels(
@@ -36,7 +40,7 @@ namespace OpenRA.Mods.TS.Traits.Render
yield return new VoxelAnimation(voxel, () => WVec.Zero, yield return new VoxelAnimation(voxel, () => WVec.Zero,
() => new[] { body.QuantizeOrientation(orientation(), facings) }, () => new[] { body.QuantizeOrientation(orientation(), facings) },
() => false, () => frame); () => false, () => frame, ShowShadow);
} }
} }
@@ -62,7 +66,7 @@ namespace OpenRA.Mods.TS.Traits.Render
frames = voxel.Frames; frames = voxel.Frames;
rv.Add(new VoxelAnimation(voxel, () => WVec.Zero, rv.Add(new VoxelAnimation(voxel, () => WVec.Zero,
() => new[] { body.QuantizeOrientation(self, self.Orientation) }, () => new[] { body.QuantizeOrientation(self, self.Orientation) },
() => false, () => frame)); () => false, () => frame, info.ShowShadow));
// Selection size // Selection size
var rvi = self.Info.TraitInfo<RenderVoxelsInfo>(); var rvi = self.Info.TraitInfo<RenderVoxelsInfo>();