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);
}
}
Aggregations