mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2025-01-23 14:50:19 +01:00
Cut off border blocks when in shaded output mode.
This commit is contained in:
parent
223d11df0b
commit
afca241c12
@ -28,14 +28,14 @@ func main() {
|
|||||||
flag.IntVar(&port, "port", 6379, "port to of mtredisalize server")
|
flag.IntVar(&port, "port", 6379, "port to of mtredisalize server")
|
||||||
flag.IntVar(&port, "p", 6379, "port to of mtredisalize server (shorthand)")
|
flag.IntVar(&port, "p", 6379, "port to of mtredisalize server (shorthand)")
|
||||||
flag.StringVar(&host, "host", "localhost", "host to mtredisalize server")
|
flag.StringVar(&host, "host", "localhost", "host to mtredisalize server")
|
||||||
flag.IntVar(&x, "x", -9, "x of query cuboid")
|
flag.IntVar(&x, "x", 0, "x of query cuboid")
|
||||||
flag.IntVar(&y, "y", -75, "y of query cuboid")
|
flag.IntVar(&y, "y", -75, "y of query cuboid")
|
||||||
flag.IntVar(&z, "z", -9, "z of query cuboid")
|
flag.IntVar(&z, "z", 0, "z of query cuboid")
|
||||||
flag.IntVar(&width, "width", 18, "width of query cuboid")
|
flag.IntVar(&width, "width", 16, "width of query cuboid")
|
||||||
flag.IntVar(&height, "height", 18, "height of query cuboid")
|
flag.IntVar(&height, "height", 16, "height of query cuboid")
|
||||||
flag.IntVar(&depth, "depth", 150, "depth of query cuboid")
|
flag.IntVar(&depth, "depth", 150, "depth of query cuboid")
|
||||||
flag.IntVar(&width, "w", 18, "width of query cuboid (shorthand)")
|
flag.IntVar(&width, "w", 16, "width of query cuboid (shorthand)")
|
||||||
flag.IntVar(&height, "h", 18, "height of query cuboid (shorthand)")
|
flag.IntVar(&height, "h", 16, "height of query cuboid (shorthand)")
|
||||||
flag.IntVar(&depth, "d", 150, "depth of query cuboid (shorthand)")
|
flag.IntVar(&depth, "d", 150, "depth of query cuboid (shorthand)")
|
||||||
flag.StringVar(&colorsfile, "colors", "colors.txt", "definition of colors")
|
flag.StringVar(&colorsfile, "colors", "colors.txt", "definition of colors")
|
||||||
flag.StringVar(&outfile, "output", "out.png", "image file of result")
|
flag.StringVar(&outfile, "output", "out.png", "image file of result")
|
||||||
@ -60,11 +60,18 @@ func main() {
|
|||||||
}
|
}
|
||||||
defer client.Close()
|
defer client.Close()
|
||||||
|
|
||||||
|
if shaded {
|
||||||
|
width += 2
|
||||||
|
height += 2
|
||||||
|
x--
|
||||||
|
z--
|
||||||
|
}
|
||||||
|
|
||||||
q1x, q1y, q1z := int16(x), int16(y), int16(z)
|
q1x, q1y, q1z := int16(x), int16(y), int16(z)
|
||||||
q2x, q2y, q2z := q1x+int16(width)-1, q1y+int16(depth)-1, q1z+int16(height)-1
|
q2x, q2y, q2z := q1x+int16(width)-1, q1y+int16(depth)-1, q1z+int16(height)-1
|
||||||
|
|
||||||
renderer := NewRenderer(q1x, q1z, width, height)
|
renderer := NewRenderer(q1x, q1z, width, height)
|
||||||
yOrder := NewYOrder(renderer, 512)
|
yOrder := NewYOrder(renderer, 1024)
|
||||||
|
|
||||||
numBlocks := 0
|
numBlocks := 0
|
||||||
drawBlock := func(block *common.Block) {
|
drawBlock := func(block *common.Block) {
|
||||||
@ -97,6 +104,7 @@ func main() {
|
|||||||
|
|
||||||
if shaded {
|
if shaded {
|
||||||
image = renderer.CreateShadedImage(
|
image = renderer.CreateShadedImage(
|
||||||
|
16, 16, (width-2)*16, (height-2)*16,
|
||||||
colors.Colors, color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff})
|
colors.Colors, color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff})
|
||||||
} else {
|
} else {
|
||||||
image = renderer.CreateImage(
|
image = renderer.CreateImage(
|
||||||
|
@ -226,12 +226,20 @@ func safeColor(x int32) uint8 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Renderer) CreateShadedImage(colors []color.RGBA, background color.RGBA) *image.RGBA {
|
func (r *Renderer) CreateShadedImage(
|
||||||
pw, ph := r.width<<4, r.height<<4
|
xOfs, zOfs, width, height int,
|
||||||
image := image.NewRGBA(image.Rect(0, 0, pw, ph))
|
colors []color.RGBA, background color.RGBA) *image.RGBA {
|
||||||
ofs, numCols := 0, int32(len(colors))
|
|
||||||
for z := ph - 1; z >= 0; z-- {
|
image := image.NewRGBA(image.Rect(0, 0, width, height))
|
||||||
for x := 0; x < pw; x++ {
|
|
||||||
|
pw := r.width << 4
|
||||||
|
|
||||||
|
ofs, numCols := zOfs*pw+xOfs, int32(len(colors))
|
||||||
|
|
||||||
|
stride := pw - width
|
||||||
|
|
||||||
|
for z := height - 1; z >= 0; z-- {
|
||||||
|
for x := 0; x < width; x++ {
|
||||||
colIdx := r.cBuffer[ofs]
|
colIdx := r.cBuffer[ofs]
|
||||||
if colIdx < 0 || colIdx >= numCols {
|
if colIdx < 0 || colIdx >= numCols {
|
||||||
image.Set(x, z, background)
|
image.Set(x, z, background)
|
||||||
@ -261,6 +269,7 @@ func (r *Renderer) CreateShadedImage(colors []color.RGBA, background color.RGBA)
|
|||||||
}
|
}
|
||||||
ofs++
|
ofs++
|
||||||
}
|
}
|
||||||
|
ofs += stride
|
||||||
}
|
}
|
||||||
return image
|
return image
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user