示例#1
0
  public void removeObject(String name) {
    // Can't Delete The Root
    if (name.equals(ROOT_NODE_NAME)) return;
    objects.remove(name);
    for (SceneObject o : objects) {
      if (o.parent != null && o.parent.equals(name)) o.parent = ROOT_NODE_NAME;
    }

    sendEvent(new SceneCollectionModifiedEvent(SceneDataType.Object, name, false));
  }
示例#2
0
 @Override
 public void render(GameContainer gc, Graphics graphics) {
   super.render(gc, graphics);
 }
示例#3
0
 @Override
 public void update(GameContainer gameContainer, int delta) {
   super.update(gameContainer, delta);
 }
示例#4
0
 public void addSceneObject(SceneObject obj) {
   obj.setScene(this);
   objs.add(obj);
 }
 public void draw() {
   activeSceneObject.doDraw();
 }
示例#6
0
  public void saveData(String file) throws ParserConfigurationException, TransformerException {
    DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder = docFactory.newDocumentBuilder();

    // Scene Root
    Document doc = docBuilder.newDocument();
    Element rootElement = doc.createElement("scene");
    doc.appendChild(rootElement);

    // Textures
    for (Texture o : textures) {
      if (DEFAULT_TEXTURES.contains(o.getID().name)) continue;

      Element e = doc.createElement("texture");
      Element tName = doc.createElement("name");
      tName.appendChild(doc.createTextNode(o.getID().name));
      e.appendChild(tName);

      Element eData = doc.createElement("data");
      o.saveData(doc, eData);
      e.appendChild(eData);

      rootElement.appendChild(e);
    }

    // Cube maps
    for (Cubemap o : cubemaps) {
      if (DEFAULT_TEXTURES.contains(o.getID().name)) continue;

      Element e = doc.createElement("cubemap");
      Element tName = doc.createElement("name");
      tName.appendChild(doc.createTextNode(o.getID().name));
      e.appendChild(tName);

      Element eData = doc.createElement("data");
      o.saveData(doc, eData);
      e.appendChild(eData);

      rootElement.appendChild(e);
    }

    // Meshes
    for (Mesh o : meshes) {
      if (DEFAULT_MESHES.contains(o.getID().name)) continue;

      Element e = doc.createElement("mesh");
      Element tName = doc.createElement("name");
      tName.appendChild(doc.createTextNode(o.getID().name));
      e.appendChild(tName);

      Element eData = doc.createElement("data");
      o.saveData(doc, eData);
      e.appendChild(eData);

      rootElement.appendChild(e);
    }

    // Materials
    for (Material o : materials) {
      if (DEFAULT_MATERIALS.contains(o.getID().name)) continue;

      Element e = doc.createElement("material");
      Element tName = doc.createElement("name");
      tName.appendChild(doc.createTextNode(o.getID().name));
      e.appendChild(tName);

      Element eData = doc.createElement("data");
      o.saveData(doc, eData);
      e.appendChild(eData);

      rootElement.appendChild(e);
    }

    // Objects
    for (SceneObject o : objects) {
      if (o.getID().name.equals(ROOT_NODE_NAME)) continue;

      Element e = doc.createElement("object");
      Element tName = doc.createElement("name");
      tName.appendChild(doc.createTextNode(o.getID().name));
      e.appendChild(tName);

      Element eData = doc.createElement("data");
      o.saveData(doc, eData);
      e.appendChild(eData);

      rootElement.appendChild(e);
    }

    // write the content into xml file
    TransformerFactory transformerFactory = TransformerFactory.newInstance();
    Transformer transformer = transformerFactory.newTransformer();
    transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
    DOMSource source = new DOMSource(doc);
    StreamResult result = new StreamResult(new File(file));
    transformer.transform(source, result);
  }