So I created a test case and could track it down. Before opening a thread could you maybe confirm whether it’s broken or just misuse?
b.setAlignment(BillboardControl.Alignment.Screen); // This works fully
b.setAlignment(BillboardControl.Alignment.AxialZ); // Couldn't check, does wierd things :P
b.setAlignment(BillboardControl.Alignment.AxialY); // This is the one I am using, leads to trouble
b.setAlignment(BillboardControl.Alignment.Camera); // This is like without BillBoard (and I used the flyCam here)
Note: They all work when applied to the parent axis (where they basically override the actual rotation) but not as a child axis.
package mygame;
import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.FastMath;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.control.BillboardControl;
import com.jme3.scene.shape.Quad;
public class Main extends SimpleApplication {
Node n;
public static void main(String[] args) {
Main app = new Main();
app.start();
}
@Override
public void simpleInitApp()
{
n = new Node("myNode");
Node o = new Node("subNode");
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.Blue);
Quad q = new Quad(1f, 1f);
Geometry geom = new Geometry("Box", q);
geom.setMaterial(mat);
o.attachChild(geom);
BillboardControl b = new BillboardControl();
b.setAlignment(BillboardControl.Alignment.AxialY);
o.addControl(b);
n.attachChild(o);
n.rotate(0f, FastMath.HALF_PI, 0f);
rootNode.attachChild(n);
flyCam.setMoveSpeed(flyCam.getMoveSpeed() * 5f);
}
@Override
public void simpleUpdate(float tpf)
{
n.rotate(0f, FastMath.HALF_PI * tpf, 0f);
}
}
Edit: Checked the Code that comes with my 3.0 SDK:
In rotateScreenAligned (the one that works), there is:
if ( parent != null ) {
rot = parent.getWorldRotation().inverse().multLocal(rot);
rot.normalizeLocal();
}
This however is missing in rotateCameraAligned and rotateAxial. I will try to fix it and see if i can do it with my humble Quaternion skills
Edit2: Adding that did partially work (Screen and Camera work, Axial only works if you DONT rotate the spatial (but you can move the camera))