bs.setDestinationFunction(BlendState.DestinationFunction.OneMinusSourceAlpha);
bs.setTestEnabled(true);
bs.setTestFunction(BlendState.TestFunction.GreaterThan);
rootNode.setRenderState(bs);
CellTransform transform = cell.getWorldTransform();
// Draw an arrow that mimics the light position --direction still under
//construction.
TextLabel2D label = new TextLabel2D(name,
Color.black, Color.white, 1.0f, true, Font.getFont("SANS_SERIF"));
Vector3f direction = directionalLight.getDirection();
Vector3f position = lightNode.getLocalTranslation();
Vector3f labelPosition = new Vector3f(position.x, position.y + 3, position.z);
Arrow arrow = new Arrow("Arrow", 3, 0.5f);
Node rotatedOnX = new Node("Rotated For Arrow");
rotatedOnX.setLocalRotation(new Quaternion().fromAngleAxis(90*FastMath.DEG_TO_RAD, new Vector3f(1, 0, 0)));
rotatedOnX.attachChild(arrow);
rotatedOnX.setLocalTranslation(position);
// arrow.setLocalTranslation(position);
label.setLocalTranslation(labelPosition);
arrow.lookAt(direction, new Vector3f(0,1,0));
rootNode.attachChild(label);
rootNode.attachChild(rotatedOnX);
// Fetch the world translation for the root node of the cell and set
// the translation for this entity root node
rootNode.setLocalTranslation(transform.getTranslation(null));
rootNode.setLocalRotation(transform.getRotation(null));
// OWL issue #61: make sure to take scale into account
rootNode.setLocalScale(transform.getScaling(null));
// Listen for changes to the cell's translation and apply the same
// update to the root node of the bounds viewer. We also re-set the size
// of the bounds: this handles the case where the bounds of the
// scene graph has changed and we need to update the bounds viewer
// accordingly.
updateListener = new TransformChangeListener() {
public void transformChanged(final Cell cell, ChangeSource source) {
// We need to perform this work inside a proper updater, to
// make sure we are MT thread safe
final WorldManager wm = ClientContextJME.getWorldManager();
RenderUpdater u = new RenderUpdater() {
public void update(Object obj) {
CellTransform transform = cell.getWorldTransform();
rootNode.setLocalTranslation(transform.getTranslation(null));
rootNode.setLocalRotation(transform.getRotation(null));
rootNode.setLocalScale(transform.getScaling(null));
wm.addToUpdateList(rootNode);
}
};
wm.addRenderUpdater(u, this);
}