mirror of
https://gitlab.com/2009scape/tools/2009scape-map-viewer.git
synced 2026-08-01 14:39:25 -06:00
Sloped wall rendering
This commit is contained in:
parent
daf6c51468
commit
86b4bd0582
1 changed files with 64 additions and 0 deletions
|
|
@ -432,8 +432,72 @@ object Rs2MapEditor {
|
|||
g.drawPolyline(xArray, yArray, nPoints)
|
||||
g.color = color
|
||||
}
|
||||
|
||||
9,7,6,8 -> {
|
||||
if(scenery.id == 85 || scenery.id == 83) return
|
||||
when(scenery.rotation){
|
||||
0,2 -> {pointX1 = 0; pointY1 = height; pointX2 = width; pointY2 = 0}
|
||||
1,3 -> {pointX1 = 0; pointY1 = 0; pointX2 = width; pointY2 = height}
|
||||
}
|
||||
|
||||
val overlayNorth = getOverlayId(scenery.x + 1, scenery.y)
|
||||
val overlaySouth = getOverlayId(scenery.x - 1, scenery.y)
|
||||
val northWest = getOverlayId(scenery.x - 1, scenery.y + 1)
|
||||
val north = getOverlayId(scenery.x, scenery.y + 1)
|
||||
val northEast = getOverlayId(scenery.x + 1, scenery.y + 1)
|
||||
val east = getOverlayId(scenery.x + 1, scenery.y)
|
||||
val southWest = getOverlayId(scenery.x - 1, scenery.y - 1)
|
||||
val south = getOverlayId(scenery.x, scenery.y - 1)
|
||||
val southEast = getOverlayId(scenery.x + 1, scenery.y - 1)
|
||||
val west = getOverlayId(scenery.x - 1, scenery.y)
|
||||
|
||||
var backFillVertice = Pair(0,0)
|
||||
when(scenery.rotation){
|
||||
0, 2 -> {
|
||||
val sumA = getOverlaySum(north, northWest, west)
|
||||
val sumB = getOverlaySum(south, southEast, east)
|
||||
backFillVertice = if(sumA > sumB) Pair(width,height)
|
||||
else if (sumA == sumB) Pair(-1,-1)
|
||||
else Pair(0,0)
|
||||
}
|
||||
1,3 -> {
|
||||
val sumA = getOverlaySum(north, northEast, east)
|
||||
val sumB = getOverlaySum(south, southWest, west)
|
||||
backFillVertice = if(sumA > sumB) Pair(0,height)
|
||||
else if (sumA == sumB) Pair(-1,-1)
|
||||
else Pair(width,0)
|
||||
}
|
||||
}
|
||||
|
||||
val fluDef = getUnderlayColor(scenery.x, scenery.y)
|
||||
g.color = fluDef
|
||||
if(overlaySouth != overlayNorth && backFillVertice.first != -1)
|
||||
g.fillPolygon(intArrayOf(pointX1, pointX2, backFillVertice.first), intArrayOf(pointY1, pointY2, backFillVertice.second), 3)
|
||||
g.color = color
|
||||
g.drawLine(pointX1, pointY1, pointX2, pointY2)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getOverlaySum(vararg overlays: Int): Int{
|
||||
var sum = 0
|
||||
for(overlay in overlays){
|
||||
sum += overlay.coerceAtMost(1)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
fun getUnderlayColor(x: Int, y: Int): Color {
|
||||
var underlayID = (MapTileParser.definition.getTile(x, y, plane).underlayId - 1)
|
||||
if (underlayID < 0) {
|
||||
underlayID = 0
|
||||
}
|
||||
return underlayMap[underlayID]?.getRGB() ?: Color.BLACK
|
||||
}
|
||||
|
||||
fun getOverlayId(x: Int, y: Int): Int {
|
||||
return MapTileParser.definition.getTile(x, y, plane).overlayId
|
||||
}
|
||||
}
|
||||
|
||||
class ScrollPane : JPanel() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue