Search in sources :

Example 26 with Vector3

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

the class TiledForwardShader method render.

@Override
public void render(Renderable renderable) {
    for (int light = 0; light < lightsToRender.size; light++) {
        NhgLight nhgLight = lightsToRender.get(light);
        String lightUniform = "u_lightsList[" + light + "].";
        Vector3 viewSpacePosition = getViewSpacePosition(nhgLight);
        Vector3 viewSpaceDirection = getViewSpaceDirection(nhgLight);
        shaderProgram.setUniformi(lightUniform + "type", nhgLight.type.ordinal());
        shaderProgram.setUniformf(lightUniform + "position", viewSpacePosition);
        shaderProgram.setUniformf(lightUniform + "direction", viewSpaceDirection);
        shaderProgram.setUniformf(lightUniform + "intensity", nhgLight.intensity);
        shaderProgram.setUniformf(lightUniform + "innerAngle", nhgLight.innerAngle);
        shaderProgram.setUniformf(lightUniform + "outerAngle", nhgLight.outerAngle);
        VectorPool.freeVector3(viewSpacePosition, viewSpaceDirection);
    }
    updateBones(renderable);
    super.render(renderable);
}
Also used : Vector3(com.badlogic.gdx.math.Vector3) NhgLight(io.github.voidzombie.nhglib.graphics.lights.NhgLight)

Example 27 with Vector3

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

the class TiledForwardShader method getViewSpaceDirection.

private Vector3 getViewSpaceDirection(NhgLight light) {
    Vector3 direction = VectorPool.getVector3();
    direction.set(light.direction).rot(camera.view);
    return direction;
}
Also used : Vector3(com.badlogic.gdx.math.Vector3)

Example 28 with Vector3

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

the class TiledForwardShader method getViewSpacePosition.

private Vector3 getViewSpacePosition(NhgLight light) {
    Vector3 position = VectorPool.getVector3();
    position.set(light.position).mul(camera.view);
    return position;
}
Also used : Vector3(com.badlogic.gdx.math.Vector3)

Example 29 with Vector3

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

the class TiledForwardShader method cullSpotLight.

private void cullSpotLight(NhgLight light) {
    Matrix4 a = MatrixPool.getMatrix4();
    a.setToTranslation(light.position);
    Matrix4 b = MatrixPool.getMatrix4();
    b.set(a).translate(new Vector3(light.direction).scl(light.radius));
    Vector3 p1 = VectorPool.getVector3();
    Vector3 p2 = VectorPool.getVector3();
    Vector3 m = VectorPool.getVector3();
    a.getTranslation(p1);
    b.getTranslation(p2);
    m.set(p1).add(p2).scl(0.5f);
    float radius = p1.dst(p2) * 0.5f;
    if (camera.frustum.sphereInFrustum(m, radius)) {
        lightsToRender.add(light);
    }
    VectorPool.freeVector3(p1, p2, m);
    MatrixPool.freeMatrix4(a, b);
}
Also used : Vector3(com.badlogic.gdx.math.Vector3) Matrix4(com.badlogic.gdx.math.Matrix4)

Example 30 with Vector3

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

the class NodeComponent method translate.

/**
     * Translates the node.
     *
     * @param x     translation.
     * @param y     translation.
     * @param z     translation.
     * @param apply if true, transforms will be calculated immediately. It's not recommended, instead use
     *              {@link #applyTransforms() applyTransforms()} after you've completed all transforms on the node.
     */
public void translate(float x, float y, float z, boolean apply) {
    translationDelta.set(translation.x - x, translation.y - y, translation.z - z);
    Vector3 translation = VectorPool.getVector3();
    translation.set(x, y, z);
    float len = translation.len();
    translation.rot(node.localTransform).nor().scl(len);
    node.translation.add(translation);
    if (apply) {
        applyTransforms();
    }
    VectorPool.freeVector3(translation);
}
Also used : Vector3(com.badlogic.gdx.math.Vector3)

Aggregations

Vector3 (com.badlogic.gdx.math.Vector3)64 Matrix4 (com.badlogic.gdx.math.Matrix4)10 Quaternion (com.badlogic.gdx.math.Quaternion)9 Vector2 (com.badlogic.gdx.math.Vector2)6 Node (com.badlogic.gdx.graphics.g3d.model.Node)5 Texture (com.badlogic.gdx.graphics.Texture)4 Model (com.badlogic.gdx.graphics.g3d.Model)4 NodeKeyframe (com.badlogic.gdx.graphics.g3d.model.NodeKeyframe)4 BoundingBox (com.badlogic.gdx.math.collision.BoundingBox)4 VertexAttribute (com.badlogic.gdx.graphics.VertexAttribute)3 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)3 Material (com.badlogic.gdx.graphics.g3d.Material)3 ModelNode (com.badlogic.gdx.graphics.g3d.model.data.ModelNode)3 ModelBuilder (com.badlogic.gdx.graphics.g3d.utils.ModelBuilder)3 Mesh (com.badlogic.gdx.graphics.Mesh)2 OrthographicCamera (com.badlogic.gdx.graphics.OrthographicCamera)2 ModelInstance (com.badlogic.gdx.graphics.g3d.ModelInstance)2 Animation (com.badlogic.gdx.graphics.g3d.model.Animation)2 MeshPart (com.badlogic.gdx.graphics.g3d.model.MeshPart)2 NodeAnimation (com.badlogic.gdx.graphics.g3d.model.NodeAnimation)2