use of io.github.voidzombie.nhglib.runtime.ecs.components.graphics.CameraComponent in project nhglib by VoidZombie.
the class CameraSystem method process.
@Override
protected void process(int entityId) {
CameraComponent cameraComponent = cameraMapper.get(entityId);
NodeComponent nodeComponent = nodeMapper.get(entityId);
Camera camera = cameraComponent.camera;
camera.position.set(nodeComponent.getTranslation());
camera.direction.rotate(camera.up, nodeComponent.getYRotationDelta());
camera.up.rotate(camera.direction, nodeComponent.getZRotationDelta());
vec.set(camera.direction).crs(camera.up).nor();
camera.direction.rotate(vec, nodeComponent.getXRotationDelta());
camera.update();
if (!cameras.contains(camera, true)) {
cameras.add(camera);
}
}
use of io.github.voidzombie.nhglib.runtime.ecs.components.graphics.CameraComponent in project nhglib by VoidZombie.
the class CameraComponentJson method parse.
@Override
public void parse(JsonValue jsonValue) {
CameraComponent cameraComponent = entities.createComponent(entity, CameraComponent.class);
Camera camera;
float nearPlane = jsonValue.getFloat("nearPlane");
float farPlane = jsonValue.getFloat("farPlane");
CameraComponent.Type type = CameraComponent.Type.fromString(jsonValue.getString("cameraType"));
switch(type) {
default:
case PERSPECTIVE:
float fieldOfView = jsonValue.getFloat("fieldOfView");
camera = new PerspectiveCamera(fieldOfView, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
break;
case ORTHOGRAPHIC:
camera = new OrthographicCamera();
break;
}
camera.near = nearPlane;
camera.far = farPlane;
cameraComponent.camera = camera;
cameraComponent.type = type;
output = cameraComponent;
}
Aggregations