Rename VoxelAnimation to ModelAnimation.

This commit is contained in:
Paul Chote
2017-06-09 00:32:48 +01:00
committed by reaperrr
parent e1cd00c1dd
commit 4f42778d26
12 changed files with 40 additions and 37 deletions

View File

@@ -14,18 +14,18 @@ using System.Collections.Generic;
namespace OpenRA.Graphics
{
public struct VoxelAnimation
public struct ModelAnimation
{
public readonly Voxel Voxel;
public readonly IModel Model;
public readonly Func<WVec> OffsetFunc;
public readonly Func<IEnumerable<WRot>> RotationFunc;
public readonly Func<bool> DisableFunc;
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, bool showshadow)
public ModelAnimation(IModel model, Func<WVec> offset, Func<IEnumerable<WRot>> rotation, Func<bool> disable, Func<uint> frame, bool showshadow)
{
Voxel = voxel;
Model = model;
OffsetFunc = offset;
RotationFunc = rotation;
DisableFunc = disable;

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Graphics
public VoxelRenderData RenderData;
}
public class Voxel
public class Voxel : IModel
{
Limb[] limbData;
float[] transforms;
@@ -31,6 +31,9 @@ namespace OpenRA.Graphics
public readonly uint Frames;
public readonly uint Limbs;
uint IModel.Frames { get { return Frames; } }
uint IModel.Sections { get { return Limbs; } }
public Voxel(VoxelLoader loader, VxlReader vxl, HvaReader hva)
{
if (vxl.LimbCount != hva.LimbCount)

View File

@@ -79,7 +79,7 @@ namespace OpenRA.Graphics
}
public VoxelRenderProxy RenderAsync(
WorldRenderer wr, IEnumerable<VoxelAnimation> voxels, WRot camera, float scale,
WorldRenderer wr, IEnumerable<ModelAnimation> voxels, WRot camera, float scale,
float[] groundNormal, WRot lightSource, float[] lightAmbientColor, float[] lightDiffuseColor,
PaletteReference color, PaletteReference normals, PaletteReference shadowPalette)
{
@@ -116,7 +116,7 @@ namespace OpenRA.Graphics
worldTransform = Util.MatrixMultiply(scaleTransform, worldTransform);
worldTransform = Util.MatrixMultiply(offsetTransform, worldTransform);
var bounds = v.Voxel.Bounds(v.FrameFunc());
var bounds = v.Model.Bounds(v.FrameFunc());
var worldBounds = Util.MatrixAABBMultiply(worldTransform, bounds);
var screenBounds = Util.MatrixAABBMultiply(cameraTransform, worldBounds);
var shadowBounds = Util.MatrixAABBMultiply(shadowTransform, worldBounds);
@@ -197,10 +197,10 @@ namespace OpenRA.Graphics
var lightTransform = Util.MatrixMultiply(Util.MatrixInverse(rotations), invShadowTransform);
var frame = v.FrameFunc();
for (uint i = 0; i < v.Voxel.Limbs; i++)
for (uint i = 0; i < v.Model.Sections; i++)
{
var rd = v.Voxel.RenderData(i);
var t = v.Voxel.TransformationMatrix(i, frame);
var rd = v.Model.RenderData(i);
var t = v.Model.TransformationMatrix(i, frame);
var it = Util.MatrixInverse(t);
if (it == null)
throw new InvalidOperationException("Failed to invert the transformed matrix of frame {0} during RenderAsync.".F(i));