Fix remaining voxel references in Game.
This commit is contained in:
@@ -79,7 +79,7 @@ namespace OpenRA.Graphics
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ModelRenderProxy RenderAsync(
|
public ModelRenderProxy RenderAsync(
|
||||||
WorldRenderer wr, IEnumerable<ModelAnimation> voxels, WRot camera, float scale,
|
WorldRenderer wr, IEnumerable<ModelAnimation> models, WRot camera, float scale,
|
||||||
float[] groundNormal, WRot lightSource, float[] lightAmbientColor, float[] lightDiffuseColor,
|
float[] groundNormal, WRot lightSource, float[] lightAmbientColor, float[] lightDiffuseColor,
|
||||||
PaletteReference color, PaletteReference normals, PaletteReference shadowPalette)
|
PaletteReference color, PaletteReference normals, PaletteReference shadowPalette)
|
||||||
{
|
{
|
||||||
@@ -105,18 +105,18 @@ namespace OpenRA.Graphics
|
|||||||
var stl = new float2(float.MaxValue, float.MaxValue);
|
var stl = new float2(float.MaxValue, float.MaxValue);
|
||||||
var sbr = new float2(float.MinValue, float.MinValue);
|
var sbr = new float2(float.MinValue, float.MinValue);
|
||||||
|
|
||||||
foreach (var v in voxels)
|
foreach (var m in models)
|
||||||
{
|
{
|
||||||
// Convert screen offset back to world coords
|
// Convert screen offset back to world coords
|
||||||
var offsetVec = Util.MatrixVectorMultiply(invCameraTransform, wr.ScreenVector(v.OffsetFunc()));
|
var offsetVec = Util.MatrixVectorMultiply(invCameraTransform, wr.ScreenVector(m.OffsetFunc()));
|
||||||
var offsetTransform = Util.TranslationMatrix(offsetVec[0], offsetVec[1], offsetVec[2]);
|
var offsetTransform = Util.TranslationMatrix(offsetVec[0], offsetVec[1], offsetVec[2]);
|
||||||
|
|
||||||
var worldTransform = v.RotationFunc().Aggregate(Util.IdentityMatrix(),
|
var worldTransform = m.RotationFunc().Aggregate(Util.IdentityMatrix(),
|
||||||
(x, y) => Util.MatrixMultiply(Util.MakeFloatMatrix(y.AsMatrix()), x));
|
(x, y) => Util.MatrixMultiply(Util.MakeFloatMatrix(y.AsMatrix()), x));
|
||||||
worldTransform = Util.MatrixMultiply(scaleTransform, worldTransform);
|
worldTransform = Util.MatrixMultiply(scaleTransform, worldTransform);
|
||||||
worldTransform = Util.MatrixMultiply(offsetTransform, worldTransform);
|
worldTransform = Util.MatrixMultiply(offsetTransform, worldTransform);
|
||||||
|
|
||||||
var bounds = v.Model.Bounds(v.FrameFunc());
|
var bounds = m.Model.Bounds(m.FrameFunc());
|
||||||
var worldBounds = Util.MatrixAABBMultiply(worldTransform, bounds);
|
var worldBounds = Util.MatrixAABBMultiply(worldTransform, bounds);
|
||||||
var screenBounds = Util.MatrixAABBMultiply(cameraTransform, worldBounds);
|
var screenBounds = Util.MatrixAABBMultiply(cameraTransform, worldBounds);
|
||||||
var shadowBounds = Util.MatrixAABBMultiply(shadowTransform, worldBounds);
|
var shadowBounds = Util.MatrixAABBMultiply(shadowTransform, worldBounds);
|
||||||
@@ -177,13 +177,13 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
doRender.Add(Pair.New<Sheet, Action>(sprite.Sheet, () =>
|
doRender.Add(Pair.New<Sheet, Action>(sprite.Sheet, () =>
|
||||||
{
|
{
|
||||||
foreach (var v in voxels)
|
foreach (var m in models)
|
||||||
{
|
{
|
||||||
// Convert screen offset to world offset
|
// Convert screen offset to world offset
|
||||||
var offsetVec = Util.MatrixVectorMultiply(invCameraTransform, wr.ScreenVector(v.OffsetFunc()));
|
var offsetVec = Util.MatrixVectorMultiply(invCameraTransform, wr.ScreenVector(m.OffsetFunc()));
|
||||||
var offsetTransform = Util.TranslationMatrix(offsetVec[0], offsetVec[1], offsetVec[2]);
|
var offsetTransform = Util.TranslationMatrix(offsetVec[0], offsetVec[1], offsetVec[2]);
|
||||||
|
|
||||||
var rotations = v.RotationFunc().Aggregate(Util.IdentityMatrix(),
|
var rotations = m.RotationFunc().Aggregate(Util.IdentityMatrix(),
|
||||||
(x, y) => Util.MatrixMultiply(Util.MakeFloatMatrix(y.AsMatrix()), x));
|
(x, y) => Util.MatrixMultiply(Util.MakeFloatMatrix(y.AsMatrix()), x));
|
||||||
var worldTransform = Util.MatrixMultiply(scaleTransform, rotations);
|
var worldTransform = Util.MatrixMultiply(scaleTransform, rotations);
|
||||||
worldTransform = Util.MatrixMultiply(offsetTransform, worldTransform);
|
worldTransform = Util.MatrixMultiply(offsetTransform, worldTransform);
|
||||||
@@ -196,11 +196,11 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
var lightTransform = Util.MatrixMultiply(Util.MatrixInverse(rotations), invShadowTransform);
|
var lightTransform = Util.MatrixMultiply(Util.MatrixInverse(rotations), invShadowTransform);
|
||||||
|
|
||||||
var frame = v.FrameFunc();
|
var frame = m.FrameFunc();
|
||||||
for (uint i = 0; i < v.Model.Sections; i++)
|
for (uint i = 0; i < m.Model.Sections; i++)
|
||||||
{
|
{
|
||||||
var rd = v.Model.RenderData(i);
|
var rd = m.Model.RenderData(i);
|
||||||
var t = v.Model.TransformationMatrix(i, frame);
|
var t = m.Model.TransformationMatrix(i, frame);
|
||||||
var it = Util.MatrixInverse(t);
|
var it = Util.MatrixInverse(t);
|
||||||
if (it == null)
|
if (it == null)
|
||||||
throw new InvalidOperationException("Failed to invert the transformed matrix of frame {0} during RenderAsync.".F(i));
|
throw new InvalidOperationException("Failed to invert the transformed matrix of frame {0} during RenderAsync.".F(i));
|
||||||
@@ -212,7 +212,7 @@ 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
|
||||||
if (v.ShowShadow)
|
if (m.ShowShadow)
|
||||||
Render(rd, wr.World.ModelCache, Util.MatrixMultiply(shadow, t), lightDirection,
|
Render(rd, wr.World.ModelCache, Util.MatrixMultiply(shadow, t), lightDirection,
|
||||||
ShadowAmbient, ShadowDiffuse, shadowPalette.TextureMidIndex, normals.TextureMidIndex);
|
ShadowAmbient, ShadowDiffuse, shadowPalette.TextureMidIndex, normals.TextureMidIndex);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -241,7 +241,7 @@ namespace OpenRA.Graphics
|
|||||||
return new float3((float)Math.Round(px.X), (float)Math.Round(px.Y), px.Z);
|
return new float3((float)Math.Round(px.X), (float)Math.Round(px.Y), px.Z);
|
||||||
}
|
}
|
||||||
|
|
||||||
// For scaling vectors to pixel sizes in the voxel renderer
|
// For scaling vectors to pixel sizes in the model renderer
|
||||||
public float3 ScreenVectorComponents(WVec vec)
|
public float3 ScreenVectorComponents(WVec vec)
|
||||||
{
|
{
|
||||||
return new float3(
|
return new float3(
|
||||||
@@ -250,7 +250,7 @@ namespace OpenRA.Graphics
|
|||||||
(float)TileSize.Height * vec.Z / TileScale);
|
(float)TileSize.Height * vec.Z / TileScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
// For scaling vectors to pixel sizes in the voxel renderer
|
// For scaling vectors to pixel sizes in the model renderer
|
||||||
public float[] ScreenVector(WVec vec)
|
public float[] ScreenVector(WVec vec)
|
||||||
{
|
{
|
||||||
var xyz = ScreenVectorComponents(vec);
|
var xyz = ScreenVectorComponents(vec);
|
||||||
|
|||||||
Reference in New Issue
Block a user