Search in sources :

Example 1 with PerspectiveCamera

use of org.terasology.engine.rendering.cameras.PerspectiveCamera in project Terasology by MovingBlocks.

the class SpriteParticleRenderer method renderAlphaBlend.

@Override
public void renderAlphaBlend() {
    if (!opengl33) {
        return;
    }
    PerspectiveCamera camera = (PerspectiveCamera) worldRenderer.getActiveCamera();
    Vector3f cameraPosition = camera.getPosition();
    Matrix4f viewProjection = new Matrix4f(camera.getViewProjectionMatrix()).translate(-cameraPosition.x, -cameraPosition.y, -cameraPosition.z);
    Material material = Assets.getMaterial(PARTICLE_MATERIAL_URI).get();
    material.enable();
    material.setFloat3("camera_position", cameraPosition.x, cameraPosition.y, cameraPosition.z);
    material.setMatrix4("view_projection", viewProjection.get(matrixBuffer));
    particleSystemManager.getParticleEmittersByDataComponent(ParticleDataSpriteComponent.class).forEach(particleSystem -> drawParticles(material, particleSystem));
}
Also used : ParticleDataSpriteComponent(org.terasology.engine.particles.components.ParticleDataSpriteComponent) Matrix4f(org.joml.Matrix4f) Vector3f(org.joml.Vector3f) Material(org.terasology.engine.rendering.assets.material.Material) PerspectiveCamera(org.terasology.engine.rendering.cameras.PerspectiveCamera)

Aggregations

Matrix4f (org.joml.Matrix4f)1 Vector3f (org.joml.Vector3f)1 ParticleDataSpriteComponent (org.terasology.engine.particles.components.ParticleDataSpriteComponent)1 Material (org.terasology.engine.rendering.assets.material.Material)1 PerspectiveCamera (org.terasology.engine.rendering.cameras.PerspectiveCamera)1