⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bloompasseditor.java

📁 java 3d game jme 工程开发源代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
 * Copyright (c) 2003-2009 jMonkeyEngine
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *
 * * Redistributions of source code must retain the above copyright
 *   notice, this list of conditions and the following disclaimer.
 *
 * * Redistributions in binary form must reproduce the above copyright
 *   notice, this list of conditions and the following disclaimer in the
 *   documentation and/or other materials provided with the distribution.
 *
 * * Neither the name of 'jMonkeyEngine' nor the names of its contributors 
 *   may be used to endorse or promote products derived from this software 
 *   without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
package com.jmex.editors.swing.pass;

import java.awt.BorderLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.border.TitledBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

import com.jmex.editors.swing.widget.ValueSpinner;
import com.jmex.effects.glsl.BloomRenderPass;

public class BloomPassEditor extends JPanel {
    private static final Logger logger = Logger.getLogger(BloomPassEditor.class
            .getName());
    
    private JCheckBox enabledCheckBox;
    private JRadioButton rerenderToPbufferRadioButton;
    private JRadioButton reuseFramebufferRadioButton;
    private static final long serialVersionUID = 1L;
    
    private ButtonGroup modeBG = new ButtonGroup();
    private ValueSpinner throttleField;
    private ValueSpinner sizeField;
    private ValueSpinner passesField;
    private ValueSpinner intensityField;
    private ValueSpinner powerField;
    private ValueSpinner cutoffField;
    
    private float origSize, origIntens, origPower, origCutoff;
    private int origPasses, origThrottleMS;
    private boolean origUseCurrent;

    protected File lastDir;
    
    public BloomPassEditor(final BloomRenderPass pass) {
        super();
        
        origCutoff = pass.getExposureCutoff();
        origIntens = pass.getBlurIntensityMultiplier();
        origPasses = pass.getNrBlurPasses();
        origPower = pass.getExposurePow();
        origSize = pass.getBlurSize();
        origUseCurrent = pass.useCurrentScene();
        origThrottleMS = (int)(pass.getThrottle()*1000);
        
        setLayout(new GridBagLayout());

        enabledCheckBox = new JCheckBox();
        enabledCheckBox.setSelected(pass.isEnabled());
        enabledCheckBox.addActionListener(new ActionListener() {
            public void actionPerformed(final ActionEvent e) {
                pass.setEnabled(enabledCheckBox.isSelected());
            }
        });
        enabledCheckBox.setText("Bloom Enabled");
        final GridBagConstraints gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridx = 0;
        add(enabledCheckBox, gridBagConstraints);

        final JPanel throttlePanel = new JPanel();
        final GridBagConstraints throttleConstraints = new GridBagConstraints();
        throttleConstraints.gridy = 1;
        throttleConstraints.gridx = 0;
        add(throttlePanel, throttleConstraints);

        final JLabel throttleLabel = new JLabel();
        throttleLabel.setText("Update Freq. (ms):");
        throttlePanel.add(throttleLabel);

        throttleField = new ValueSpinner(0, 1000, 1);
        throttleField.setValue((int)(pass.getThrottle()*1000));
        throttleField.addChangeListener(new ChangeListener() {
            public void stateChanged(ChangeEvent e) {
                pass.setThrottle(((Number) throttleField.getValue()).intValue()/1000f);
            }
        });
        throttlePanel.add(throttleField);

        final JPanel panel = new JPanel();
        panel.setLayout(new GridLayout(0, 1));
        panel.setBorder(new TitledBorder(null, "Render Mode", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
        final GridBagConstraints gridBagConstraints_1 = new GridBagConstraints();
        gridBagConstraints_1.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints_1.weightx = 1;
        gridBagConstraints_1.gridy = 2;
        gridBagConstraints_1.gridx = 0;
        add(panel, gridBagConstraints_1);

        reuseFramebufferRadioButton = new JRadioButton();
        if (pass.useCurrentScene())
            reuseFramebufferRadioButton.setSelected(true);
        reuseFramebufferRadioButton.addActionListener(new ActionListener() {
            public void actionPerformed(final ActionEvent e) {
                pass.setUseCurrentScene(true);
            }
        });
        modeBG.add(reuseFramebufferRadioButton);
        reuseFramebufferRadioButton.setText("Reuse FrameBuffer");
        panel.add(reuseFramebufferRadioButton);

        rerenderToPbufferRadioButton = new JRadioButton();
        if (!pass.useCurrentScene())
            rerenderToPbufferRadioButton.setSelected(true);
        rerenderToPbufferRadioButton.addActionListener(new ActionListener() {
            public void actionPerformed(final ActionEvent e) {
                pass.setUseCurrentScene(false);
            }
        });
        modeBG.add(rerenderToPbufferRadioButton);
        rerenderToPbufferRadioButton.setText("Rerender to PBuffer");
        panel.add(rerenderToPbufferRadioButton);

        final JPanel exposurePanel = new JPanel();
        exposurePanel.setLayout(new GridLayout(0, 2));
        exposurePanel.setBorder(new TitledBorder(null, "Exposure Settings", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
        final GridBagConstraints gridBagConstraints_2 = new GridBagConstraints();
        gridBagConstraints_2.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints_2.weightx = 1;
        gridBagConstraints_2.gridy = 3;
        gridBagConstraints_2.gridx = 0;
        add(exposurePanel, gridBagConstraints_2);

        final JLabel powerLabel = new JLabel();
        powerLabel.setText("Power:");
        exposurePanel.add(powerLabel);

        powerField = new ValueSpinner(0, 32, .01f);
        powerField.setValue(pass.getExposurePow());
        powerField.addChangeListener(new ChangeListener() {
            public void stateChanged(ChangeEvent e) {
                pass.setExposurePow(((Number) powerField.getValue()).floatValue());
            }
        });
        exposurePanel.add(powerField);

        final JLabel cutoffLabel = new JLabel();
        cutoffLabel.setText("Cutoff:");
        exposurePanel.add(cutoffLabel);

        cutoffField = new ValueSpinner(0, 10, .01f);
        cutoffField.setValue(pass.getExposureCutoff());
        cutoffField.addChangeListener(new ChangeListener() {
            public void stateChanged(ChangeEvent e) {
                pass.setExposureCutoff(((Number) cutoffField.getValue()).floatValue());
            }
        });

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -