1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-06-20 22:25:24 +00:00

More rendering fixes

This commit is contained in:
Tim Sarbin 2018-11-24 18:54:32 -05:00
parent b456b7be82
commit 78fed23e21
4 changed files with 35 additions and 29 deletions

View File

@ -319,6 +319,7 @@ namespace OpenDiablo2.Common.Models
NumberOfNPCs = br.ReadInt32();
}*/
LevelPreset levelPreset;
if (definition == -1)
{
@ -349,6 +350,7 @@ namespace OpenDiablo2.Common.Models
log.Debug($"Loading DT resource {levelType.File[i]}");
DT1s[i] = resourceManager.GetMPQDT1("data\\global\\tiles\\" + levelType.File[i].Replace("/", "\\"));
}
}
}

View File

@ -143,7 +143,7 @@ namespace OpenDiablo2.Common.Models
length -= n;
while (n > 0)
{
block.PixelData[x + ((31-y) * 32)] = br.ReadByte();
block.PixelData[x + (y * 32)] = br.ReadByte();
x++;
n--;
}
@ -176,7 +176,7 @@ namespace OpenDiablo2.Common.Models
length -= b2;
while (b2 > 0)
{
block.PixelData[x + ((31-y) * 32)] = br.ReadByte();
block.PixelData[x + (y * 32)] = br.ReadByte();
x++;
b2--;
}

View File

@ -99,14 +99,21 @@ namespace OpenDiablo2.SDL2_
}
var sub_index = floor.Prop2;
var main_index = (floor.Prop3 >> 4) + ((floor.Prop4 & 0x03) << 4);
if (mapData.DT1s[main_index] == null)
return;
var main_index = (floor.Prop3 >> 4) + ((floor.Prop4 & 0x03) << 4);
if (mapData.DT1s[main_index].Tiles.Count() <= sub_index)
return;
MPQDT1Tile tile = null;
for (int i = 0; i < mapData.DT1s.Count(); i++)
{
if (mapData.DT1s[i] == null)
continue;
var tile = mapData.DT1s[main_index].Tiles[sub_index];
tile = mapData.DT1s[i].Tiles.FirstOrDefault(z => z.MainIndex == main_index && z.SubIndex == sub_index);
if (tile != null)
break;
}
if (tile == null)
throw new ApplicationException("Could not locate tile!");
FrameSize = new Size(tile.Width, Math.Abs(tile.Height));
TotalFrames = 1;
@ -122,30 +129,27 @@ namespace OpenDiablo2.SDL2_
SDL.SDL_LockTexture(texture, IntPtr.Zero, out pixels, out pitch);
try
{
if (tile.Orientation == 0)
UInt32* data = (UInt32*)pixels;
for (var i = 0; i < FrameSize.Width * FrameSize.Height; i++)
data[i] = 0x0;
foreach (var block in tile.Blocks.Take(1))
{
UInt32* data = (UInt32*)pixels;
for (var i = 0; i < FrameSize.Width * FrameSize.Height; i++)
data[i] = 0x0;
//var px = block.PositionX;
//var py = block.PositionY;
foreach (var block in tile.Blocks)
var px = 0;
var py = 0;
for (int yy = 0; yy < 32; yy++)
{
var px = block.PositionX;
var py = block.PositionY;
//var px = 0;
//var py = 0;
for (int yy = 0; yy < 32; yy++)
for (int xx = 0; xx < 32; xx++)
{
for (int xx = 0; xx < 32; xx++)
{
var index = px + xx + ((py + yy) * (pitch / 4));
if (index > (FrameSize.Width * FrameSize.Height))
continue;
if (index < 0)
continue;
data[index] = palette.Colors[block.PixelData[xx + ((31-yy) * 32)]];
}
var index = px + xx + ((py + yy) * (pitch / 4));
if (index > (FrameSize.Width * FrameSize.Height))
continue;
if (index < 0)
continue;
data[index] = palette.Colors[block.PixelData[xx + (yy * 32)]];
}
}
}

View File

@ -87,7 +87,7 @@ namespace OpenDiablo2.Scenes
for (int x = 0; x < gameState.MapData.Width; x++)
{
testSprite[idx] = renderWindow.GenerateMapCell(gameState.MapData, x, y, eRenderCellType.Floor, gameState.CurrentPalette);
testSprite[idx].Location = new Point(((x - y) * 80) - 900, ((x + y) * 40) - 1100);
testSprite[idx].Location = new Point(((x - y) * 80) - 0, ((x + y) * 40) - 0);
idx++;
}
}