public void saveTo(String rootDirPath) throws ParserConfigurationException,
			TransformerException, IOException {
		if (currentPath == null) {
			return;
		}
		input.deselect();
		DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory
				.newInstance();
		DocumentBuilder docB = documentBuilderFactory.newDocumentBuilder();
		Document doc = docB.newDocument();
		Element level = doc.createElement("level");
		doc.appendChild(level);
		writeEnvironment(doc);
		writeLights(doc);
		writeRigidBodies(doc);

		File rootDir = new File(rootDirPath);
		if (rootDir.exists()) {
			if (!clearDir(rootDir)) {
				JOptionPane.showMessageDialog(null,
						"Unable to clear directory.");
				return;
			}
		}
		rootDir.mkdirs();
		File levelFile = new File(rootDirPath + File.separator + LEVEL_DATA);
		levelFile.createNewFile();
		ResourceController.writeXML(levelFile.toString(), doc);
		File assetDir = new File(rootDirPath + File.separator + "assets");
		assetDir.mkdirs();
		assetLibrary.writeAllAssets(rootDirPath);
		currentPath = rootDirPath;
	}