Example usage for javax.media.j3d TexCoordGeneration SPHERE_MAP

List of usage examples for javax.media.j3d TexCoordGeneration SPHERE_MAP

Introduction

In this page you can find the example usage for javax.media.j3d TexCoordGeneration SPHERE_MAP.

Prototype

int SPHERE_MAP

To view the source code for javax.media.j3d TexCoordGeneration SPHERE_MAP.

Click Source Link

Document

Generates texture coordinates using a spherical reflection mapping in eye coordinates.

Usage

From source file:TexCoordTest.java

public void actionPerformed(ActionEvent event) {
    if (event.getActionCommand().equals("EYE_LINEAR") != false)
        m_TexGen.setGenMode(TexCoordGeneration.EYE_LINEAR);

    else if (event.getActionCommand().equals("OBJECT_LINEAR") != false)
        m_TexGen.setGenMode(TexCoordGeneration.OBJECT_LINEAR);

    else if (event.getActionCommand().equals("SPHERE_MAP") != false)
        m_TexGen.setGenMode(TexCoordGeneration.SPHERE_MAP);

    else if (event.getActionCommand().equals("Rotate") != false)
        m_RotationInterpolator.setEnable(!m_RotationInterpolator.getEnable());

    else if (event.getActionCommand().equals("Translate") != false)
        m_PositionInterpolator.setEnable(!m_PositionInterpolator.getEnable());

    // apply any changes to the TexCoordGeneration and copy into the
    // appearance
    TexCoordGeneration texCoordGeneration = new TexCoordGeneration();
    texCoordGeneration = (TexCoordGeneration) m_TexGen.cloneNodeComponent(true);
    m_Appearance.setTexCoordGeneration(texCoordGeneration);
}

From source file:AppearanceTest.java

public void onSPHERE_MAP() {
    getTexCoordGeneration().setGenMode(TexCoordGeneration.SPHERE_MAP);
    assignToAppearance();
}

From source file:AppearanceExplorer.java

TexCoordGenerationEditor(Appearance initApp, boolean initEnable, int initMode, Vector4f initPlaneS,
        Vector4f initPlaneT) {/*  ww w . j  av  a 2s.  c  o  m*/

    super(BoxLayout.Y_AXIS);
    app = initApp;
    enable = initEnable;
    mode = initMode;
    planeS.set(initPlaneS);
    planeT.set(initPlaneT);
    setTexGen(); // set up the initial texGen

    JCheckBox enableCheckBox = new JCheckBox("Enable Tex Coord Gen");
    enableCheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            enable = ((JCheckBox) e.getSource()).isSelected();
            texGen.setEnable(enable);
        }
    });
    add(new LeftAlignComponent(enableCheckBox));

    // texture boundaries
    String[] modeNames = { "OBJECT_LINEAR", "EYE_LINEAR", "SPHERE_MAP", };
    int[] modeValues = { TexCoordGeneration.OBJECT_LINEAR, TexCoordGeneration.EYE_LINEAR,
            TexCoordGeneration.SPHERE_MAP, };

    // tex gen modes
    IntChooser modeChooser = new IntChooser("Generation Mode:", modeNames, modeValues);
    modeChooser.setValue(mode);
    modeChooser.addIntListener(new IntListener() {
        public void intChanged(IntEvent event) {
            int value = event.getValue();
            mode = value;
            setTexGen();
        }
    });
    add(modeChooser);

    // make a panel for both sets of sliders and then two sub-panels,
    // one for each group of sliders
    Box sliderPanel = new Box(BoxLayout.Y_AXIS);
    add(sliderPanel);

    Box planeSPanel = new Box(BoxLayout.Y_AXIS);
    Box planeTPanel = new Box(BoxLayout.Y_AXIS);
    sliderPanel.add(planeSPanel);
    sliderPanel.add(planeTPanel);

    planeSPanel.add(new LeftAlignComponent(new JLabel("Plane S:")));
    FloatLabelJSlider planeSxSlider = new FloatLabelJSlider("X:", 0.1f, -10.0f, 10.0f, planeS.x);
    planeSxSlider.setMajorTickSpacing(0.1f);
    planeSxSlider.setPaintTicks(true);
    planeSxSlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            planeS.x = e.getValue();
            setTexGen();
        }
    });
    planeSPanel.add(planeSxSlider);

    FloatLabelJSlider planeSySlider = new FloatLabelJSlider("Y:", 0.1f, -10.0f, 10.0f, planeS.y);
    planeSySlider.setMajorTickSpacing(0.1f);
    planeSySlider.setPaintTicks(true);
    planeSySlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            planeS.y = e.getValue();
            setTexGen();
        }
    });
    planeSPanel.add(planeSySlider);

    FloatLabelJSlider planeSzSlider = new FloatLabelJSlider("Z:", 0.1f, -10.0f, 10.0f, planeS.z);
    planeSzSlider.setMajorTickSpacing(0.1f);
    planeSzSlider.setPaintTicks(true);
    planeSzSlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            planeS.z = e.getValue();
            setTexGen();
        }
    });
    planeSPanel.add(planeSzSlider);

    FloatLabelJSlider planeSwSlider = new FloatLabelJSlider("W:", 0.1f, -10.0f, 10.0f, planeS.w);
    planeSwSlider.setMajorTickSpacing(0.1f);
    planeSwSlider.setPaintTicks(true);
    planeSwSlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            planeS.w = e.getValue();
            setTexGen();
        }
    });
    planeSPanel.add(planeSwSlider);

    planeSPanel.add(new LeftAlignComponent(new JLabel("Plane T:")));
    FloatLabelJSlider planeTxSlider = new FloatLabelJSlider("X:", 0.1f, -10.0f, 10.0f, planeT.x);
    planeTxSlider.setMajorTickSpacing(0.1f);
    planeTxSlider.setPaintTicks(true);
    planeTxSlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            planeT.x = e.getValue();
            setTexGen();
        }
    });
    planeTPanel.add(planeTxSlider);

    FloatLabelJSlider planeTySlider = new FloatLabelJSlider("Y:", 0.1f, -10.0f, 10.0f, planeT.y);
    planeTySlider.setMajorTickSpacing(0.1f);
    planeTySlider.setPaintTicks(true);
    planeTySlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            planeT.y = e.getValue();
            setTexGen();
        }
    });
    planeTPanel.add(planeTySlider);

    FloatLabelJSlider planeTzSlider = new FloatLabelJSlider("Z:", 0.1f, -10.0f, 10.0f, planeT.z);
    planeTzSlider.setMajorTickSpacing(0.1f);
    planeTzSlider.setPaintTicks(true);
    planeTzSlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            planeT.z = e.getValue();
            setTexGen();
        }
    });
    planeTPanel.add(planeTzSlider);

    FloatLabelJSlider planeTwSlider = new FloatLabelJSlider("W:", 0.1f, -10.0f, 10.0f, planeT.w);
    planeTwSlider.setMajorTickSpacing(0.1f);
    planeTwSlider.setPaintTicks(true);
    planeTwSlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            planeT.w = e.getValue();
            setTexGen();
        }
    });
    planeTPanel.add(planeTwSlider);
}