Continuing the discussion from Nifty HUD causing fps drop:
Take this code here for a fixed picture rotating with your camera.
private Picture compass;
private Node compassNode;
public void initialize(AppStateManager stateManager, Application application) {
attachCompass();
}
private void attachCompass() {
compass = new Picture("compass");
compass.setHeight(64.0f);
compass.setWidth(64.0f);
compass.setImage(app.getAssetManager(), "Textures/compass.png", true);
compass.center();
compassNode = new Node();
compassNode.attachChild(compass);
compassNode.setLocalTranslation(app.getGuiViewPort().getCamera().getWidth() - 100, app.getGuiViewPort().getCamera().getHeight() - 100, 0);
updateCompass();
app.getGuiNode().attachChild(compassNode);
}
public void update(float tpf) {
updateCompass();
}
private void updateCompass() {
float[] angles = cam.getLocalRotation().toAngles(null);
compassNode.setLocalRotation(new Quaternion(new float[]{0.0f, 0.0f, angles[1]}));
}
I am assuming the angles are right, but you might have to fix them, because we dont use a normal camera.
Heres a picture of it. The red arrow is north.