Search in sources :

Example 31 with Matrix4

use of com.badlogic.gdx.math.Matrix4 in project nhglib by VoidZombie.

the class LightingSystem method process.

@Override
protected void process(int entityId) {
    NodeComponent node = nodeMapper.get(entityId);
    LightComponent light = lightMapper.get(entityId);
    light.light.position.set(node.getTranslation());
    light.light.setTransform(node.getTransform());
    switch(light.type) {
        case SPOT_LIGHT:
        case DIRECTIONAL_LIGHT:
            Matrix4 tempMatrix = MatrixPool.getMatrix4();
            tempMatrix.set(node.getTransform());
            tempMatrix.translate(0f, 1f, 0f);
            Vector3 direction = VectorPool.getVector3();
            Vector3 tempVec = VectorPool.getVector3();
            direction.set(light.light.position).sub(tempMatrix.getTranslation(tempVec));
            light.light.direction.set(direction);
            MatrixPool.freeMatrix4(tempMatrix);
            VectorPool.freeVector3(direction, tempVec);
            break;
    }
}
Also used : LightComponent(io.github.voidzombie.nhglib.runtime.ecs.components.graphics.LightComponent) NodeComponent(io.github.voidzombie.nhglib.runtime.ecs.components.scenes.NodeComponent) Vector3(com.badlogic.gdx.math.Vector3) Matrix4(com.badlogic.gdx.math.Matrix4)

Aggregations

Matrix4 (com.badlogic.gdx.math.Matrix4)31 Vector3 (com.badlogic.gdx.math.Vector3)10 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)5 Texture (com.badlogic.gdx.graphics.Texture)4 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)4 Sprite (com.badlogic.gdx.graphics.g2d.Sprite)3 Material (com.badlogic.gdx.graphics.g3d.Material)3 Model (com.badlogic.gdx.graphics.g3d.Model)3 Quaternion (com.badlogic.gdx.math.Quaternion)3 JsonValue (com.badlogic.gdx.utils.JsonValue)3 InputAdapter (com.badlogic.gdx.InputAdapter)2 TextureAtlas (com.badlogic.gdx.graphics.g2d.TextureAtlas)2 Environment (com.badlogic.gdx.graphics.g3d.Environment)2 ModelInstance (com.badlogic.gdx.graphics.g3d.ModelInstance)2 ModelBuilder (com.badlogic.gdx.graphics.g3d.utils.ModelBuilder)2 com.badlogic.gdx.physics.bullet.collision.btBvhTriangleMeshShape (com.badlogic.gdx.physics.bullet.collision.btBvhTriangleMeshShape)2 com.badlogic.gdx.physics.bullet.collision.btSphereShape (com.badlogic.gdx.physics.bullet.collision.btSphereShape)2 GdxRuntimeException (com.badlogic.gdx.utils.GdxRuntimeException)2 NodeComponent (io.github.voidzombie.nhglib.runtime.ecs.components.scenes.NodeComponent)2 ArrayList (java.util.ArrayList)2