Add a -transparent-dim=percent flag to set the extra dimming of transparent materials each depth meter.

This commit is contained in:
Sascha L. Teichmann
2015-07-26 11:55:38 +02:00
parent 68bb1ee320
commit e1eb03813f
7 changed files with 81 additions and 37 deletions

View File

@ -45,7 +45,7 @@ func order(a, b int) (int, int) {
func createBaseLevel(
address string,
xMin, zMin, xMax, zMax int,
transparent bool,
transparent bool, transparentDim float32,
colorsFile, outDir string,
numWorkers int) (err error) {
@ -55,6 +55,8 @@ func createBaseLevel(
return
}
colors.TransparentDim = transparentDim
baseDir := filepath.Join(outDir, baseLevelDir)
if err = os.MkdirAll(baseDir, os.ModePerm); err != nil {
return

View File

@ -8,20 +8,23 @@ import (
"flag"
"fmt"
"log"
"bitbucket.org/s_l_teichmann/mtsatellite/common"
)
func main() {
var (
port int
host string
xMin, zMin int
xMax, zMax int
colorsFile string
outDir string
numWorkers int
skipBaseLevel bool
skipPyramid bool
transparent bool
port int
host string
xMin, zMin int
xMax, zMax int
colorsFile string
outDir string
numWorkers int
skipBaseLevel bool
skipPyramid bool
transparent bool
transparentDim float64
)
flag.IntVar(&port, "port", 6379, "port to of mtredisalize server")
@ -42,15 +45,22 @@ func main() {
flag.BoolVar(&skipPyramid, "sp", false, "Do not generate pyramid tiles (shorthand)")
flag.BoolVar(&transparent, "transparent", false, "Render transparent blocks.")
flag.BoolVar(&transparent, "t", false, "Render transparent blocks (shorthand).")
flag.Float64Var(&transparentDim,
"transparent-dim", common.DefaultTransparentDim*100.0,
"Extra dimming of transparent nodes each depth meter in percent.")
flag.Float64Var(&transparentDim,
"td", common.DefaultTransparentDim*100.0,
"Extra fimming of transparent nodes each depth meter in percent. (shorthand)")
flag.Parse()
if !skipBaseLevel {
td := common.Clamp32f(float32(transparentDim/100.0), 0.0, 1.0)
address := fmt.Sprintf("%s:%d", host, port)
if err := createBaseLevel(
address,
xMin, zMin, xMax, zMax,
transparent,
transparent, td,
colorsFile,
outDir,
numWorkers); err != nil {

View File

@ -27,6 +27,7 @@ func main() {
shaded bool
transparent bool
cpuProfile string
transparentDim float64
)
flag.IntVar(&port, "port", 6379, "port to of mtredisalize server")
@ -46,6 +47,9 @@ func main() {
flag.StringVar(&outfile, "o", "out.png", "image file of result (shorthand)")
flag.BoolVar(&shaded, "shaded", true, "draw relief")
flag.BoolVar(&transparent, "transparent", false, "render transparent blocks")
flag.Float64Var(
&transparentDim, "transparent-dim", common.DefaultTransparentDim*100,
"Extra dimming of transparent nodes every depth meter in percent (0-100).")
flag.StringVar(&cpuProfile, "cpuprofile", "", "write cpu profile to file")
flag.Parse()
@ -66,6 +70,9 @@ func main() {
log.Fatalf("Cannot open color file: %s", err)
}
colors.TransparentDim = common.Clamp32f(
float32(transparentDim/100.0), 0.0, 100.0)
address := fmt.Sprintf("%s:%d", host, port)
var client *common.RedisClient

View File

@ -18,18 +18,19 @@ import (
func main() {
var (
webPort int
webHost string
webDir string
mapDir string
redisPort int
redisHost string
colorsFile string
workers int
transparent bool
updateHosts string
websockets bool
playersFIFO string
webPort int
webHost string
webDir string
mapDir string
redisPort int
redisHost string
colorsFile string
workers int
transparent bool
transparentDim float64
updateHosts string
websockets bool
playersFIFO string
)
flag.IntVar(&webPort, "web-port", 8808, "port of the web server")
flag.IntVar(&webPort, "p", 8808, "port of the web server (shorthand)")
@ -52,6 +53,12 @@ func main() {
flag.StringVar(&colorsFile, "c", "colors.txt", "colors used to render map tiles (shorthand).")
flag.BoolVar(&transparent, "transparent", false, "Render transparent blocks.")
flag.BoolVar(&transparent, "t", false, "Render transparent blocks (shorthand).")
flag.Float64Var(&transparentDim,
"transparent-dim", common.DefaultTransparentDim*100.0,
"Extra dimming of transparent nodes each depth meter in percent.")
flag.Float64Var(&transparentDim,
"td", common.DefaultTransparentDim*100.0,
"Extra fimming of transparent nodes each depth meter in percent. (shorthand)")
flag.BoolVar(&websockets, "websockets", false, "Forward tile changes to clients via websockets.")
flag.BoolVar(&websockets, "ws", false, "Forward tile changes to clients via websockets (shorthand).")
flag.StringVar(&playersFIFO, "players", "", "Path to FIFO file to read active players from.")
@ -86,6 +93,8 @@ func main() {
if colors, err = common.ParseColors(colorsFile); err != nil {
log.Fatalf("ERROR: problem loading colors: %s", err)
}
colors.TransparentDim = common.Clamp32f(
float32(transparentDim/100.0), 0.0, 100.0)
redisAddress := fmt.Sprintf("%s:%d", redisHost, redisPort)
var allowedUpdateIps []net.IP