de.javagl.swogl.layout
Class BillboardLayout3D

java.lang.Object
  extended by de.javagl.swogl.layout.BillboardLayout3D
All Implemented Interfaces:
LayoutManager3D, CameraListener

public class BillboardLayout3D
extends java.lang.Object
implements LayoutManager3D, CameraListener

This is an implementation of the LayoutManager3D interface that lays out all SwoglComponents so that they face the viewer. The computation is based on a Camera that provides the viewing information. This class also offers a static utility method for computing the billboarding transform, which may be used in other implementations of layout managers.


Constructor Summary
BillboardLayout3D(Camera camera)
          Creates a new BillboardLayout3D that lets all SwoglComponents face the given camera.
 
Method Summary
 void cameraChanged(Camera camera)
          Will be called when a property of the given Camera changed
static javax.vecmath.Matrix4f computeBillboardTransform(SwoglComponent swoglComponent, Camera camera)
          Utility method that computes the transform that must be applied to the given SwoglComponent so that it faces the given Camera.
 void doLayout3D()
          Lays out the SwoglComponents in a SwoglContainer
 void setSwoglContainer(SwoglContainer swoglContainer)
          This method will assign the given SwoglContainer to this LayoutManager3D.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BillboardLayout3D

public BillboardLayout3D(Camera camera)
Creates a new BillboardLayout3D that lets all SwoglComponents face the given camera. This layout will be attached as a CameraListener to the given Camera.

Parameters:
camera - The camera
Method Detail

cameraChanged

public void cameraChanged(Camera camera)
Description copied from interface: CameraListener
Will be called when a property of the given Camera changed

Specified by:
cameraChanged in interface CameraListener
Parameters:
camera - The Camera

setSwoglContainer

public void setSwoglContainer(SwoglContainer swoglContainer)
Description copied from interface: LayoutManager3D
This method will assign the given SwoglContainer to this LayoutManager3D. When this LayoutManager3D is assigned to a SwoglContainer using the SwoglContainer.setLayout3D(LayoutManager3D) method, the SwoglContainer will pass itself to this method. When a different LayoutManager3D is assigned to the SwoglContainer, then the SwoglContainer will call this method and pass null as the argument. This allows implementations of this interface to perform an initialization when this LayoutManager3D becomes assigned to a SwoglContainer, and necessary cleanup operations when it is detached from a SwoglContainer.

Specified by:
setSwoglContainer in interface LayoutManager3D
Parameters:
swoglContainer - The SwoglContainer for this LayoutManager3D

doLayout3D

public void doLayout3D()
Description copied from interface: LayoutManager3D
Lays out the SwoglComponents in a SwoglContainer

Specified by:
doLayout3D in interface LayoutManager3D

computeBillboardTransform

public static javax.vecmath.Matrix4f computeBillboardTransform(SwoglComponent swoglComponent,
                                                               Camera camera)
Utility method that computes the transform that must be applied to the given SwoglComponent so that it faces the given Camera.

Parameters:
swoglComponent - The SwoglComponent
camera - The Camera
Returns:
The billboarding transform