Fix isometric blocks/block models sampling from wrong vertical location and fix order of rendering of elements in the hotbar. (Thanks 123DontMessWitMe)

This commit is contained in:
UnknownShadow200 2016-01-17 16:40:14 +11:00
parent f6d083f280
commit 599944d943
4 changed files with 36 additions and 38 deletions

View File

@ -76,7 +76,7 @@ namespace ClassicalSharp {
FlushIfNotSame();
FastColour col = colNormal;
float vOrigin = rec.V1;
float vOrigin = (texLoc % atlas.elementsPerAtlas1D) * atlas.invElementSize;
rec.U1 = minBB.X; rec.U2 = maxBB.X;
rec.V1 = vOrigin + minBB.Z * atlas.invElementSize;
rec.V2 = vOrigin + maxBB.Z * atlas.invElementSize * 15.99f/16f;
@ -97,18 +97,18 @@ namespace ClassicalSharp {
FlushIfNotSame();
FastColour col = fullBright ? colNormal : colZSide;
float vOrigin = rec.V1;
float vOrigin = (texLoc % atlas.elementsPerAtlas1D) * atlas.invElementSize;
rec.U1 = minBB.X; rec.U2 = maxBB.X;
rec.V1 = vOrigin + minBB.Y * atlas.invElementSize;
rec.V2 = vOrigin + maxBB.Y * atlas.invElementSize * 15.99f/16f;
rec.V1 = vOrigin + (1 - minBB.Y) * atlas.invElementSize;
rec.V2 = vOrigin + (1 - maxBB.Y) * atlas.invElementSize * 15.99f/16f;
cache.vertices[index++] = new VertexPos3fTex2fCol4b( pos.X + Make( minBB.X ), pos.Y + Make( minBB.Y ),
pos.Z + z, rec.U2, rec.V2, col );
cache.vertices[index++] = new VertexPos3fTex2fCol4b( pos.X + Make( minBB.X ), pos.Y + Make( maxBB.Y ),
pos.Z + z, rec.U2, rec.V2, col );
cache.vertices[index++] = new VertexPos3fTex2fCol4b( pos.X + Make( minBB.X ), pos.Y + Make( minBB.Y ),
pos.Z + z, rec.U2, rec.V1, col );
cache.vertices[index++] = new VertexPos3fTex2fCol4b( pos.X + Make( maxBB.X ), pos.Y + Make( maxBB.Y ),
pos.Z + z, rec.U1, rec.V1, col );
cache.vertices[index++] = new VertexPos3fTex2fCol4b( pos.X + Make( maxBB.X ), pos.Y + Make( minBB.Y ),
pos.Z + z, rec.U1, rec.V1, col );
cache.vertices[index++] = new VertexPos3fTex2fCol4b( pos.X + Make( maxBB.X ), pos.Y + Make( maxBB.Y ),
pos.Z + z, rec.U1, rec.V2, col );
}
@ -118,18 +118,18 @@ namespace ClassicalSharp {
FlushIfNotSame();
FastColour col = fullBright ? colNormal : colXSide;
float vOrigin = rec.V1;
float vOrigin = (texLoc % atlas.elementsPerAtlas1D) * atlas.invElementSize;
rec.U1 = minBB.Z; rec.U2 = maxBB.Z;
rec.V1 = vOrigin + minBB.Y * atlas.invElementSize;
rec.V2 = vOrigin + maxBB.Y * atlas.invElementSize * 15.99f/16f;
rec.V1 = vOrigin + (1 - minBB.Y) * atlas.invElementSize;
rec.V2 = vOrigin + (1 - maxBB.Y) * atlas.invElementSize * 15.99f/16f;
cache.vertices[index++] = new VertexPos3fTex2fCol4b( pos.X + x, pos.Y + Make( minBB.Y ),
cache.vertices[index++] = new VertexPos3fTex2fCol4b( pos.X + x, pos.Y + Make( maxBB.Y ),
pos.Z + Make( minBB.Z ), rec.U2, rec.V2, col );
cache.vertices[index++] = new VertexPos3fTex2fCol4b( pos.X + x, pos.Y + Make( maxBB.Y ),
pos.Z + Make( minBB.Z ), rec.U2, rec.V1, col );
cache.vertices[index++] = new VertexPos3fTex2fCol4b( pos.X + x, pos.Y + Make( maxBB.Y ),
pos.Z + Make( maxBB.Z ), rec.U1, rec.V1, col );
cache.vertices[index++] = new VertexPos3fTex2fCol4b( pos.X + x, pos.Y + Make( minBB.Y ),
pos.Z + Make( minBB.Z ), rec.U2, rec.V1, col );
cache.vertices[index++] = new VertexPos3fTex2fCol4b( pos.X + x, pos.Y + Make( minBB.Y ),
pos.Z + Make( maxBB.Z ), rec.U1, rec.V1, col );
cache.vertices[index++] = new VertexPos3fTex2fCol4b( pos.X + x, pos.Y + Make( maxBB.Y ),
pos.Z + Make( maxBB.Z ), rec.U1, rec.V2, col );
}

View File

@ -45,10 +45,9 @@ namespace ClassicalSharp {
int x = (int)(X + barXOffset + (elemSize + borderSize) * i + elemSize / 2);
int y = (int)(game.Height - barHeight / 2);
float scale = (elemSize * 14/16f) / 2f;
float scale = (elemSize * 13.5f/16f) / 2f;
IsometricBlockDrawer.Draw( game, block, scale, x, y );
}
RenderSelected();
graphicsApi.Texturing = false;
}
@ -56,16 +55,13 @@ namespace ClassicalSharp {
int texId = game.UseClassicGui ? game.GuiClassicTexId : game.GuiTexId;
backTex.ID = texId;
backTex.Render( graphicsApi );
}
void RenderSelected() {
int texId = game.UseClassicGui ? game.GuiClassicTexId : game.GuiTexId;
int i = game.Inventory.HeldBlockIndex;
int x = (int)(X + barXOffset + (elemSize + borderSize) * i + elemSize / 2);
selTex.ID = texId;
selTex.X1 = (int)(x - selBlockSize / 2);
selTex.Render( graphicsApi );
graphicsApi.Draw2DTexture( ref selTex );
}
public override void Dispose() { }

View File

@ -31,6 +31,8 @@ namespace ClassicalSharp {
int defaultHeight;
readonly Font font;
public string[] Description;
public override void Init() {
DrawTextArgs args = new DrawTextArgs( "I", font, true );
defaultHeight = game.Drawer2D.MeasureSize( ref args ).Height;

View File

@ -106,7 +106,7 @@ namespace ClassicalSharp.Model {
FlushIfNotSame( texIndex );
FastColour col = bright ? FastColour.White : FastColour.Scale( this.col, shade );
float vOrigin = rec.V1;
float vOrigin = (texId % atlas.elementsPerAtlas1D) * atlas.invElementSize;
rec.U1 = minBB.X; rec.U2 = maxBB.X;
rec.V1 = vOrigin + minBB.Z * atlas.invElementSize;
rec.V2 = vOrigin + maxBB.Z * atlas.invElementSize * 15.99f/16f;
@ -123,16 +123,16 @@ namespace ClassicalSharp.Model {
FlushIfNotSame( texIndex );
FastColour col = bright ? FastColour.White : FastColour.Scale( this.col, shade );
float vOrigin = rec.V1;
float vOrigin = (texId % atlas.elementsPerAtlas1D) * atlas.invElementSize;
rec.U1 = minBB.X; rec.U2 = maxBB.X;
rec.V1 = vOrigin + minBB.Y * atlas.invElementSize;
rec.V2 = vOrigin + maxBB.Y * atlas.invElementSize * 15.99f/16f;
rec.V1 = vOrigin + (1 - minBB.Y) * atlas.invElementSize;
rec.V2 = vOrigin + (1 - maxBB.Y) * atlas.invElementSize * 15.99f/16f;
if( swapU ) rec.SwapU();
cache.vertices[index++] = new VertexPos3fTex2fCol4b( minBB.X - 0.5f, 0, z, rec.U1, rec.V2, col );
cache.vertices[index++] = new VertexPos3fTex2fCol4b( minBB.X - 0.5f, height, z, rec.U1, rec.V1, col );
cache.vertices[index++] = new VertexPos3fTex2fCol4b( maxBB.X - 0.5f, height, z, rec.U2, rec.V1, col );
cache.vertices[index++] = new VertexPos3fTex2fCol4b( maxBB.X - 0.5f, 0, z, rec.U2, rec.V2, col );
cache.vertices[index++] = new VertexPos3fTex2fCol4b( minBB.X - 0.5f, 0, z, rec.U1, rec.V1, col );
cache.vertices[index++] = new VertexPos3fTex2fCol4b( minBB.X - 0.5f, height, z, rec.U1, rec.V2, col );
cache.vertices[index++] = new VertexPos3fTex2fCol4b( maxBB.X - 0.5f, height, z, rec.U2, rec.V2, col );
cache.vertices[index++] = new VertexPos3fTex2fCol4b( maxBB.X - 0.5f, 0, z, rec.U2, rec.V1, col );
}
void XQuad( float x, int side, bool swapU, float shade ) {
@ -141,16 +141,16 @@ namespace ClassicalSharp.Model {
FlushIfNotSame( texIndex );
FastColour col = bright ? FastColour.White : FastColour.Scale( this.col, shade );
float vOrigin = rec.V1;
float vOrigin = (texId % atlas.elementsPerAtlas1D) * atlas.invElementSize;
rec.U1 = minBB.Z; rec.U2 = maxBB.Z;
rec.V1 = vOrigin + minBB.Y * atlas.invElementSize;
rec.V2 = vOrigin + maxBB.Y * atlas.invElementSize * 15.99f/16f;
rec.V1 = vOrigin + (1 - minBB.Y) * atlas.invElementSize;
rec.V2 = vOrigin + (1 - maxBB.Y) * atlas.invElementSize * 15.99f/16f;
if( swapU ) rec.SwapU();
cache.vertices[index++] = new VertexPos3fTex2fCol4b( x, 0, minBB.Z - 0.5f, rec.U1, rec.V2, col );
cache.vertices[index++] = new VertexPos3fTex2fCol4b( x, height, minBB.Z - 0.5f, rec.U1, rec.V1, col );
cache.vertices[index++] = new VertexPos3fTex2fCol4b( x, height, maxBB.Z - 0.5f, rec.U2, rec.V1, col );
cache.vertices[index++] = new VertexPos3fTex2fCol4b( x, 0, maxBB.Z - 0.5f, rec.U2, rec.V2, col );
cache.vertices[index++] = new VertexPos3fTex2fCol4b( x, 0, minBB.Z - 0.5f, rec.U1, rec.V1, col );
cache.vertices[index++] = new VertexPos3fTex2fCol4b( x, height, minBB.Z - 0.5f, rec.U1, rec.V2, col );
cache.vertices[index++] = new VertexPos3fTex2fCol4b( x, height, maxBB.Z - 0.5f, rec.U2, rec.V2, col );
cache.vertices[index++] = new VertexPos3fTex2fCol4b( x, 0, maxBB.Z - 0.5f, rec.U2, rec.V1, col );
}
void SpriteZQuad( int side, bool firstPart ) {