skeletalMesh.material.setFloat("blockLight", 1.0f, true);
skeletalMesh.material.setMatrix4("projectionMatrix", worldRenderer.getActiveCamera().getProjectionMatrix());
skeletalMesh.material.bindTextures();
LocationComponent location = entity.getComponent(LocationComponent.class);
location.getWorldRotation(worldRot);
inverseWorldRot.inverse(worldRot);
location.getWorldPosition(worldPos);
Vector3f worldPositionCameraSpace = new Vector3f();
worldPositionCameraSpace.sub(worldPos, cameraPosition);
worldPos.y -= skeletalMesh.heightOffset;
float worldScale = location.getWorldScale();
matrixCameraSpace.set(worldRot, worldPositionCameraSpace, worldScale);
Matrix4f modelViewMatrix = MatrixUtils.calcModelViewMatrix(worldRenderer.getActiveCamera().getViewMatrix(), matrixCameraSpace);
MatrixUtils.matrixToFloatBuffer(modelViewMatrix, tempMatrixBuffer44);
skeletalMesh.material.setMatrix4("worldViewMatrix", tempMatrixBuffer44, true);
MatrixUtils.matrixToFloatBuffer(MatrixUtils.calcNormalMatrix(modelViewMatrix), tempMatrixBuffer33);
skeletalMesh.material.setMatrix3("normalMatrix", tempMatrixBuffer33, true);
skeletalMesh.material.setFloat("sunlight", worldRenderer.getSunlightValueAt(worldPos), true);
skeletalMesh.material.setFloat("blockLight", worldRenderer.getBlockLightValueAt(worldPos), true);
// TODO: Add frustum culling here
List<Vector3f> bonePositions = Lists.newArrayListWithCapacity(skeletalMesh.mesh.getVertexCount());
List<Quat4f> boneRotations = Lists.newArrayListWithCapacity(skeletalMesh.mesh.getVertexCount());
for (Bone bone : skeletalMesh.mesh.getBones()) {
EntityRef boneEntity = skeletalMesh.boneEntities.get(bone.getName());
if (boneEntity == null) {
boneEntity = EntityRef.NULL;
}
LocationComponent boneLocation = boneEntity.getComponent(LocationComponent.class);
if (boneLocation != null) {
Vector3f pos = boneLocation.getWorldPosition();
pos.sub(worldPos);
QuaternionUtil.quatRotate(inverseWorldRot, pos, pos);
bonePositions.add(pos);
Quat4f rot = new Quat4f();
rot.mul(inverseWorldRot, boneLocation.getWorldRotation());
boneRotations.add(rot);
} else {
logger.warn("Unable to resolve bone \"{}\"", bone.getName());
bonePositions.add(new Vector3f());
boneRotations.add(new Quat4f());