use of ilargia.egdx.api.factories.EntityFactory in project Entitas-Java by Rubentxu.
the class SceneManagerGDX method initialize.
@Override
public void initialize() {
if (engine.getManager(PhysicsManagerGDX.class) == null)
throw new EntitasException("SceneManagerGDX", "SceneManagerGDX needs load PhysicsManagerGDX on the engine");
physics = engine.getManager(PhysicsManagerGDX.class);
rayHandler = new RayHandler(physics.getPhysics());
PreferencesManagerGDX preferences = engine.getManager(PreferencesManagerGDX.class);
rayHandler.setAmbientLight(preferences.AMBIENT_LIGHT);
rayHandler.setBlur(preferences.BLUR);
rayHandler.setCulling(preferences.CULLING);
rayHandler.setGammaCorrection(preferences.GAMMA_CORRECTION);
rayHandler.setBlurNum(preferences.BLUR_NUM);
rayHandler.setShadows(preferences.SHADOWS);
rayHandler.useDiffuseLight(preferences.USE_DIFFUSE_LIGHT);
//rayHandler.update();
AssetsManagerGDX assetsManager = engine.getManager(AssetsManagerGDX.class);
for (EntityFactory factory : entityFactories.values()) {
factory.loadAssets(engine);
}
assetsManager.finishLoading();
addLightFactory(PointLight.class, (SceneManager sceneManager, IComponent c) -> {
CPointLight component = (CPointLight) c;
return new PointLight(rayHandler, component.raysNum, component.color, component.distance, component.position.x, component.position.y);
});
addLightFactory(DirectionalLight.class, (SceneManager sceneManager, IComponent c) -> {
LogManagerGDX.debug("SceneManager", "create directional ligth");
CDirectionalLight component = (CDirectionalLight) c;
return new DirectionalLight(rayHandler, component.raysNum, component.color, component.direcction);
});
addLightFactory(ChainLight.class, (SceneManager sceneManager, IComponent c) -> {
LogManagerGDX.debug("SceneManager", "create ChainLight");
CChainLight component = (CChainLight) c;
return new ChainLight(rayHandler, component.raysNum, component.color, component.distance, component.rayDirecction, component.chain);
});
addLightFactory(ConeLight.class, (SceneManager sceneManager, IComponent c) -> {
LogManagerGDX.debug("SceneManager", "create ConeLight");
CConeLight component = (CConeLight) c;
return new ConeLight(rayHandler, component.raysNum, component.color, component.distance, component.position.x, component.position.y, component.directionDegree, component.coneDegree);
});
}
Aggregations