Skip to content

Commit 9f90db2

Browse files
author
Unknown
committed
playfield rendering fixed
1 parent c866af3 commit 9f90db2

1 file changed

Lines changed: 20 additions & 20 deletions

File tree

I, Robot Emulator MonoGame/Renderers/MathboxRenderer.cs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -616,10 +616,10 @@ void DrawPlayfieldTile(int index, Vector3 corner)
616616
// draw if tile to the left is lower than current tile
617617
if (height.a < side.b || height.d < side.c)
618618
{
619-
Vertices[0] = new Vector3(x1, height.a, z1);
620-
Vertices[1] = new Vector3(x1, height.d, z2);
621-
Vertices[2] = new Vector3(x1, side.c, z2);
622-
Vertices[3] = new Vector3(x1, side.b, z1);
619+
Vertices[0] = Vector3.Transform(new Vector3(x1, height.a, z1), Parent.D3DTS_WORLD);
620+
Vertices[1] = Vector3.Transform(new Vector3(x1, height.d, z2), Parent.D3DTS_WORLD);
621+
Vertices[2] = Vector3.Transform(new Vector3(x1, side.c, z2), Parent.D3DTS_WORLD);
622+
Vertices[3] = Vector3.Transform(new Vector3(x1, side.b, z1), Parent.D3DTS_WORLD);
623623
DisplayListManager.AddPrimitive(Vertices, 4, Parent.GetColor(colorIndex - 1), Mode);
624624
}
625625
}
@@ -637,10 +637,10 @@ void DrawPlayfieldTile(int index, Vector3 corner)
637637
// draw if tile to the right is lower than current tile
638638
if (height.b < side.a || height.c < side.d)
639639
{
640-
Vertices[0] = new Vector3(x2, height.b, z1);
641-
Vertices[1] = new Vector3(x2, side.a, z1);
642-
Vertices[2] = new Vector3(x2, side.d, z2);
643-
Vertices[3] = new Vector3(x2, height.c, z2);
640+
Vertices[0] = Vector3.Transform(new Vector3(x2, height.b, z1), Parent.D3DTS_WORLD);
641+
Vertices[1] = Vector3.Transform(new Vector3(x2, side.a, z1), Parent.D3DTS_WORLD);
642+
Vertices[2] = Vector3.Transform(new Vector3(x2, side.d, z2), Parent.D3DTS_WORLD);
643+
Vertices[3] = Vector3.Transform(new Vector3(x2, height.c, z2), Parent.D3DTS_WORLD);
644644
DisplayListManager.AddPrimitive(Vertices, 4, Parent.GetColor(colorIndex - 1), Mode);
645645
}
646646
}
@@ -663,19 +663,19 @@ void DrawPlayfieldTile(int index, Vector3 corner)
663663
}
664664
if (height.a < side.d || height.b < side.c)
665665
{
666-
Vertices[0] = new Vector3(x1, height.a, z1);
667-
Vertices[1] = new Vector3(x1, side.d, z1);
668-
Vertices[2] = new Vector3(x2, side.c, z1);
669-
Vertices[3] = new Vector3(x2, height.b, z1);
666+
Vertices[0] = Vector3.Transform(new Vector3(x1, height.a, z1), Parent.D3DTS_WORLD);
667+
Vertices[1] = Vector3.Transform(new Vector3(x1, side.d, z1), Parent.D3DTS_WORLD);
668+
Vertices[2] = Vector3.Transform(new Vector3(x2, side.c, z1), Parent.D3DTS_WORLD);
669+
Vertices[3] = Vector3.Transform(new Vector3(x2, height.b, z1), Parent.D3DTS_WORLD);
670670
DisplayListManager.AddPrimitive(Vertices, 4, Parent.GetColor(colorIndex - 2), Mode);
671671
}
672672
}
673673

674674
// draw the top of the cube
675-
Vertices[0] = new Vector3(x1, height.a, z1);
676-
Vertices[1] = new Vector3(x2, height.b, z1);
677-
Vertices[2] = new Vector3(x2, height.c, z2);
678-
Vertices[3] = new Vector3(x1, height.d, z2);
675+
Vertices[0] = Vector3.Transform(new Vector3(x1, height.a, z1), Parent.D3DTS_WORLD);
676+
Vertices[1] = Vector3.Transform(new Vector3(x2, height.b, z1), Parent.D3DTS_WORLD);
677+
Vertices[2] = Vector3.Transform(new Vector3(x2, height.c, z2), Parent.D3DTS_WORLD);
678+
Vertices[3] = Vector3.Transform(new Vector3(x1, height.d, z2), Parent.D3DTS_WORLD);
679679
DisplayListManager.AddPrimitive(Vertices, 4, Parent.GetColor(colorIndex), Mode);
680680

681681
// special case for rendering solid sloped tiles
@@ -684,10 +684,10 @@ void DrawPlayfieldTile(int index, Vector3 corner)
684684
DisplayListManager.AddPrimitive(Vertices, 4, Parent.GetColor(colorIndex), Mathbox.RenderMode.Vector);
685685

686686
// draw the bottom of the cube
687-
Vertices[0] = new Vector3(x1, -Parent.ViewPosition.Y + Tile.DEFAULT_HEIGHT_Y, z1);
688-
Vertices[1] = new Vector3(x1, -Parent.ViewPosition.Y + Tile.DEFAULT_HEIGHT_Y, z2);
689-
Vertices[2] = new Vector3(x2, -Parent.ViewPosition.Y + Tile.DEFAULT_HEIGHT_Y, z2);
690-
Vertices[3] = new Vector3(x2, -Parent.ViewPosition.Y + Tile.DEFAULT_HEIGHT_Y, z1);
687+
Vertices[0] = Vector3.Transform(new Vector3(x1, -Parent.ViewPosition.Y + Tile.DEFAULT_HEIGHT_Y, z1), Parent.D3DTS_WORLD);
688+
Vertices[1] = Vector3.Transform(new Vector3(x1, -Parent.ViewPosition.Y + Tile.DEFAULT_HEIGHT_Y, z2), Parent.D3DTS_WORLD);
689+
Vertices[2] = Vector3.Transform(new Vector3(x2, -Parent.ViewPosition.Y + Tile.DEFAULT_HEIGHT_Y, z2), Parent.D3DTS_WORLD);
690+
Vertices[3] = Vector3.Transform(new Vector3(x2, -Parent.ViewPosition.Y + Tile.DEFAULT_HEIGHT_Y, z1), Parent.D3DTS_WORLD);
691691
DisplayListManager.AddPrimitive(Vertices, 4, Parent.GetColor(colorIndex), Mode);
692692
}
693693
}

0 commit comments

Comments
 (0)