Search in sources :

Example 6 with LevelEditorEntity

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

the class EntityBoundingVolumeView method updateModelBoundingVolume.

/**
	 * Update model bounding volume
	 * @param entity
	 * @param idx
	 */
private void updateModelBoundingVolume(LevelEditorEntity entity, int idx) {
    LevelEditorEntityBoundingVolume entityBoundingVolume = entity.getBoundingVolumeAt(idx);
    // remove old bv
    String id = EntityBoundingVolumeSubScreenController.MODEL_BOUNDINGVOLUME_IDS[idx];
    Entity modelBoundingVolumeObject = engine.getEntity(id);
    if (modelBoundingVolumeObject != null) {
        engine.removeEntity(id);
    }
    // add new bv
    if (entityBoundingVolume.getModel() == null)
        return;
    modelBoundingVolumeObject = new Object3D(id, entityBoundingVolume.getModel());
    modelBoundingVolumeObject.setEnabled(false);
    engine.addEntity(modelBoundingVolumeObject);
}
Also used : LevelEditorEntityBoundingVolume(net.drewke.tdme.tools.shared.model.LevelEditorEntityBoundingVolume) Entity(net.drewke.tdme.engine.Entity) LevelEditorEntity(net.drewke.tdme.tools.shared.model.LevelEditorEntity) Object3D(net.drewke.tdme.engine.Object3D)

Example 7 with LevelEditorEntity

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

the class LevelEditorView method pasteObjects.

/**
	 * Paste objects
	 */
private void pasteObjects() {
    // determine top left of paste objects
    float pasteObjectsMinX = Float.MAX_VALUE;
    float pasteObjectsMinZ = Float.MAX_VALUE;
    float pasteObjectsMinY = Float.MIN_VALUE;
    for (LevelEditorObject object : pasteObjects) {
        BoundingVolume obv = object.getEntity().getModel().getBoundingBox();
        BoundingVolume cbv = obv.clone();
        cbv.fromBoundingVolumeWithTransformations(obv, object.getTransformations());
        float[] objectBBMinXYZ = ((BoundingBox) cbv).getMin().getArray();
        if (objectBBMinXYZ[0] < pasteObjectsMinX)
            pasteObjectsMinX = objectBBMinXYZ[0];
        if (objectBBMinXYZ[1] < pasteObjectsMinY)
            pasteObjectsMinY = objectBBMinXYZ[1];
        if (objectBBMinXYZ[2] < pasteObjectsMinZ)
            pasteObjectsMinZ = objectBBMinXYZ[2];
    }
    // determine top left of selected objects
    float selectedObjectsMinX = Float.MAX_VALUE;
    float selectedObjectsMinZ = Float.MAX_VALUE;
    float selectedObjectsMaxY = Float.MIN_VALUE;
    for (Entity object : selectedObjects) {
        LevelEditorObject levelEditorObject = level.getObjectById(object.getId());
        if (levelEditorObject == null)
            continue;
        BoundingVolume obv = levelEditorObject.getEntity().getModel().getBoundingBox();
        BoundingVolume cbv = obv.clone();
        cbv.fromBoundingVolumeWithTransformations(obv, levelEditorObject.getTransformations());
        float[] objectBBMinXYZ = ((BoundingBox) cbv).getMin().getArray();
        float[] objectBBMaxXYZ = ((BoundingBox) cbv).getMax().getArray();
        if (objectBBMinXYZ[0] < selectedObjectsMinX)
            selectedObjectsMinX = objectBBMinXYZ[0];
        if (objectBBMaxXYZ[1] > selectedObjectsMaxY)
            selectedObjectsMaxY = objectBBMaxXYZ[1];
        if (objectBBMinXYZ[2] < selectedObjectsMinZ)
            selectedObjectsMinZ = objectBBMinXYZ[2];
    }
    // paste objects
    for (LevelEditorObject pasteObject : pasteObjects) {
        // get selected level entity if it is one
        LevelEditorEntity pasteModel = pasteObject.getEntity();
        // create level entity, copy transformations from original
        Transformations levelEditorObjectTransformations = new Transformations();
        levelEditorObjectTransformations.fromTransformations(pasteObject.getTransformations());
        // compute new translation
        float objectDiffX = pasteObject.getTransformations().getTranslation().getX() - pasteObjectsMinX;
        float objectDiffY = pasteObject.getTransformations().getTranslation().getY() - pasteObjectsMinY;
        float objectDiffZ = pasteObject.getTransformations().getTranslation().getZ() - pasteObjectsMinZ;
        levelEditorObjectTransformations.getTranslation().setX(selectedObjectsMinX + objectDiffX);
        levelEditorObjectTransformations.getTranslation().setY(selectedObjectsMaxY + objectDiffY);
        levelEditorObjectTransformations.getTranslation().setZ(selectedObjectsMinZ + objectDiffZ);
        levelEditorObjectTransformations.update();
        // check if entity already exists
        for (int i = 0; i < level.getObjectCount(); i++) {
            LevelEditorObject levelEditorObject = level.getObjectAt(i);
            if (levelEditorObject.getEntity() == pasteModel && levelEditorObject.getTransformations().getTranslation().equals(levelEditorObjectTransformations.getTranslation())) {
                // we already have a object with selected model on this translation
                return;
            }
        }
        // create new level editor object
        LevelEditorObject levelEditorObject = new LevelEditorObject(pasteModel.getName() + "_" + level.allocateObjectId(), "", levelEditorObjectTransformations, pasteModel);
        // copy properties
        for (PropertyModelClass property : pasteObject.getProperties()) {
            levelEditorObject.addProperty(property.getName(), property.getValue());
        }
        //	add to level
        level.addObject(levelEditorObject);
        // add to 3d engine
        Object3D object = new Object3D(levelEditorObject.getId(), levelEditorObject.getEntity().getModel());
        object.fromTransformations(levelEditorObjectTransformations);
        object.setPickable(true);
        engine.addEntity(object);
    }
    // add to objects listbox
    levelEditorScreenController.setObjectListbox(level.getObjectIdsIterator());
}
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) Transformations(net.drewke.tdme.engine.Transformations) LevelEditorObject(net.drewke.tdme.tools.shared.model.LevelEditorObject) LevelEditorEntity(net.drewke.tdme.tools.shared.model.LevelEditorEntity) Object3D(net.drewke.tdme.engine.Object3D)

Example 8 with LevelEditorEntity

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

the class LevelEditorEntityLibraryScreenController method onValueChanged.

/*
	 * (non-Javadoc)
	 * @see net.drewke.tdme.gui.events.GUIChangeListener#onValueChanged(net.drewke.tdme.gui.nodes.GUIElementNode)
	 */
public void onValueChanged(GUIElementNode node) {
    if (node.getId().equals("entity_library_listbox") == true) {
        onEntitySelectionChanged();
    } else if (node.getId().equals("dropdown_entity_action") == true) {
        if (node.getController().getValue().equals("edit") == true) {
            onEditEntity();
        } else if (node.getController().getValue().equals("delete") == true) {
            onDeleteEntity();
        } else // model
        if (node.getController().getValue().equals("create_model") == true) {
            // model library
            final LevelEditorEntityLibrary entityLibrary = TDMELevelEditor.getInstance().getEntityLibrary();
            //
            popUps.getFileDialogScreenController().show(modelPath, "Load from: ", new String[] { "tmm", "dae", "tm" }, "", new Action() {

                public void performAction() {
                    try {
                        // add model
                        LevelEditorEntity entity = entityLibrary.addModel(LevelEditorEntityLibrary.ID_ALLOCATE, popUps.getFileDialogScreenController().getFileName(), "", popUps.getFileDialogScreenController().getPathName(), popUps.getFileDialogScreenController().getFileName(), new Vector3(0f, 0f, 0f));
                        entity.setDefaultBoundingVolumes();
                        setEntityLibrary();
                        entityLibraryListBox.getController().setValue(entityLibraryListBoxSelection.set(entity.getId()));
                        onEditEntity();
                    } catch (Exception exception) {
                        popUps.getInfoDialogScreenController().show("Error", "An error occurred: " + exception.getMessage());
                    }
                    modelPath = popUps.getFileDialogScreenController().getPathName();
                    popUps.getFileDialogScreenController().close();
                }
            });
        } else // trigger
        if (node.getController().getValue().equals("create_trigger") == true) {
            try {
                LevelEditorEntity model = TDMELevelEditor.getInstance().getEntityLibrary().addTrigger(LevelEditorEntityLibrary.ID_ALLOCATE, "New trigger", "", 1f, 1f, 1f);
                setEntityLibrary();
                entityLibraryListBox.getController().setValue(entityLibraryListBoxSelection.set(model.getId()));
                onEditEntity();
            } catch (Exception exception) {
                popUps.getInfoDialogScreenController().show("Error", "An error occurred: " + exception.getMessage());
            }
        } else // empty
        if (node.getController().getValue().equals("create_empty") == true) {
            try {
                LevelEditorEntity model = TDMELevelEditor.getInstance().getEntityLibrary().addEmpty(LevelEditorEntityLibrary.ID_ALLOCATE, "New empty", "");
                setEntityLibrary();
                entityLibraryListBox.getController().setValue(entityLibraryListBoxSelection.set(model.getId()));
                onEditEntity();
            } catch (Exception exception) {
                popUps.getInfoDialogScreenController().show("Error", "An error occurred: " + exception.getMessage());
            }
        } else // light
        if (node.getController().getValue().equals("create_light") == true) {
        } else // particle
        if (node.getController().getValue().equals("create_particlesystem") == true) {
            try {
                LevelEditorEntity model = TDMELevelEditor.getInstance().getEntityLibrary().addParticleSystem(LevelEditorEntityLibrary.ID_ALLOCATE, "New particle system", "");
                setEntityLibrary();
                entityLibraryListBox.getController().setValue(entityLibraryListBoxSelection.set(model.getId()));
                onEditEntity();
            } catch (Exception exception) {
                popUps.getInfoDialogScreenController().show("Error", "An error occurred: " + exception.getMessage());
            }
        } else {
            System.out.println("LevelEditorEntityLibraryScreenController::onValueChanged: dropdown_model_create: " + node.getController().getValue());
        }
        // reset
        node.getController().setValue(dropdownEntityActionReset);
    } else {
        System.out.println("LevelEditorEntityLibraryScreenController::onValueChanged: " + node.getId());
    }
}
Also used : LevelEditorEntityLibrary(net.drewke.tdme.tools.shared.model.LevelEditorEntityLibrary) Action(net.drewke.tdme.gui.events.Action) Vector3(net.drewke.tdme.math.Vector3) MutableString(net.drewke.tdme.utils.MutableString) LevelEditorEntity(net.drewke.tdme.tools.shared.model.LevelEditorEntity)

Example 9 with LevelEditorEntity

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

the class ModelMetaDataFileImport method doImportFromJSON.

/**
	 * Imports a model meta data file from JSON object
	 * @param id or LevelEditorEntity.ID_NONE
	 * @param path name or null
	 * @param JSON entity root
	 */
public static LevelEditorEntity doImportFromJSON(int id, String pathName, JSONObject jEntityRoot) throws Exception {
    LevelEditorEntity levelEditorEntity;
    // check for version
    float version = Float.parseFloat(jEntityRoot.getString("version"));
    // pivot
    Vector3 pivot = new Vector3((float) jEntityRoot.getDouble("px"), (float) jEntityRoot.getDouble("py"), (float) jEntityRoot.getDouble("pz"));
    // String thumbnail = jRoot.getString("thumbnail");
    EntityType modelType = LevelEditorEntity.EntityType.valueOf(jEntityRoot.getString("type"));
    String modelFile = jEntityRoot.has("file") == true ? new File(jEntityRoot.getString("file")).getCanonicalPath() : null;
    String modelThumbnail = jEntityRoot.has("thumbnail") == true ? jEntityRoot.getString("thumbnail") : null;
    String name = jEntityRoot.getString("name");
    String description = jEntityRoot.getString("descr");
    // load model
    Model model = null;
    // having a model file?
    String gameRoot = Tools.getGameRootPath(pathName);
    String modelRelativeFileName = null;
    if (modelFile != null) {
        // yep, load it
        modelRelativeFileName = Tools.getRelativeResourcesFileName(gameRoot, modelFile);
        String modelPath = (gameRoot.length() > 0 ? gameRoot + "/" : "") + Tools.getPath(modelRelativeFileName);
        if (modelFile.toLowerCase().endsWith(".dae")) {
            model = DAEReader.read(modelPath, Tools.getFileName(modelRelativeFileName));
        } else if (modelFile.toLowerCase().endsWith(".tm")) {
            model = TMReader.read(modelPath, Tools.getFileName(modelRelativeFileName));
        } else {
            throw new Exception("Unsupported mode file: " + modelFile);
        }
    } else //	TODO: only load if required e.g. for LevelEditor
    if (modelType == EntityType.EMPTY) {
        model = DAEReader.read("resources/tools/leveleditor/models", "arrow.dae");
    }
    // load level editor model
    levelEditorEntity = new LevelEditorEntity(id, modelType, name, description, null, modelFile != null ? new File(gameRoot, modelRelativeFileName).getCanonicalPath() : null, modelThumbnail, model, pivot);
    // parse properties
    JSONArray jProperties = jEntityRoot.getJSONArray("properties");
    for (int i = 0; i < jProperties.length(); i++) {
        JSONObject jProperty = jProperties.getJSONObject(i);
        levelEditorEntity.addProperty(jProperty.getString("name"), jProperty.getString("value"));
    }
    // old: optional bounding volume
    if (jEntityRoot.has("bv") == true) {
        levelEditorEntity.addBoundingVolume(0, parseBoundingVolume(0, levelEditorEntity, jEntityRoot.getJSONObject("bv")));
    } else // new: optional bounding volumeS
    if (jEntityRoot.has("bvs") == true) {
        JSONArray jBoundingVolumes = jEntityRoot.getJSONArray("bvs");
        for (int i = 0; i < jBoundingVolumes.length(); i++) {
            JSONObject jBv = jBoundingVolumes.getJSONObject(i);
            levelEditorEntity.addBoundingVolume(i, parseBoundingVolume(i, levelEditorEntity, jBv));
        }
    }
    // parse particle system 
    if (modelType == EntityType.PARTICLESYSTEM) {
        LevelEditorEntityParticleSystem particleSystem = levelEditorEntity.getParticleSystem();
        JSONObject jParticleSystem = jEntityRoot.getJSONObject("ps");
        // type
        particleSystem.setType(Type.valueOf(jParticleSystem.getString("t")));
        switch(particleSystem.getType()) {
            case NONE:
                {
                    break;
                }
            case OBJECT_PARTICLE_SYSTEM:
                {
                    JSONObject jObjectParticleSystem = jParticleSystem.getJSONObject("ops");
                    ObjectParticleSystem objectParticleSystem = particleSystem.getObjectParticleSystem();
                    objectParticleSystem.setMaxCount(jObjectParticleSystem.getInt("mc"));
                    objectParticleSystem.getScale().setX((float) jObjectParticleSystem.getDouble("sx"));
                    objectParticleSystem.getScale().setY((float) jObjectParticleSystem.getDouble("sy"));
                    objectParticleSystem.getScale().setZ((float) jObjectParticleSystem.getDouble("sz"));
                    objectParticleSystem.setAutoEmit(jObjectParticleSystem.getBoolean("ae"));
                    try {
                        String particleModelFile = jObjectParticleSystem.getString("mf");
                        String particleModelRelativeFileName = Tools.getRelativeResourcesFileName(gameRoot, particleModelFile);
                        String particleModelPath = (gameRoot.length() > 0 ? gameRoot + "/" : "") + Tools.getPath(particleModelRelativeFileName);
                        objectParticleSystem.setModelFile(particleModelPath + "/" + Tools.getFileName(particleModelRelativeFileName));
                    } catch (Exception exception) {
                        exception.printStackTrace();
                        System.out.println("ModelMetaDataFileImport::doImport(): Failed to set model file: " + exception.getMessage());
                    }
                    break;
                }
            case POINT_PARTICLE_SYSTEM:
                {
                    JSONObject jPointParticleSystem = jParticleSystem.getJSONObject("pps");
                    particleSystem.getPointParticleSystem().setMaxPoints(jPointParticleSystem.getInt("mp"));
                    particleSystem.getPointParticleSystem().setAutoEmit(jPointParticleSystem.getBoolean("ae"));
                    break;
                }
            default:
                {
                    System.out.println("ModelMetaDataFileExport::export(): unknown particle system type '" + particleSystem.getType() + "'");
                    break;
                }
        }
        // emitter
        particleSystem.setEmitter(Emitter.valueOf(jParticleSystem.getString("e")));
        switch(particleSystem.getEmitter()) {
            case NONE:
                {
                    break;
                }
            case POINT_PARTICLE_EMITTER:
                {
                    JSONObject jPointParticleEmitter = jParticleSystem.getJSONObject("ppe");
                    PointParticleEmitter emitter = particleSystem.getPointParticleEmitter();
                    emitter.setCount(jPointParticleEmitter.getInt("c"));
                    emitter.setLifeTime(jPointParticleEmitter.getLong("lt"));
                    emitter.setLifeTimeRnd(jPointParticleEmitter.getLong("ltrnd"));
                    emitter.setMass((float) jPointParticleEmitter.getDouble("m"));
                    emitter.setMassRnd((float) jPointParticleEmitter.getDouble("mrnd"));
                    emitter.getPosition().setX((float) jPointParticleEmitter.getDouble("px"));
                    emitter.getPosition().setY((float) jPointParticleEmitter.getDouble("py"));
                    emitter.getPosition().setZ((float) jPointParticleEmitter.getDouble("pz"));
                    emitter.getVelocity().setX((float) jPointParticleEmitter.getDouble("vx"));
                    emitter.getVelocity().setY((float) jPointParticleEmitter.getDouble("vy"));
                    emitter.getVelocity().setZ((float) jPointParticleEmitter.getDouble("vz"));
                    emitter.getVelocityRnd().setX((float) jPointParticleEmitter.getDouble("vrndx"));
                    emitter.getVelocityRnd().setY((float) jPointParticleEmitter.getDouble("vrndy"));
                    emitter.getVelocityRnd().setZ((float) jPointParticleEmitter.getDouble("vrndz"));
                    emitter.getColorStart().setRed((float) jPointParticleEmitter.getDouble("csr"));
                    emitter.getColorStart().setGreen((float) jPointParticleEmitter.getDouble("csg"));
                    emitter.getColorStart().setBlue((float) jPointParticleEmitter.getDouble("csb"));
                    emitter.getColorStart().setAlpha((float) jPointParticleEmitter.getDouble("csa"));
                    emitter.getColorEnd().setRed((float) jPointParticleEmitter.getDouble("cer"));
                    emitter.getColorEnd().setGreen((float) jPointParticleEmitter.getDouble("ceg"));
                    emitter.getColorEnd().setBlue((float) jPointParticleEmitter.getDouble("ceb"));
                    emitter.getColorEnd().setAlpha((float) jPointParticleEmitter.getDouble("cea"));
                    break;
                }
            case BOUNDINGBOX_PARTICLE_EMITTER:
                {
                    JSONObject jBoundingBoxParticleEmitter = jParticleSystem.getJSONObject("bbpe");
                    BoundingBoxParticleEmitter emitter = particleSystem.getBoundingBoxParticleEmitters();
                    emitter.setCount(jBoundingBoxParticleEmitter.getInt("c"));
                    emitter.setLifeTime(jBoundingBoxParticleEmitter.getLong("lt"));
                    emitter.setLifeTimeRnd(jBoundingBoxParticleEmitter.getLong("ltrnd"));
                    emitter.setMass((float) jBoundingBoxParticleEmitter.getDouble("m"));
                    emitter.setMassRnd((float) jBoundingBoxParticleEmitter.getDouble("mrnd"));
                    emitter.getVelocity().setX((float) jBoundingBoxParticleEmitter.getDouble("vx"));
                    emitter.getVelocity().setY((float) jBoundingBoxParticleEmitter.getDouble("vy"));
                    emitter.getVelocity().setZ((float) jBoundingBoxParticleEmitter.getDouble("vz"));
                    emitter.getVelocityRnd().setX((float) jBoundingBoxParticleEmitter.getDouble("vrndx"));
                    emitter.getVelocityRnd().setY((float) jBoundingBoxParticleEmitter.getDouble("vrndy"));
                    emitter.getVelocityRnd().setZ((float) jBoundingBoxParticleEmitter.getDouble("vrndz"));
                    emitter.getColorStart().setRed((float) jBoundingBoxParticleEmitter.getDouble("csr"));
                    emitter.getColorStart().setGreen((float) jBoundingBoxParticleEmitter.getDouble("csg"));
                    emitter.getColorStart().setBlue((float) jBoundingBoxParticleEmitter.getDouble("csb"));
                    emitter.getColorStart().setAlpha((float) jBoundingBoxParticleEmitter.getDouble("csa"));
                    emitter.getColorEnd().setRed((float) jBoundingBoxParticleEmitter.getDouble("cer"));
                    emitter.getColorEnd().setGreen((float) jBoundingBoxParticleEmitter.getDouble("ceg"));
                    emitter.getColorEnd().setBlue((float) jBoundingBoxParticleEmitter.getDouble("ceb"));
                    emitter.getColorEnd().setAlpha((float) jBoundingBoxParticleEmitter.getDouble("cea"));
                    emitter.getObbCenter().setX((float) jBoundingBoxParticleEmitter.getDouble("ocx"));
                    emitter.getObbCenter().setY((float) jBoundingBoxParticleEmitter.getDouble("ocy"));
                    emitter.getObbCenter().setZ((float) jBoundingBoxParticleEmitter.getDouble("ocz"));
                    emitter.getObbHalfextension().setX((float) jBoundingBoxParticleEmitter.getDouble("ohex"));
                    emitter.getObbHalfextension().setY((float) jBoundingBoxParticleEmitter.getDouble("ohey"));
                    emitter.getObbHalfextension().setZ((float) jBoundingBoxParticleEmitter.getDouble("ohez"));
                    emitter.getObbAxis0().setX((float) jBoundingBoxParticleEmitter.getDouble("oa0x"));
                    emitter.getObbAxis0().setY((float) jBoundingBoxParticleEmitter.getDouble("oa0y"));
                    emitter.getObbAxis0().setZ((float) jBoundingBoxParticleEmitter.getDouble("oa0z"));
                    emitter.getObbAxis1().setX((float) jBoundingBoxParticleEmitter.getDouble("oa1x"));
                    emitter.getObbAxis1().setY((float) jBoundingBoxParticleEmitter.getDouble("oa1y"));
                    emitter.getObbAxis1().setZ((float) jBoundingBoxParticleEmitter.getDouble("oa1z"));
                    emitter.getObbAxis2().setX((float) jBoundingBoxParticleEmitter.getDouble("oa2x"));
                    emitter.getObbAxis2().setY((float) jBoundingBoxParticleEmitter.getDouble("oa2y"));
                    emitter.getObbAxis2().setZ((float) jBoundingBoxParticleEmitter.getDouble("oa2z"));
                    break;
                }
            case CIRCLE_PARTICLE_EMITTER:
                {
                    JSONObject jCircleParticleEmitter = jParticleSystem.getJSONObject("cpe");
                    CircleParticleEmitter emitter = particleSystem.getCircleParticleEmitter();
                    emitter.setCount(jCircleParticleEmitter.getInt("c"));
                    emitter.setLifeTime(jCircleParticleEmitter.getLong("lt"));
                    emitter.setLifeTimeRnd(jCircleParticleEmitter.getLong("ltrnd"));
                    emitter.setMass((float) jCircleParticleEmitter.getDouble("m"));
                    emitter.setMassRnd((float) jCircleParticleEmitter.getDouble("mrnd"));
                    emitter.getVelocity().setX((float) jCircleParticleEmitter.getDouble("vx"));
                    emitter.getVelocity().setY((float) jCircleParticleEmitter.getDouble("vy"));
                    emitter.getVelocity().setZ((float) jCircleParticleEmitter.getDouble("vz"));
                    emitter.getVelocityRnd().setX((float) jCircleParticleEmitter.getDouble("vrndx"));
                    emitter.getVelocityRnd().setY((float) jCircleParticleEmitter.getDouble("vrndy"));
                    emitter.getVelocityRnd().setZ((float) jCircleParticleEmitter.getDouble("vrndz"));
                    emitter.getColorStart().setRed((float) jCircleParticleEmitter.getDouble("csr"));
                    emitter.getColorStart().setGreen((float) jCircleParticleEmitter.getDouble("csg"));
                    emitter.getColorStart().setBlue((float) jCircleParticleEmitter.getDouble("csb"));
                    emitter.getColorStart().setAlpha((float) jCircleParticleEmitter.getDouble("csa"));
                    emitter.getColorEnd().setRed((float) jCircleParticleEmitter.getDouble("cer"));
                    emitter.getColorEnd().setGreen((float) jCircleParticleEmitter.getDouble("ceg"));
                    emitter.getColorEnd().setBlue((float) jCircleParticleEmitter.getDouble("ceb"));
                    emitter.getColorEnd().setAlpha((float) jCircleParticleEmitter.getDouble("cea"));
                    emitter.getCenter().setX((float) jCircleParticleEmitter.getDouble("cx"));
                    emitter.getCenter().setY((float) jCircleParticleEmitter.getDouble("cy"));
                    emitter.getCenter().setZ((float) jCircleParticleEmitter.getDouble("cz"));
                    emitter.setRadius((float) jCircleParticleEmitter.getDouble("r"));
                    emitter.getAxis0().setX((float) jCircleParticleEmitter.getDouble("a0x"));
                    emitter.getAxis0().setY((float) jCircleParticleEmitter.getDouble("a0y"));
                    emitter.getAxis0().setZ((float) jCircleParticleEmitter.getDouble("a0z"));
                    emitter.getAxis1().setX((float) jCircleParticleEmitter.getDouble("a1x"));
                    emitter.getAxis1().setY((float) jCircleParticleEmitter.getDouble("a1y"));
                    emitter.getAxis1().setZ((float) jCircleParticleEmitter.getDouble("a1z"));
                    break;
                }
            case CIRCLE_PARTICLE_EMITTER_PLANE_VELOCITY:
                {
                    JSONObject jCircleParticleEmitterPlaneVelocity = jParticleSystem.getJSONObject("cpeev");
                    CircleParticleEmitterPlaneVelocity emitter = particleSystem.getCircleParticleEmitterPlaneVelocity();
                    emitter.setCount(jCircleParticleEmitterPlaneVelocity.getInt("c"));
                    emitter.setLifeTime(jCircleParticleEmitterPlaneVelocity.getLong("lt"));
                    emitter.setLifeTimeRnd(jCircleParticleEmitterPlaneVelocity.getLong("ltrnd"));
                    emitter.setMass((float) jCircleParticleEmitterPlaneVelocity.getDouble("m"));
                    emitter.setMassRnd((float) jCircleParticleEmitterPlaneVelocity.getDouble("mrnd"));
                    emitter.setVelocity((float) jCircleParticleEmitterPlaneVelocity.getDouble("v"));
                    emitter.setVelocityRnd((float) jCircleParticleEmitterPlaneVelocity.getDouble("vrnd"));
                    emitter.getColorStart().setRed((float) jCircleParticleEmitterPlaneVelocity.getDouble("csr"));
                    emitter.getColorStart().setGreen((float) jCircleParticleEmitterPlaneVelocity.getDouble("csg"));
                    emitter.getColorStart().setBlue((float) jCircleParticleEmitterPlaneVelocity.getDouble("csb"));
                    emitter.getColorStart().setAlpha((float) jCircleParticleEmitterPlaneVelocity.getDouble("csa"));
                    emitter.getColorEnd().setRed((float) jCircleParticleEmitterPlaneVelocity.getDouble("cer"));
                    emitter.getColorEnd().setGreen((float) jCircleParticleEmitterPlaneVelocity.getDouble("ceg"));
                    emitter.getColorEnd().setBlue((float) jCircleParticleEmitterPlaneVelocity.getDouble("ceb"));
                    emitter.getColorEnd().setAlpha((float) jCircleParticleEmitterPlaneVelocity.getDouble("cea"));
                    emitter.getCenter().setX((float) jCircleParticleEmitterPlaneVelocity.getDouble("cx"));
                    emitter.getCenter().setY((float) jCircleParticleEmitterPlaneVelocity.getDouble("cy"));
                    emitter.getCenter().setZ((float) jCircleParticleEmitterPlaneVelocity.getDouble("cz"));
                    emitter.setRadius((float) jCircleParticleEmitterPlaneVelocity.getDouble("r"));
                    emitter.getAxis0().setX((float) jCircleParticleEmitterPlaneVelocity.getDouble("a0x"));
                    emitter.getAxis0().setY((float) jCircleParticleEmitterPlaneVelocity.getDouble("a0y"));
                    emitter.getAxis0().setZ((float) jCircleParticleEmitterPlaneVelocity.getDouble("a0z"));
                    emitter.getAxis1().setX((float) jCircleParticleEmitterPlaneVelocity.getDouble("a1x"));
                    emitter.getAxis1().setY((float) jCircleParticleEmitterPlaneVelocity.getDouble("a1y"));
                    emitter.getAxis1().setZ((float) jCircleParticleEmitterPlaneVelocity.getDouble("a1z"));
                    break;
                }
            case SPHERE_PARTICLE_EMITTER:
                {
                    JSONObject jSphereParticleEmitter = jParticleSystem.getJSONObject("spe");
                    SphereParticleEmitter emitter = particleSystem.getSphereParticleEmitter();
                    emitter.setCount(jSphereParticleEmitter.getInt("c"));
                    emitter.setLifeTime(jSphereParticleEmitter.getLong("lt"));
                    emitter.setLifeTimeRnd(jSphereParticleEmitter.getLong("ltrnd"));
                    emitter.setMass((float) jSphereParticleEmitter.getDouble("m"));
                    emitter.setMassRnd((float) jSphereParticleEmitter.getDouble("mrnd"));
                    emitter.getVelocity().setX((float) jSphereParticleEmitter.getDouble("vx"));
                    emitter.getVelocity().setY((float) jSphereParticleEmitter.getDouble("vy"));
                    emitter.getVelocity().setZ((float) jSphereParticleEmitter.getDouble("vz"));
                    emitter.getVelocityRnd().setX((float) jSphereParticleEmitter.getDouble("vrndx"));
                    emitter.getVelocityRnd().setY((float) jSphereParticleEmitter.getDouble("vrndy"));
                    emitter.getVelocityRnd().setZ((float) jSphereParticleEmitter.getDouble("vrndz"));
                    emitter.getColorStart().setRed((float) jSphereParticleEmitter.getDouble("csr"));
                    emitter.getColorStart().setGreen((float) jSphereParticleEmitter.getDouble("csg"));
                    emitter.getColorStart().setBlue((float) jSphereParticleEmitter.getDouble("csb"));
                    emitter.getColorStart().setAlpha((float) jSphereParticleEmitter.getDouble("csa"));
                    emitter.getColorEnd().setRed((float) jSphereParticleEmitter.getDouble("cer"));
                    emitter.getColorEnd().setGreen((float) jSphereParticleEmitter.getDouble("ceg"));
                    emitter.getColorEnd().setBlue((float) jSphereParticleEmitter.getDouble("ceb"));
                    emitter.getColorEnd().setAlpha((float) jSphereParticleEmitter.getDouble("cea"));
                    emitter.getCenter().setX((float) jSphereParticleEmitter.getDouble("cx"));
                    emitter.getCenter().setY((float) jSphereParticleEmitter.getDouble("cy"));
                    emitter.getCenter().setZ((float) jSphereParticleEmitter.getDouble("cz"));
                    emitter.setRadius((float) jSphereParticleEmitter.getDouble("r"));
                    break;
                }
            default:
                System.out.println("ModelMetaDataFileExport::export(): unknown particle system emitter '" + particleSystem.getEmitter() + "'");
        }
    }
    // done
    return levelEditorEntity;
}
Also used : CircleParticleEmitterPlaneVelocity(net.drewke.tdme.tools.shared.model.LevelEditorEntityParticleSystem.CircleParticleEmitterPlaneVelocity) JSONArray(org.json.JSONArray) CircleParticleEmitter(net.drewke.tdme.tools.shared.model.LevelEditorEntityParticleSystem.CircleParticleEmitter) Vector3(net.drewke.tdme.math.Vector3) JSONException(org.json.JSONException) IOException(java.io.IOException) LevelEditorEntityParticleSystem(net.drewke.tdme.tools.shared.model.LevelEditorEntityParticleSystem) EntityType(net.drewke.tdme.tools.shared.model.LevelEditorEntity.EntityType) JSONObject(org.json.JSONObject) Model(net.drewke.tdme.engine.model.Model) PrimitiveModel(net.drewke.tdme.engine.primitives.PrimitiveModel) BoundingBoxParticleEmitter(net.drewke.tdme.tools.shared.model.LevelEditorEntityParticleSystem.BoundingBoxParticleEmitter) ObjectParticleSystem(net.drewke.tdme.tools.shared.model.LevelEditorEntityParticleSystem.ObjectParticleSystem) LevelEditorEntity(net.drewke.tdme.tools.shared.model.LevelEditorEntity) File(java.io.File) SphereParticleEmitter(net.drewke.tdme.tools.shared.model.LevelEditorEntityParticleSystem.SphereParticleEmitter) PointParticleEmitter(net.drewke.tdme.tools.shared.model.LevelEditorEntityParticleSystem.PointParticleEmitter)

Example 10 with LevelEditorEntity

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

the class EntityBoundingVolumeSubScreenController method onBoundingVolumeConvexMeshFile.

/**
	 * On bounding volume convex mesh file clicked
	 * @param entity
	 * @param idx
	 */
public void onBoundingVolumeConvexMeshFile(LevelEditorEntity entity, int idx) {
    final int idxFinal = idx;
    final LevelEditorEntity entityFinal = entity;
    view.getPopUpsViews().getFileDialogScreenController().show(modelPath.getPath(), "Load from: ", new String[] { "dae", "tm" }, entity.getBoundingVolumeAt(idx).getModelMeshFile() != null ? entity.getBoundingVolumeAt(idx).getModelMeshFile() : entity.getFileName(), new Action() {

        public void performAction() {
            boundingvolumeConvexMeshFile[idxFinal].getController().setValue(value.set(view.getPopUpsViews().getFileDialogScreenController().getFileName()));
            onBoundingVolumeConvexMeshApply(entityFinal, idxFinal);
            modelPath.setPath(view.getPopUpsViews().getFileDialogScreenController().getPathName());
            view.getPopUpsViews().getFileDialogScreenController().close();
        }
    });
}
Also used : Action(net.drewke.tdme.gui.events.Action) LevelEditorEntity(net.drewke.tdme.tools.shared.model.LevelEditorEntity)

Aggregations

LevelEditorEntity (net.drewke.tdme.tools.shared.model.LevelEditorEntity)20 Vector3 (net.drewke.tdme.math.Vector3)7 IOException (java.io.IOException)6 File (java.io.File)4 Entity (net.drewke.tdme.engine.Entity)4 Transformations (net.drewke.tdme.engine.Transformations)4 Model (net.drewke.tdme.engine.model.Model)4 Object3D (net.drewke.tdme.engine.Object3D)3 Rotation (net.drewke.tdme.engine.Rotation)3 EmptyView (net.drewke.tdme.tools.leveleditor.views.EmptyView)3 ModelViewerView (net.drewke.tdme.tools.leveleditor.views.ModelViewerView)3 ParticleSystemView (net.drewke.tdme.tools.leveleditor.views.ParticleSystemView)3 TriggerView (net.drewke.tdme.tools.leveleditor.views.TriggerView)3 LevelEditorEntityLibrary (net.drewke.tdme.tools.shared.model.LevelEditorEntityLibrary)3 LevelEditorObject (net.drewke.tdme.tools.shared.model.LevelEditorObject)3 PropertyModelClass (net.drewke.tdme.tools.shared.model.PropertyModelClass)3 JSONObject (org.json.JSONObject)3 InputStream (java.io.InputStream)2 FacesEntity (net.drewke.tdme.engine.model.FacesEntity)2 Action (net.drewke.tdme.gui.events.Action)2