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);
}
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;
}
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;
}
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);
}
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);
}
Aggregations