use of com.badlogic.gdx.graphics.Camera 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 com.badlogic.gdx.graphics.Camera in project nhglib by VoidZombie.
the class GraphicsSystem method begin.
@Override
protected void begin() {
super.begin();
if (physicsSystem == null) {
physicsSystem = entities.getEntitySystem(PhysicsSystem.class);
}
if (cameraSystem == null) {
cameraSystem = entities.getEntitySystem(CameraSystem.class);
}
if (physicsSystem.isPhysicsInitialized()) {
if (debugDrawer == null) {
debugDrawer = new DebugDrawer();
debugDrawer.setDebugMode(btIDebugDraw.DebugDrawModes.DBG_MAX_DEBUG_DRAW_MODE);
}
physicsSystem.setDebugDrawer(debugDrawer);
}
cameras = cameraSystem.cameras;
for (int i = 0; i < cameras.size - modelBatches.size; i++) {
modelBatches.add(new ModelBatch(shaderProvider));
dynamicCaches.add(new ModelCache());
staticCaches.add(new ModelCache());
}
for (int i = 0; i < cameras.size; i++) {
Camera camera = cameras.get(i);
ModelCache dynamicCache = dynamicCaches.get(i);
dynamicCache.begin(camera);
}
}
use of com.badlogic.gdx.graphics.Camera in project Entitas-Java by Rubentxu.
the class PongState method initialize.
@Override
public void initialize() {
// Input
Camera camera = engine.getManager(BaseSceneManager.class).getDefaultCamera();
Batch batch = engine.getManager(BaseSceneManager.class).getBatch();
BitmapFont font = engine.getManager(BaseGUIManager.class).getDefaultFont();
context.core.createEntity().addBall(false).addView(new Circle(0, 0, 8)).addMotion(MathUtils.clamp(1, 230, 300), 300);
context.core.createEntity().addPlayer(Player.ID.PLAYER1).addScore("Player 1: ", 180, 470).addView(new Rectangle(-350, 0, Pong.PLAYER_WIDTH, Pong.PLAYER_HEIGHT)).addMotion(0, 0);
context.core.createEntity().addPlayer(Player.ID.PLAYER2).addScore("Player 2: ", 480, 470).addView(new Rectangle(350, 0, Pong.PLAYER_WIDTH, Pong.PLAYER_HEIGHT)).addMotion(0, 0);
systems.add(new InputSystem(context.core)).add(new ContactSystem(context.core)).add(new BoundsSystem(context.core)).add(new MoveSystem(context.core)).add(new RendererSystem(context.core, engine.sr, camera, batch, font));
}
use of com.badlogic.gdx.graphics.Camera in project Entitas-Java by Rubentxu.
the class SplashState method initialize.
@Override
public void initialize() {
// Input
Camera camera = engine.getManager(BaseSceneManager.class).getDefaultCamera();
Batch batch = engine.getManager(BaseSceneManager.class).getBatch();
BitmapFont font = engine.getManager(BaseGUIManager.class).getDefaultFont();
systems.add(new DelaySystem(context.core)).add(new RendererSystem(context.core, engine.sr, camera, batch, font));
Texture texture = assetsManager.getTexture(splash);
context.core.createEntity().addTextureView("Pong", new TextureRegion(texture, 0, 0, texture.getWidth(), texture.getHeight()), new Vector2(), 0, Pong.SCREEN_HEIGHT, Pong.SCREEN_WIDTH).addDelay(3);
}
use of com.badlogic.gdx.graphics.Camera in project libgdx by libgdx.
the class MainShader method bindDirectionalShadows.
public void bindDirectionalShadows(final Attributes attributes) {
final DirectionalLightsAttribute dla = attributes.get(DirectionalLightsAttribute.class, DirectionalLightsAttribute.Type);
final Array<DirectionalLight> dirs = dla == null ? null : dla.lights;
if (dirLightsLoc >= 0) {
for (int i = 0; i < directionalLights.length; i++) {
if (dirs == null || dirs.size <= i) {
continue;
}
int idx = dirShadowsLoc + i * dirShadowsSize;
// Shadow
ObjectMap<DirectionalLight, LightProperties> dirCameras = shadowSystem.getDirectionalCameras();
DirectionalLight dl = dirs.get(i);
if (shadowSystem.hasLight(dl)) {
// UVTransform
final TextureRegion tr = dirCameras.get(dl).region;
Camera cam = dirCameras.get(dl).camera;
if (cam != null) {
program.setUniformf(idx + dirShadowsUvTransformOffset, tr.getU(), tr.getV(), tr.getU2() - tr.getU(), tr.getV2() - tr.getV());
// ProjViewTrans
idx = dirShadowMapProjViewTransLoc + i * dirShadowMapProjViewTransSize;
program.setUniformMatrix(idx, dirCameras.get(dl).camera.combined);
}
}
if (dirLightsSize <= 0)
break;
}
}
}
Aggregations