Search in sources :

Example 16 with PropertyModelClass

use of net.drewke.tdme.tools.shared.model.PropertyModelClass in project tdme by andreasdr.

the class LevelEditorView method updateGUIElements.

/**
	 * Update GUI elements
	 * 	screen caption
	 *  level size
	 *  selected object
	 *		object properties
	 *		object 3d transformations
	 *		object data  
	 */
private void updateGUIElements() {
    levelEditorScreenController.setScreenCaption("Level Editor - " + level.getFileName());
    levelEditorScreenController.setLevelSize(level.getDimension().getX(), level.getDimension().getZ(), level.getDimension().getY());
    if (selectedObjects.size() == 1) {
        Entity selectedObject = selectedObjects.get(0);
        if (selectedObject != null && selectedObject.getId().startsWith("leveleditor.") == false) {
            LevelEditorObject levelEditorObject = level.getObjectById(selectedObject.getId());
            PropertyModelClass preset = levelEditorObject.getProperty("preset");
            levelEditorScreenController.setObjectProperties(preset != null ? preset.getValue() : "", levelEditorObject.getProperties(), null);
            levelEditorScreenController.setObject(selectedObject.getTranslation(), selectedObject.getScale(), selectedObject.getRotations().get(level.getRotationOrder().getAxisXIndex()).getAngle(), selectedObject.getRotations().get(level.getRotationOrder().getAxisYIndex()).getAngle(), selectedObject.getRotations().get(level.getRotationOrder().getAxisZIndex()).getAngle());
            // determine center
            Vector3 objectCenter = null;
            if (levelEditorObject.getEntity().getModel() != null) {
                BoundingVolume bv = levelEditorObject.getEntity().getModel().getBoundingBox().clone();
                bv.fromBoundingVolumeWithTransformations(bv, levelEditorObject.getTransformations());
                objectCenter = bv.getCenter();
            } else {
                // TODO: this is not the center, applies currently to particle systems
                objectCenter = levelEditorObject.getTransformations().getTranslation();
            }
            //
            levelEditorScreenController.setObjectData(levelEditorObject.getId(), levelEditorObject.getDescription(), levelEditorObject.getEntity().getName(), objectCenter);
        } else {
            levelEditorScreenController.unsetObjectData();
            levelEditorScreenController.unsetObject();
            levelEditorScreenController.unsetObjectProperties();
        }
    } else if (selectedObjects.size() > 1) {
        levelEditorScreenController.unsetObjectData();
        levelEditorScreenController.setObject(new Vector3(0f, 0f, 0f), new Vector3(1f, 1f, 1f), 0f, 0f, 0f);
        levelEditorScreenController.unsetObjectProperties();
    } else if (selectedObjects.size() == 0) {
        levelEditorScreenController.unsetObjectData();
        levelEditorScreenController.unsetObject();
        levelEditorScreenController.unsetObjectProperties();
    }
    // set up lights
    for (int i = 0; i < 4; i++) {
        levelEditorScreenController.setLight(i, level.getLightAt(i).getAmbient(), level.getLightAt(i).getDiffuse(), level.getLightAt(i).getSpecular(), level.getLightAt(i).getPosition(), level.getLightAt(i).getConstantAttenuation(), level.getLightAt(i).getLinearAttenuation(), level.getLightAt(i).getQuadraticAttenuation(), level.getLightAt(i).getSpotTo(), level.getLightAt(i).getSpotDirection(), level.getLightAt(i).getSpotExponent(), level.getLightAt(i).getSpotCutOff(), level.getLightAt(i).isEnabled());
    }
}
Also used : Entity(net.drewke.tdme.engine.Entity) LevelEditorEntity(net.drewke.tdme.tools.shared.model.LevelEditorEntity) FacesEntity(net.drewke.tdme.engine.model.FacesEntity) PropertyModelClass(net.drewke.tdme.tools.shared.model.PropertyModelClass) BoundingVolume(net.drewke.tdme.engine.primitives.BoundingVolume) Vector3(net.drewke.tdme.math.Vector3) LevelEditorObject(net.drewke.tdme.tools.shared.model.LevelEditorObject)

Example 17 with PropertyModelClass

use of net.drewke.tdme.tools.shared.model.PropertyModelClass in project tdme by andreasdr.

the class TriggerView method updateGUIElements.

/**
	 * Init GUI elements
	 */
public void updateGUIElements() {
    if (entity != null) {
        triggerScreenController.setScreenCaption("Trigger - " + entity.getName());
        PropertyModelClass preset = entity.getProperty("preset");
        triggerScreenController.setEntityProperties(preset != null ? preset.getValue() : null, entity.getProperties(), null);
        triggerScreenController.setEntityData(entity.getName(), entity.getDescription());
        // trigger
        Vector3 dimension = new Vector3();
        dimension.set(entity.getModel().getBoundingBox().getMax());
        dimension.sub(entity.getModel().getBoundingBox().getMin());
        triggerScreenController.setTrigger(dimension.getX(), dimension.getY(), dimension.getZ());
    } else {
        triggerScreenController.setScreenCaption("Trigger - no trigger loaded");
        triggerScreenController.unsetEntityProperties();
        triggerScreenController.unsetEntityData();
        triggerScreenController.unsetTrigger();
    }
}
Also used : PropertyModelClass(net.drewke.tdme.tools.shared.model.PropertyModelClass) Vector3(net.drewke.tdme.math.Vector3)

Example 18 with PropertyModelClass

use of net.drewke.tdme.tools.shared.model.PropertyModelClass in project tdme by andreasdr.

the class EntityBaseView method entityPropertyRemove.

/**
	 * Remove a entity property from model properties
	 * @param entity
	 * @param name
	 * @return success
	 */
public boolean entityPropertyRemove(LevelEditorEntity entity, String name) {
    if (entity == null)
        return false;
    // try to remove property
    int idx = entity.getPropertyIndex(name);
    if (idx != -1 && entity.removeProperty(name) == true) {
        // get property first at index that was removed 
        PropertyModelClass property = entity.getPropertyByIndex(idx);
        if (property == null) {
            // if current index does not work, take current one -1
            property = entity.getPropertyByIndex(idx - 1);
        }
        // reload model properties
        entityBaseSubScreenController.setEntityProperties(entity, null, entity.getProperties(), property == null ? null : property.getName());
        //
        return true;
    }
    //
    return false;
}
Also used : PropertyModelClass(net.drewke.tdme.tools.shared.model.PropertyModelClass)

Example 19 with PropertyModelClass

use of net.drewke.tdme.tools.shared.model.PropertyModelClass in project tdme by andreasdr.

the class EntityBaseView method entityPropertiesPreset.

/**
	 * Apply entity property preset
	 * @param entity
	 * @param preset id
	 */
public void entityPropertiesPreset(LevelEditorEntity entity, String presetId) {
    if (entity == null)
        return;
    // clear entity properties
    entity.clearProperties();
    // add entity properties by preset if missing
    ArrayList<PropertyModelClass> entityPropertyPresetArrayList = LevelPropertyPresets.getInstance().getObjectPropertiesPresets().get(presetId);
    if (entityPropertyPresetArrayList != null) {
        for (PropertyModelClass entityPropertyPreset : entityPropertyPresetArrayList) {
            entity.addProperty(entityPropertyPreset.getName(), entityPropertyPreset.getValue());
        }
    }
    // update entity properties to gui
    entityBaseSubScreenController.setEntityProperties(entity, presetId, entity.getProperties(), null);
}
Also used : PropertyModelClass(net.drewke.tdme.tools.shared.model.PropertyModelClass)

Example 20 with PropertyModelClass

use of net.drewke.tdme.tools.shared.model.PropertyModelClass in project tdme by andreasdr.

the class LevelEditorScreenController method setObjectProperties.

/**
	 * Set up object properties
	 * @param preset id
	 * @param object properties
	 * @param selected name
	 */
public void setObjectProperties(String presetId, Iterable<PropertyModelClass> objectProperties, String selectedName) {
    objectPropertiesPresets.getController().setDisabled(false);
    btnObjectPropertyPresetApply.getController().setDisabled(false);
    objectPropertiesListBox.getController().setDisabled(false);
    btnObjectPropertyAdd.getController().setDisabled(false);
    btnObjectPropertyRemove.getController().setDisabled(false);
    btnObjectPropertySave.getController().setDisabled(true);
    objectPropertyName.getController().setDisabled(true);
    objectPropertyValue.getController().setDisabled(true);
    // set up preset
    objectPropertiesPresets.getController().setValue(presetId != null ? value.set(presetId) : value.set("none"));
    // object properties list box inner
    GUIParentNode objectPropertiesListBoxInnerNode = (GUIParentNode) (objectPropertiesListBox.getScreenNode().getNodeById(objectPropertiesListBox.getId() + "_inner"));
    // construct XML for sub nodes
    int idx = 1;
    String objectPropertiesListBoxSubNodesXML = "";
    objectPropertiesListBoxSubNodesXML += "<scrollarea-vertical id=\"" + objectPropertiesListBox.getId() + "_inner_scrollarea\" width=\"100%\" height=\"100%\">\n";
    for (PropertyModelClass objectProperty : objectProperties) {
        objectPropertiesListBoxSubNodesXML += "<selectbox-option text=\"" + GUIParser.escapeQuotes(objectProperty.getName()) + ": " + GUIParser.escapeQuotes(objectProperty.getValue()) + "\" value=\"" + GUIParser.escapeQuotes(objectProperty.getName()) + "\" " + (selectedName != null && objectProperty.getName().equals(selectedName) ? "selected=\"true\" " : "") + "/>\n";
    }
    objectPropertiesListBoxSubNodesXML += "</scrollarea-vertical>\n";
    // inject sub nodes
    try {
        objectPropertiesListBoxInnerNode.replaceSubNodes(objectPropertiesListBoxSubNodesXML, false);
    } catch (Exception e) {
        e.printStackTrace();
    }
    //
    onObjectPropertiesSelectionChanged();
}
Also used : PropertyModelClass(net.drewke.tdme.tools.shared.model.PropertyModelClass) GUIParentNode(net.drewke.tdme.gui.nodes.GUIParentNode) MutableString(net.drewke.tdme.utils.MutableString)

Aggregations

PropertyModelClass (net.drewke.tdme.tools.shared.model.PropertyModelClass)23 LevelEditorObject (net.drewke.tdme.tools.shared.model.LevelEditorObject)9 LevelEditorEntity (net.drewke.tdme.tools.shared.model.LevelEditorEntity)7 Entity (net.drewke.tdme.engine.Entity)6 FacesEntity (net.drewke.tdme.engine.model.FacesEntity)5 Vector3 (net.drewke.tdme.math.Vector3)5 BoundingVolume (net.drewke.tdme.engine.primitives.BoundingVolume)3 GUIParentNode (net.drewke.tdme.gui.nodes.GUIParentNode)3 MutableString (net.drewke.tdme.utils.MutableString)3 File (java.io.File)2 IOException (java.io.IOException)2 Object3D (net.drewke.tdme.engine.Object3D)2 Transformations (net.drewke.tdme.engine.Transformations)2 JSONArray (org.json.JSONArray)2 JSONObject (org.json.JSONObject)2 FileOutputStream (java.io.FileOutputStream)1 PrintStream (java.io.PrintStream)1 ObjectParticleSystemEntity (net.drewke.tdme.engine.ObjectParticleSystemEntity)1 PointsParticleSystemEntity (net.drewke.tdme.engine.PointsParticleSystemEntity)1 Rotation (net.drewke.tdme.engine.Rotation)1