frameRateLabel.setHudXY(5,
_canvas.getCanvasRenderer().getCamera().getHeight() - 5 - frameRateLabel.getContentHeight());
frameRateLabel.setForegroundColor(ColorRGBA.WHITE);
hud.add(frameRateLabel);
final UIFrame optionsFrame = new UIFrame("Controls", EnumSet.noneOf(FrameButtons.class));
final UIPanel basePanel = optionsFrame.getContentPanel();
basePanel.setLayout(new AnchorLayout());
runWalkButton = new UIButton("Start running...");
runWalkButton.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, basePanel, Alignment.TOP_LEFT, 5, -5));
runWalkButton.addActionListener(new ActionListener() {
boolean walk = true;
public void actionPerformed(final ActionEvent event) {
if (!walk) {
if (manager.getBaseAnimationLayer().doTransition("walk")) {
runWalkButton.setButtonText("Start running...");
walk = true;
}
} else {
if (manager.getBaseAnimationLayer().doTransition("run")) {
runWalkButton.setButtonText("Start walking...");
walk = false;
}
}
}
});
basePanel.add(runWalkButton);
punchButton = new UIButton("PUNCH!");
punchButton
.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, runWalkButton, Alignment.BOTTOM_LEFT, 0, -5));
punchButton.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent event) {
manager.findAnimationLayer("punch").setCurrentState("punch_right", true);
punchButton.setEnabled(false);
}
});
basePanel.add(punchButton);
headCheck = new UICheckBox("Procedurally turn head");
headCheck.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, punchButton, Alignment.BOTTOM_LEFT, 0, -5));
headCheck.setSelected(true);
headCheck.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent event) {
manager.getValuesStore().put("head_blend", headCheck.isSelected() ? 1.0 : 0.0);
}
});
basePanel.add(headCheck);
final UICheckBox gpuSkinningCheck = new UICheckBox("Use GPU skinning");
gpuSkinningCheck
.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, headCheck, Alignment.BOTTOM_LEFT, 0, -5));
gpuSkinningCheck.setSelected(false);
gpuSkinningCheck.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent event) {
_root.acceptVisitor(new Visitor() {
@Override
public void visit(final Spatial spatial) {
if (spatial instanceof SkinnedMesh) {
final SkinnedMesh skinnedSpatial = (SkinnedMesh) spatial;
if (gpuSkinningCheck.isSelected()) {
skinnedSpatial.setGPUShader(gpuShader);
skinnedSpatial.setUseGPU(true);
} else {
skinnedSpatial.setGPUShader(null);
skinnedSpatial.clearRenderState(StateType.GLSLShader);
skinnedSpatial.setUseGPU(false);
}
}
}
}, true);
}
});
basePanel.add(gpuSkinningCheck);
final UICheckBox vboCheck = new UICheckBox("Use VBO");
vboCheck.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, gpuSkinningCheck, Alignment.BOTTOM_LEFT, 0, -5));
vboCheck.setSelected(false);
vboCheck.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent event) {
skNode.getSceneHints().setDataMode(vboCheck.isSelected() ? DataMode.VBO : DataMode.Arrays);
gpuShader.setUseAttributeVBO(vboCheck.isSelected());
}
});
basePanel.add(vboCheck);
final UICheckBox skeletonCheck = new UICheckBox("Show skeleton");
final UICheckBox boneLabelCheck = new UICheckBox("Show joint labels");
skeletonCheck.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, vboCheck, Alignment.BOTTOM_LEFT, 0, -5));
skeletonCheck.setSelected(showSkeleton);
skeletonCheck.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent event) {
showSkeleton = skeletonCheck.isSelected();
boneLabelCheck.setEnabled(showSkeleton);
}
});
basePanel.add(skeletonCheck);
boneLabelCheck.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, skeletonCheck, Alignment.BOTTOM_LEFT, 0,
-5));
boneLabelCheck.setSelected(false);
boneLabelCheck.setEnabled(showSkeleton);
boneLabelCheck.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent event) {
showJointLabels = boneLabelCheck.isSelected();
}
});
basePanel.add(boneLabelCheck);
optionsFrame.updateMinimumSizeFromContents();
optionsFrame.layout();
optionsFrame.pack();
optionsFrame.setUseStandin(true);
optionsFrame.setOpacity(0.8f);
final Camera cam = _canvas.getCanvasRenderer().getCamera();
optionsFrame.setLocalXY(cam.getWidth() - optionsFrame.getLocalComponentWidth() - 10, cam.getHeight()
- optionsFrame.getLocalComponentHeight() - 10);
hud.add(optionsFrame);
UIComponent.setUseTransparency(true);
}