Search in sources :

Example 1 with Properties

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

the class Level method addLevel.

/**
	 * Add level to engine
	 * @param engine
	 * @param level
	 * @param add empties
	 * @param add trigger
	 * @param dynamic shadowing 
	 * @param pickable
	 * @param translation
	 */
public static void addLevel(Engine engine, LevelEditorLevel level, boolean addEmpties, boolean addTrigger, boolean dynamicShadowing, boolean pickable, Vector3 translation) {
    // load level objects
    for (int i = 0; i < level.getObjectCount(); i++) {
        LevelEditorObject object = level.getObjectAt(i);
        Properties properties = object.getTotalProperties();
        // skip on empties or trigger
        if (addEmpties == false && object.getEntity().getType() == EntityType.EMPTY)
            continue;
        if (addTrigger == false && object.getEntity().getType() == EntityType.TRIGGER)
            continue;
        // add to 3d engine
        Entity entity = null;
        if (object.getEntity().getModel() != null) {
            entity = new Object3D(object.getId(), object.getEntity().getModel());
        } else if (object.getEntity().getType() == EntityType.PARTICLESYSTEM) {
            entity = createParticleSystem(object.getEntity().getParticleSystem(), object.getId(), false);
        }
        // skip if we have no entity
        if (entity == null)
            continue;
        // apply transformations
        entity.fromTransformations(object.getTransformations());
        // apply translation
        if (translation != null) {
            entity.getTranslation().add(translation);
        }
        // pickable
        entity.setPickable(pickable);
        // dynamic shadowing
        PropertyModelClass shadowingProperty = properties.getProperty("shadowing");
        boolean omitShadowing = shadowingProperty != null && shadowingProperty.getValue().equalsIgnoreCase("false");
        entity.setDynamicShadowingEnabled(omitShadowing == true ? false : dynamicShadowing);
        // do not scale empties
        if (object.getEntity().getType() == EntityType.EMPTY) {
            entity.getScale().set(MathTools.sign(entity.getScale().getX()), MathTools.sign(entity.getScale().getY()), MathTools.sign(entity.getScale().getZ()));
        }
        // update
        entity.update();
        // add
        engine.addEntity(entity);
    }
}
Also used : Entity(net.drewke.tdme.engine.Entity) PointsParticleSystemEntity(net.drewke.tdme.engine.PointsParticleSystemEntity) ObjectParticleSystemEntity(net.drewke.tdme.engine.ObjectParticleSystemEntity) PropertyModelClass(net.drewke.tdme.tools.shared.model.PropertyModelClass) LevelEditorObject(net.drewke.tdme.tools.shared.model.LevelEditorObject) Properties(net.drewke.tdme.tools.shared.model.Properties) Object3D(net.drewke.tdme.engine.Object3D)

Aggregations

Entity (net.drewke.tdme.engine.Entity)1 Object3D (net.drewke.tdme.engine.Object3D)1 ObjectParticleSystemEntity (net.drewke.tdme.engine.ObjectParticleSystemEntity)1 PointsParticleSystemEntity (net.drewke.tdme.engine.PointsParticleSystemEntity)1 LevelEditorObject (net.drewke.tdme.tools.shared.model.LevelEditorObject)1 Properties (net.drewke.tdme.tools.shared.model.Properties)1 PropertyModelClass (net.drewke.tdme.tools.shared.model.PropertyModelClass)1