Search in sources :

Example 6 with PropertyModelClass

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

the class ModelViewerView method updateGUIElements.

/**
	 * Init GUI elements
	 */
public void updateGUIElements() {
    if (entity != null) {
        modelViewerScreenController.setScreenCaption("Model Viewer - " + (entity.getEntityFileName() != null ? Tools.getFileName(entity.getEntityFileName()) : Tools.getFileName(entity.getFileName())));
        PropertyModelClass preset = entity.getProperty("preset");
        modelViewerScreenController.setEntityProperties(preset != null ? preset.getValue() : null, entity.getProperties(), null);
        modelViewerScreenController.setEntityData(entity.getName(), entity.getDescription());
        modelViewerScreenController.setPivot(entity.getPivot());
        entityBoundingVolumeView.setBoundingVolumes(entity);
    } else {
        modelViewerScreenController.setScreenCaption("Model Viewer - no entity loaded");
        modelViewerScreenController.unsetEntityProperties();
        modelViewerScreenController.unsetEntityData();
        modelViewerScreenController.unsetPivot();
        entityBoundingVolumeView.unsetBoundingVolumes();
    }
}
Also used : PropertyModelClass(net.drewke.tdme.tools.shared.model.PropertyModelClass)

Example 7 with PropertyModelClass

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

the class ParticleSystemView method updateGUIElements.

/**
	 * Init GUI elements
	 */
public void updateGUIElements() {
    if (entity != null) {
        particleSystemScreenController.setScreenCaption("Particle System - " + (entity.getEntityFileName() != null ? Tools.getFileName(entity.getEntityFileName()) : entity.getName()));
        PropertyModelClass preset = entity.getProperty("preset");
        particleSystemScreenController.setEntityProperties(preset != null ? preset.getValue() : null, entity.getProperties(), null);
        particleSystemScreenController.setEntityData(entity.getName(), entity.getDescription());
        entityBoundingVolumeView.setBoundingVolumes(entity);
    } else {
        particleSystemScreenController.setScreenCaption("Particle System - no entity loaded");
        particleSystemScreenController.unsetEntityProperties();
        particleSystemScreenController.unsetEntityData();
        entityBoundingVolumeView.unsetBoundingVolumes();
    }
}
Also used : PropertyModelClass(net.drewke.tdme.tools.shared.model.PropertyModelClass)

Example 8 with PropertyModelClass

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

the class LevelEditorView method mapPropertyRemove.

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

Example 9 with PropertyModelClass

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

the class LevelEditorView method objectPropertiesPreset.

/**
	 * Apply object property preset
	 * @param preset id
	 */
public void objectPropertiesPreset(String presetId) {
    if (selectedObjects.size() != 1)
        return;
    // handle single object
    Entity selectedObject = selectedObjects.get(0);
    LevelEditorObject levelEditorObject = level.getObjectById(selectedObject.getId());
    if (levelEditorObject == null)
        return;
    // clear object properties
    levelEditorObject.clearProperties();
    // add object properties by preset if missing
    ArrayList<PropertyModelClass> objectPropertyPresetVector = LevelPropertyPresets.getInstance().getObjectPropertiesPresets().get(presetId);
    if (objectPropertyPresetVector != null) {
        for (PropertyModelClass objectPropertyPreset : objectPropertyPresetVector) {
            levelEditorObject.addProperty(objectPropertyPreset.getName(), objectPropertyPreset.getValue());
        }
    }
    // update object properties to gui
    levelEditorScreenController.setObjectProperties(presetId, levelEditorObject.getProperties(), null);
}
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) LevelEditorObject(net.drewke.tdme.tools.shared.model.LevelEditorObject)

Example 10 with PropertyModelClass

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

the class LevelEditorView method colorObject.

/**
	 * Centers selected objects
	 */
public void colorObject() {
    // skip if no objects selected
    if (selectedObjects.size() == 0)
        return;
    // color selected objects in blue
    for (Entity selectedObject : selectedObjects) {
        LevelEditorObject levelEditorObject = level.getObjectById(selectedObject.getId());
        if (levelEditorObject == null)
            continue;
        String color = OBJECTCOLOR_NAMES[0];
        PropertyModelClass colorProperty = levelEditorObject.getProperty("object.color");
        if (colorProperty == null) {
            levelEditorObject.addProperty("object.color", color);
        } else {
            // switch color
            color = colorProperty.getValue();
            for (int i = 0; i < OBJECTCOLOR_NAMES.length; i++) {
                if (color.equalsIgnoreCase(OBJECTCOLOR_NAMES[i])) {
                    color = OBJECTCOLOR_NAMES[(i + 1) % OBJECTCOLOR_NAMES.length];
                    break;
                }
            }
            // set up color in object properties
            if (color.equals("none")) {
                levelEditorObject.removeProperty("object.color");
            } else {
                levelEditorObject.updateProperty(colorProperty.getName(), "object.color", color);
            }
        }
        setStandardObjectColorEffect(selectedObject);
        setHighlightObjectColorEffect(selectedObject);
    }
    // set object properties if changed
    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);
        } else {
            levelEditorScreenController.unsetObjectProperties();
        }
    } else if (selectedObjects.size() > 1) {
        levelEditorScreenController.unsetObjectProperties();
    }
}
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) LevelEditorObject(net.drewke.tdme.tools.shared.model.LevelEditorObject)

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