private void calculateCameraPosition(float horizontalDistance, float verticalDistance) { float theta = player.getRotY() + angleAroundPlayer; float offsetX = (float) (horizontalDistance * Math.sin(Math.toRadians(theta))); float offsetZ = (float) (horizontalDistance * Math.cos(Math.toRadians(theta))); position.x = player.getPosition().x - offsetX; position.z = player.getPosition().z - offsetZ; position.y = player.getPosition().y + 1 + verticalDistance; yaw = 180.0f - theta; }
private void prepareInstance(Entity entity) { Matrix4f transformationMatrix = Maths.createTransformationMatrix( entity.getPosition(), entity.getRotX(), entity.getRotY(), entity.getRotZ(), entity.getScale()); shader.loadTransformationMatrix(transformationMatrix); shader.loadOffset(entity.getTextureXOffset(), entity.getTextureYOffset()); }