Package com.ardor3d.extension.ui

Examples of com.ardor3d.extension.ui.UIFrame


        pane.add(panel2, "grid");
        pane.add(panel3, "chat");
        pane.add(panel4, "clock");
        pane.add(panel5, "picture");

        frame = new UIFrame("UI Sample");
        frame.setContentPanel(pane);
        frame.updateMinimumSizeFromContents();
        frame.layout();
        frame.pack();
View Full Code Here


        _initialX = Math.round(vec.getXf());
        _initialY = Math.round(vec.getYf());
        Vector3.releaseTempInstance(vec);

        final UIFrame frame = UIFrame.findParentFrame(_uiFrameStatusBar);
        _initialLocalComponentWidth = frame.getLocalComponentWidth();
        _initialLocalComponentHeight = frame.getLocalComponentHeight();

        _initFrameTransform.set(frame.getWorldTransform());
    }
View Full Code Here

        _uiFrameStatusBar.getWorldTransform().applyInverseVector(vec);

        final int x = Math.round(vec.getXf());
        final int y = Math.round(vec.getYf());

        final UIFrame frame = UIFrame.findParentFrame(_uiFrameStatusBar);

        // Set the new width to the initial width + the change in mouse x position.
        int newWidth = _initialLocalComponentWidth + x - _initialX;
        if (newWidth < UIFrame.MIN_FRAME_WIDTH) {
            // don't let us get smaller than min size
            newWidth = UIFrame.MIN_FRAME_WIDTH;
        }
        if (newWidth < frame.getMinimumLocalComponentWidth()) {
            // don't let us get smaller than frame min size
            newWidth = frame.getMinimumLocalComponentWidth();
        }
        if (newWidth > frame.getMaximumLocalComponentWidth()) {
            // don't let us get bigger than frame max size
            newWidth = frame.getMaximumLocalComponentWidth();
        }

        // Set the new height to the initial height + the change in mouse y position.
        int newHeight = _initialLocalComponentHeight - (y - _initialY);
        if (newHeight < UIFrame.MIN_FRAME_HEIGHT) {
            // don't let us get smaller than absolute min size
            newHeight = UIFrame.MIN_FRAME_HEIGHT;
        }
        if (newHeight < frame.getMinimumLocalComponentHeight()) {
            // don't let us get smaller than frame min size
            newHeight = frame.getMinimumLocalComponentHeight();
        }
        if (newHeight > frame.getMaximumLocalComponentHeight()) {
            // don't let us get bigger than frame max size
            newHeight = frame.getMaximumLocalComponentHeight();
        }

        frame.setLocalComponentSize(newWidth, newHeight);

        vec.set(0, _initialLocalComponentHeight - newHeight, 0);
        _initFrameTransform.applyForwardVector(vec);
        frame.setTransform(_initFrameTransform);
        frame.addTranslation(vec);
        Vector3.releaseTempInstance(vec);

        frame.layout();
    }
View Full Code Here

        // setup hud
        hud = new UIHud();
        hud.setupInput(_canvas, _physicalLayer, _logicalLayer);
        hud.setMouseManager(_mouseManager);

        final UIFrame frame = new UIFrame("Controls", EnumSet.noneOf(FrameButtons.class));
        frame.setResizeable(false);

        final UILabel turnLabel = new UILabel("Turn Speed: " + ROCKET_TURN_SPEED);
        final UISlider turnSlider = new UISlider(Orientation.Horizontal, 0, 250, (int) (ROCKET_TURN_SPEED * 10));
        turnSlider.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent event) {
                ROCKET_TURN_SPEED = turnSlider.getValue() / 10;
                turnLabel.setText("Turn Speed: " + ROCKET_TURN_SPEED);
            }
        });

        final UILabel propelLabel = new UILabel("Propel Speed: " + ROCKET_PROPEL_SPEED);
        final UISlider propelSlider = new UISlider(Orientation.Horizontal, 0, 250, (int) (ROCKET_PROPEL_SPEED));
        propelSlider.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent event) {
                ROCKET_PROPEL_SPEED = propelSlider.getValue();
                propelLabel.setText("Propel Speed: " + ROCKET_PROPEL_SPEED);
            }
        });

        final UILabel ageLabel = new UILabel("Max Age of Smoke: " + age + " ms");
        final UISlider ageSlider = new UISlider(Orientation.Horizontal, 25, 400, age / 10);
        ageSlider.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent event) {
                age = ageSlider.getValue() * 10;
                ageLabel.setText("Max Age of Smoke: " + age + " ms");
                smoke.setMaximumLifeTime(age);
                smoke.setMinimumLifeTime(age / 2);
            }
        });

        final UICheckBox twoDimCheck = new UICheckBox("Constrain Rocket to 2D Plane.");
        twoDimCheck.setSelected(stayIn2DPlane);
        twoDimCheck.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent event) {
                stayIn2DPlane = twoDimCheck.isSelected();
            }
        });

        final UICheckBox worldCoordsCheck = new UICheckBox("Particles are in world coords");
        worldCoordsCheck.setSelected(particleInWorld);
        worldCoordsCheck.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent event) {
                particleInWorld = worldCoordsCheck.isSelected();
                smoke.setParticlesInWorldCoords(particleInWorld);
            }
        });

        final UIPanel panel = new UIPanel(new RowLayout(false, true, false));
        panel.setPadding(new Insets(10, 20, 10, 20));
        panel.add(turnLabel);
        panel.add(turnSlider);
        panel.add(propelLabel);
        panel.add(propelSlider);
        panel.add(ageLabel);
        panel.add(ageSlider);
        panel.add(twoDimCheck);
        panel.add(worldCoordsCheck);

        frame.setContentPanel(panel);
        frame.pack();
        final Camera cam = _canvas.getCanvasRenderer().getCamera();
        frame.setLocalXY(cam.getWidth() - frame.getLocalComponentWidth(),
                cam.getHeight() - frame.getLocalComponentHeight());
        hud.add(frame);
    }
View Full Code Here

        final int height = _canvas.getCanvasRenderer().getCamera().getHeight();

        hud = new UIHud();

        // Add Frame for balls
        _ballFrame = new UIFrame("Bubbles");
        _ballFrame.updateMinimumSizeFromContents();
        _ballFrame.pack(500, 300);
        _ballFrame.layout();
        _ballFrame.setResizeable(false);
        _ballFrame.setHudXY(5, 5);
View Full Code Here

        hud.setupInput(_canvas, _physicalLayer, _logicalLayer);
    }

    private void buildConfigFrame(final int width, final int height) {
        _configFrame = new UIFrame("Config");
        _configFrame.updateMinimumSizeFromContents();
        _configFrame.pack(320, 240);
        _configFrame.setUseStandin(true);
        _configFrame.setHudXY(width - _configFrame.getLocalComponentWidth() - 5, height
                - _configFrame.getLocalComponentHeight() - 5);
View Full Code Here

        pane.add(panel2, "grid");
        pane.add(panel3, "chat");
        pane.add(panel4, "clock");
        pane.add(panel5, "picture");

        frame = new UIFrame("UI Sample");
        frame.setContentPanel(pane);
        frame.updateMinimumSizeFromContents();
        frame.layout();
        frame.pack();
View Full Code Here

        UIComponent.setUseTransparency(true);

        final UIPanel panel = makePanel();

        final UIFrame frame = new UIFrame("Sample");
        frame.setContentPanel(panel);
        frame.updateMinimumSizeFromContents();
        frame.layout();
        frame.pack(300, 200);

        frame.setUseStandin(false);
        frame.setOpacity(1f);
        frame.setLocationRelativeTo(_canvas.getCanvasRenderer().getCamera());
        frame.setName("sample");

        final Matrix3 rotate = new Matrix3();
        final Vector3 axis = new Vector3(0, 0, 1).normalizeLocal();
        rotate.fromAngleNormalAxis(45 * MathUtils.DEG_TO_RAD, axis);
        frame.setRotation(rotate);

        hud = new UIHud();
        hud.add(frame);
        hud.setupInput(_canvas, _physicalLayer, _logicalLayer);

        frame.setLocationRelativeTo(_canvas.getCanvasRenderer().getCamera());
    }
View Full Code Here

        // setup hud
        hud = new UIHud();
        hud.setupInput(_canvas, _physicalLayer, _logicalLayer);
        hud.setMouseManager(_mouseManager);

        final UIFrame frame = new UIFrame("Controls", EnumSet.noneOf(FrameButtons.class));
        frame.setResizeable(false);

        final UILabel distLabel = new UILabel("Max Shadow Distance: 1500");
        final UISlider distSlider = new UISlider(Orientation.Horizontal, 0, 2000, 1500);
        distSlider.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent event) {
                _pssmPass.setMaxShadowDistance(distSlider.getValue());
                distLabel.setText("Max Shadow Distance: " + distSlider.getValue());
            }
        });

        final UIButton updateCamera = new UIButton("Update Shadow Camera");
        updateCamera.setSelectable(true);
        updateCamera.setSelected(true);
        updateCamera.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent event) {
                _pssmPass.setUpdateMainCamera(updateCamera.isSelected());
                updateText();
            }
        });

        final UIButton rotateLight = new UIButton("Rotate Light");
        rotateLight.setSelectable(true);
        rotateLight.setSelected(false);
        rotateLight.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent event) {
                moveLight = rotateLight.isSelected();
                updateText();
            }
        });

        final UIPanel panel = new UIPanel(new RowLayout(false, true, false));
        panel.setPadding(new Insets(10, 20, 10, 20));
        panel.add(distLabel);
        panel.add(distSlider);
        panel.add(updateCamera);
        panel.add(rotateLight);

        frame.setContentPanel(panel);
        frame.pack();
        final Camera cam = _canvas.getCanvasRenderer().getCamera();
        frame.setLocalXY(cam.getWidth() - frame.getLocalComponentWidth(),
                cam.getHeight() - frame.getLocalComponentHeight());
        hud.add(frame);
    }
View Full Code Here

        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);
    }
View Full Code Here

TOP

Related Classes of com.ardor3d.extension.ui.UIFrame

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.