Start structuring for shaders and perspectives

This commit is contained in:
Mike Primm 2011-07-08 01:34:22 -05:00
parent ae190b3c57
commit 52f23f5e2d
8 changed files with 82 additions and 6 deletions

1
perspectives.txt Normal file
View File

@ -0,0 +1 @@
perspectives:

18
shaders.txt Normal file
View File

@ -0,0 +1,18 @@
shaders:
- class: org.dynmap.hdmap.DefaultHDShader
name: classic
colorscheme: default
- class: org.dynmap.hdmap.DefaultHDShader
name: night
colorscheme: default
ambientlight: 4
shadowstrength: 1.0
- class: org.dynmap.hdmap.DefaultHDShader
name: daynight
colorscheme: default
ambientlight: 4
shadowstrength: 1.0
night-and-day: true

View File

@ -27,7 +27,9 @@
<directory>${project.basedir}</directory> <directory>${project.basedir}</directory>
<outputDirectory>/dynmap/</outputDirectory> <outputDirectory>/dynmap/</outputDirectory>
<includes> <includes>
<include>configuration.txt</include></includes></fileSet> <include>configuration.txt</include>
<include>shaders.txt</include>
<include>perspectives.txt</include></includes></fileSet>
</fileSets> </fileSets>
<files> <files>
<file> <file>

View File

@ -46,6 +46,8 @@ public class DynmapPlugin extends JavaPlugin {
public MapManager mapManager = null; public MapManager mapManager = null;
public PlayerList playerList; public PlayerList playerList;
public ConfigurationNode configuration; public ConfigurationNode configuration;
public ConfigurationNode shaderconfig;
public ConfigurationNode perspectiveconfig;
public HashSet<String> enabledTriggers = new HashSet<String>(); public HashSet<String> enabledTriggers = new HashSet<String>();
public PermissionProvider permissions; public PermissionProvider permissions;
public ComponentManager componentManager = new ComponentManager(); public ComponentManager componentManager = new ComponentManager();
@ -77,6 +79,13 @@ public class DynmapPlugin extends JavaPlugin {
org.bukkit.util.config.Configuration bukkitConfiguration = new org.bukkit.util.config.Configuration(new File(this.getDataFolder(), "configuration.txt")); org.bukkit.util.config.Configuration bukkitConfiguration = new org.bukkit.util.config.Configuration(new File(this.getDataFolder(), "configuration.txt"));
bukkitConfiguration.load(); bukkitConfiguration.load();
configuration = new ConfigurationNode(bukkitConfiguration); configuration = new ConfigurationNode(bukkitConfiguration);
/* Load shaders and perspectives */
org.bukkit.util.config.Configuration bukkitShaderConfig = new org.bukkit.util.config.Configuration(new File(this.getDataFolder(), "shaders.txt"));
bukkitShaderConfig.load();
shaderconfig = new ConfigurationNode(bukkitShaderConfig);
org.bukkit.util.config.Configuration bukkitPerspectiveConfig = new org.bukkit.util.config.Configuration(new File(this.getDataFolder(), "perspectives.txt"));
bukkitPerspectiveConfig.load();
perspectiveconfig = new ConfigurationNode(bukkitPerspectiveConfig);
Log.verbose = configuration.getBoolean("verbose", true); Log.verbose = configuration.getBoolean("verbose", true);
@ -90,7 +99,7 @@ public class DynmapPlugin extends JavaPlugin {
playerList = new PlayerList(getServer(), getFile("hiddenplayers.txt"), configuration); playerList = new PlayerList(getServer(), getFile("hiddenplayers.txt"), configuration);
playerList.load(); playerList.load();
mapManager = new MapManager(this, configuration); mapManager = new MapManager(this, configuration, shaderconfig, perspectiveconfig);
mapManager.startRendering(); mapManager.startRendering();
loadWebserver(); loadWebserver();

View File

@ -21,6 +21,8 @@ import org.bukkit.scheduler.BukkitScheduler;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.dynmap.DynmapWorld.AutoGenerateOption; import org.dynmap.DynmapWorld.AutoGenerateOption;
import org.dynmap.debug.Debug; import org.dynmap.debug.Debug;
import org.dynmap.hdmap.HDMapManager;
import org.dynmap.hdmap.HDShader;
import org.dynmap.utils.LegacyMapChunkCache; import org.dynmap.utils.LegacyMapChunkCache;
import org.dynmap.utils.MapChunkCache; import org.dynmap.utils.MapChunkCache;
import org.dynmap.utils.NewMapChunkCache; import org.dynmap.utils.NewMapChunkCache;
@ -48,6 +50,7 @@ public class MapManager {
public static final Object lock = new Object(); public static final Object lock = new Object();
public static MapManager mapman; /* Our singleton */ public static MapManager mapman; /* Our singleton */
public HDMapManager hdmapman;
/* Thread pool for processing renders */ /* Thread pool for processing renders */
private DynmapScheduledThreadPoolExecutor renderpool; private DynmapScheduledThreadPoolExecutor renderpool;
@ -319,9 +322,13 @@ public class MapManager {
} }
} }
public MapManager(DynmapPlugin plugin, ConfigurationNode configuration) { public MapManager(DynmapPlugin plugin, ConfigurationNode configuration, ConfigurationNode shadercfg, ConfigurationNode perspectivecfg) {
plug_in = plugin; plug_in = plugin;
mapman = this; mapman = this;
/* Initialize HD map manager */
hdmapman = new HDMapManager();
hdmapman.loadHDShaders(shadercfg);
hdmapman.loadHDPerspectives(perspectivecfg);
this.tileQueue = new AsynchronousQueue<MapTile>(new Handler<MapTile>() { this.tileQueue = new AsynchronousQueue<MapTile>(new Handler<MapTile>() {
@Override @Override

View File

@ -38,7 +38,7 @@ public class DefaultHDShader implements HDShader {
public DefaultHDShader(ConfigurationNode configuration) { public DefaultHDShader(ConfigurationNode configuration) {
this.configuration = configuration; this.configuration = configuration;
name = (String) configuration.get("prefix"); name = (String) configuration.get("name");
double shadowweight = configuration.getDouble("shadowstrength", 0.0); double shadowweight = configuration.getDouble("shadowstrength", 0.0);
if(shadowweight > 0.0) { if(shadowweight > 0.0) {
shadowscale = new int[16]; shadowscale = new int[16];
@ -61,7 +61,7 @@ public class DefaultHDShader implements HDShader {
lightscale[i] = i - (15-v); lightscale[i] = i - (15-v);
} }
} }
colorScheme = ColorScheme.getScheme((String)configuration.get("colorscheme")); colorScheme = ColorScheme.getScheme(configuration.getString("colorscheme", "default"));
night_and_day = configuration.getBoolean("night-and-day", false); night_and_day = configuration.getBoolean("night-and-day", false);
transparency = configuration.getBoolean("transparency", true); /* Default on */ transparency = configuration.getBoolean("transparency", true); /* Default on */
String biomeopt = configuration.getString("biomecolored", "none"); String biomeopt = configuration.getString("biomecolored", "none");

View File

@ -0,0 +1,33 @@
package org.dynmap.hdmap;
import java.util.HashMap;
import org.dynmap.ConfigurationNode;
import org.dynmap.Log;
public class HDMapManager {
public HashMap<String, HDShader> shaders = new HashMap<String, HDShader>();
public HashMap<String, HDPerspective> perspectives = new HashMap<String, HDPerspective>();
public void loadHDShaders(ConfigurationNode shadercfg) {
Log.verboseinfo("Loading shaders...");
for(HDShader shader : shadercfg.<HDShader>createInstances("shaders", new Class<?>[0], new Object[0])) {
if(shaders.containsKey(shader.getName())) {
Log.severe("Duplicate shader name '" + shader.getName() + "' - shader ignored");
}
shaders.put(shader.getName(), shader);
}
Log.info("Loaded " + shaders.size() + " shaders.");
}
public void loadHDPerspectives(ConfigurationNode perspectivecfg) {
Log.verboseinfo("Loading perspectives...");
for(HDPerspective perspective : perspectivecfg.<HDPerspective>createInstances("perspectives", new Class<?>[0], new Object[0])) {
if(perspectives.containsKey(perspective.getName())) {
Log.severe("Duplicate perspective name '" + perspective.getName() + "' - perspective ignored");
}
perspectives.put(perspective.getName(), perspective);
}
Log.info("Loaded " + perspectives.size() + " perspectives.");
}
}

View File

@ -0,0 +1,6 @@
package org.dynmap.hdmap;
public interface HDPerspective {
/* Get name of perspective */
String getName();
}