com.jogamp.newt.event.KeyEvent Java Examples

The following examples show how to use com.jogamp.newt.event.KeyEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GPUTextRendererListenerBase01.java    From jogl-samples with MIT License 6 votes vote down vote up
@Override
public void keyReleased(final KeyEvent e) {
    if( !e.isPrintableKey() || e.isAutoRepeat() ) {
        return;
    }
    if(userInput) {
        final short k = e.getKeySymbol();
        if( KeyEvent.VK_ENTER == k ) {
            userInput = false;
            setIgnoreInput(false);
        } else if( KeyEvent.VK_BACK_SPACE == k && userString.length()>0) {
            userString.deleteCharAt(userString.length()-1);
        } else {
            final char c = e.getKeyChar();
            if( font.isPrintableChar( c ) ) {
                userString.append(c);
            }
        }
    }
}
 
Example #2
Source File: Test.java    From jogl-samples with MIT License 5 votes vote down vote up
@Override
public void keyReleased(KeyEvent e) {

    switch (e.getKeyCode()) {
        case KeyEvent.VK_ESCAPE:
            animator.stop();
            glWindow.destroy();
            break;
    }
}
 
Example #3
Source File: TextBasics.java    From jaamsim with Apache License 2.0 5 votes vote down vote up
@Override
public boolean handleKeyPressed(int keyCode, char keyChar, boolean shift, boolean control, boolean alt) {

	// If F2 is pressed, set edit mode
	if (keyCode == KeyEvent.VK_F2) {
		setEditMode(true);
		RenderManager.redraw();
		return true;
	}

	// If not in edit mode, apply the normal action for the keystroke
	if (!isEditMode()) {
		boolean ret = super.handleKeyPressed(keyCode, keyChar, shift, control, alt);
		return ret;
	}

	// If in edit mode, the apply the keystroke to the text
	int result = handleEditKeyPressed(keyCode, keyChar, shift, control, alt);
	if (result == Editable.ACCEPT_EDITS) {
		acceptEdits();
	}
	else if (result == Editable.CANCEL_EDITS) {
		cancelEdits();
	}
	RenderManager.redraw();
	return true;
}
 
Example #4
Source File: OverlayEntity.java    From jaamsim with Apache License 2.0 5 votes vote down vote up
@Override
public boolean handleKeyPressed(int keyCode, char keyChar, boolean shift, boolean control, boolean alt) {
	if (!isMovable())
		return false;

	IntegerVector pos = screenPosition.getValue();
	int x = pos.get(0);
	int y = pos.get(1);

	switch (keyCode) {

		case KeyEvent.VK_LEFT:
			x += getAlignRight() ? 1 : -1;
			break;

		case KeyEvent.VK_RIGHT:
			x += getAlignRight() ? -1 : 1;
			break;

		case KeyEvent.VK_UP:
			y += getAlignBottom() ? 1 : -1;
			break;

		case KeyEvent.VK_DOWN:
			y += getAlignBottom() ? -1 : 1;
			break;

		default:
			return false;
	}

	x = Math.max(0, x);
	y = Math.max(0, y);
	KeywordIndex kw = InputAgent.formatIntegers(screenPosition.getKeyword(), x, y);
	InputAgent.storeAndExecute(new KeywordCommand(this, kw));
	return true;
}
 
Example #5
Source File: DisplayEntity.java    From jaamsim with Apache License 2.0 5 votes vote down vote up
public void handleKeyReleased(int keyCode, char keyChar, boolean shift, boolean control, boolean alt) {
	if (keyCode == KeyEvent.VK_DELETE) {
		GUIListener gui = getJaamSimModel().getGUIListener();
		if (gui == null)
			return;
		try {
			gui.deleteEntity(this);
			FrameBox.setSelectedEntity(null, false);
		}
		catch (ErrorException e) {
			gui.invokeErrorDialogBox("User Error", e.getMessage());
		}
	}
}
 
Example #6
Source File: KeyboardControl.java    From clearvolume with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void processSingleKeyToggableEvents(KeyEvent pE,
																						final Collection<?> lOverlays)
{
	boolean lHasAnyOverlayBeenToggled = false;

	for (final Object lOverlay : lOverlays)
		if (lOverlay instanceof SingleKeyToggable)
		{
			final SingleKeyToggable lSingleKeyToggable = (SingleKeyToggable) lOverlay;

			final boolean lRightKey =
															pE.getKeyCode() == lSingleKeyToggable.toggleKeyCode();
			final boolean lRightModifiers =
																		pE.getModifiers() == lSingleKeyToggable.toggleKeyModifierMask();
			// (pE.getModifiers() &
			// lSingleKeyToggable.toggleKeyModifierMask()) ==
			// lSingleKeyToggable.toggleKeyModifierMask();

			if (lRightKey && lRightModifiers)
			{
				lSingleKeyToggable.toggle();

				lHasAnyOverlayBeenToggled = true;
			}
		}

	if (lHasAnyOverlayBeenToggled)
		mClearVolumeRenderer.notifyChangeOfVolumeRenderingParameters();
}
 
Example #7
Source File: KeyboardControl.java    From clearvolume with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void handleOverlayRelatedEvents(KeyEvent pE)
{
	final Collection<Overlay> lOverlays =
																			mClearVolumeRenderer.getOverlays();

	processSingleKeyToggableEvents(pE, lOverlays);
}
 
Example #8
Source File: OverlayText.java    From jaamsim with Apache License 2.0 5 votes vote down vote up
@Override
public boolean handleKeyPressed(int keyCode, char keyChar, boolean shift, boolean control, boolean alt) {

	// If F2 is pressed, set edit mode
	if (keyCode == KeyEvent.VK_F2) {
		setEditMode(true);
		RenderManager.redraw();
		return true;
	}

	// If not in edit mode, apply the normal action for the keystroke
	if (!isEditMode()) {
		boolean ret = super.handleKeyPressed(keyCode, keyChar, shift, control, alt);
		return ret;
	}

	// If in edit mode, the apply the keystroke to the text
	int result = handleEditKeyPressed(keyCode, keyChar, shift, control, alt);
	if (result == ACCEPT_EDITS) {
		acceptEdits();
	}
	else if (result == CANCEL_EDITS) {
		cancelEdits();
	}
	RenderManager.redraw();
	return true;
}
 
Example #9
Source File: HelloTriangleSimple.java    From hello-triangle with MIT License 5 votes vote down vote up
@Override
public void keyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
        new Thread(() -> {
            window.destroy();
        }).start();
    }
}
 
Example #10
Source File: GPUTextRendererListenerBase01.java    From jogl-samples with MIT License 5 votes vote down vote up
@Override
public void keyPressed(final KeyEvent e) {
    if(userInput) {
        return;
    }
    final short s = e.getKeySymbol();
    if(s == KeyEvent.VK_3) {
        if( e.isAltDown() ) {
            fontHeadIncr(1);
        } else {
            fontBottomIncr(1);
        }
    }
    else if(s == KeyEvent.VK_4) {
        if( e.isAltDown() ) {
            fontHeadIncr(-1);
        } else {
            fontBottomIncr(-1);
        }
    }
    else if(s == KeyEvent.VK_H) {
        switchHeadBox();
    }
    else if(s == KeyEvent.VK_F) {
        drawFPS = !drawFPS;
    }
    else if(s == KeyEvent.VK_SPACE) {
        nextFontSet();
    }
    else if(s == KeyEvent.VK_I) {
        userInput = true;
        setIgnoreInput(true);
    }
}
 
Example #11
Source File: HelloTexture.java    From hello-triangle with MIT License 5 votes vote down vote up
@Override
public void keyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
        new Thread(() -> {
            window.destroy();
        }).start();
    }
}
 
Example #12
Source File: HelloTriangle.java    From hello-triangle with MIT License 5 votes vote down vote up
@Override
public void keyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
        new Thread(() -> {
            window.destroy();
        }).start();
    }
}
 
Example #13
Source File: UINewtDemo01.java    From jogl-samples with MIT License 5 votes vote down vote up
public static void main(final String[] args) {
    final GLProfile glp = GLProfile.getGL2ES2();
    final GLCapabilities caps = new GLCapabilities(glp);
    caps.setAlphaBits(4);
    caps.setSampleBuffers(true);
    caps.setNumSamples(4);
    System.out.println("Requested: " + caps);

    final GLWindow window = GLWindow.create(caps);
    window.setPosition(10, 10);
    window.setSize(800, 400);
    window.setTitle("GPU UI Newt Demo 01");
    final RenderState rs = RenderState.createRenderState(SVertex.factory());
    final UIGLListener01 uiGLListener = new UIGLListener01 (0, rs, DEBUG, TRACE);
    uiGLListener.attachInputListenerTo(window);
    window.addGLEventListener(uiGLListener);
    window.setVisible(true);

    final Animator animator = new Animator();
    animator.setUpdateFPSFrames(60, System.err);
    animator.add(window);

    window.addKeyListener(new KeyAdapter() {
        public void keyPressed(final KeyEvent arg0) {
            if(arg0.getKeyCode() == KeyEvent.VK_F4) {
                window.destroy();
            }
        }
    });
    window.addWindowListener(new WindowAdapter() {
        public void windowDestroyed(final WindowEvent e) {
            animator.stop();
        }
    });

    animator.start();
}
 
Example #14
Source File: HelloGlobe.java    From hello-triangle with MIT License 5 votes vote down vote up
@Override
public void keyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
        new Thread(() -> {
            window.destroy();
        }).start();
    }
}
 
Example #15
Source File: CameraControl.java    From jaamsim with Apache License 2.0 5 votes vote down vote up
@Override
public void keyReleased(KeyEvent e) {
	if (RenderManager.inst().isEntitySelected()) {
		RenderManager.inst().handleKeyReleased(e.getKeyCode(), e.getKeyChar(),
				e.isShiftDown(), e.isControlDown(), e.isAltDown());
		return;
	}
}
 
Example #16
Source File: HelloTriangle.java    From hello-triangle with MIT License 5 votes vote down vote up
@Override
public void keyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
        new Thread(() -> {
            window.destroy();
        }).start();
    }
}
 
Example #17
Source File: KeyEventInput.java    From jaamsim with Apache License 2.0 5 votes vote down vote up
public static Integer getKeyCode(String name) {
	Integer code;
	if (name.length() == 1) {
		code = (int) KeyEvent.utf16ToVKey(name.charAt(0));
	}
	else {
		code = keyCodeMap.get(name.toUpperCase());
	}
	return code;
}
 
Example #18
Source File: HelloGlobe.java    From CPE552-Java with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void keyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
        new Thread(() -> {
            window.destroy();
        }).start();
    }
}
 
Example #19
Source File: HelloTriangle.java    From CPE552-Java with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void keyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
        new Thread(() -> {
            window.destroy();
        }).start();
    }
}
 
Example #20
Source File: CubeSample2.java    From MeteoInfo with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void keyReleased(KeyEvent e) {
	char keyChar = e.getKeyChar();
	if(keyChar == KEY_ESC || keyChar == 'q' || keyChar == 'Q') { //KeyEvent.VK_Qは大文字。小文字?
		glWindow.destroy();
	}
}
 
Example #21
Source File: KeyEventInput.java    From jaamsim with Apache License 2.0 4 votes vote down vote up
private static void initMaps() {
	mapKeyEvent("ADD",         KeyEvent.VK_ADD);
	mapKeyEvent("ALT",         KeyEvent.VK_ALT);
	mapKeyEvent("CONTROL",     KeyEvent.VK_CONTROL);
	mapKeyEvent("DECIMAL",     KeyEvent.VK_DECIMAL);
	mapKeyEvent("DELETE",      KeyEvent.VK_DELETE);
	mapKeyEvent("DIVIDE",      KeyEvent.VK_DIVIDE);
	mapKeyEvent("DOWN",        KeyEvent.VK_DOWN);
	mapKeyEvent("END",         KeyEvent.VK_END);
	mapKeyEvent("ENTER",       KeyEvent.VK_ENTER);
	mapKeyEvent("ESCAPE",      KeyEvent.VK_ESCAPE);
	mapKeyEvent("F1",          KeyEvent.VK_F1);
	mapKeyEvent("F2",          KeyEvent.VK_F2);
	mapKeyEvent("F3",          KeyEvent.VK_F3);
	mapKeyEvent("F4",          KeyEvent.VK_F4);
	mapKeyEvent("F5",          KeyEvent.VK_F5);
	mapKeyEvent("F6",          KeyEvent.VK_F6);
	mapKeyEvent("F7",          KeyEvent.VK_F7);
	mapKeyEvent("F8",          KeyEvent.VK_F8);
	mapKeyEvent("F9",          KeyEvent.VK_F9);
	mapKeyEvent("F10",         KeyEvent.VK_F10);
	mapKeyEvent("F11",         KeyEvent.VK_F11);
	mapKeyEvent("F12",         KeyEvent.VK_F12);
	mapKeyEvent("F13",         KeyEvent.VK_F13);
	mapKeyEvent("F14",         KeyEvent.VK_F14);
	mapKeyEvent("F15",         KeyEvent.VK_F15);
	mapKeyEvent("F16",         KeyEvent.VK_F16);
	mapKeyEvent("F17",         KeyEvent.VK_F17);
	mapKeyEvent("F18",         KeyEvent.VK_F18);
	mapKeyEvent("F19",         KeyEvent.VK_F19);
	mapKeyEvent("F20",         KeyEvent.VK_F20);
	mapKeyEvent("F21",         KeyEvent.VK_F21);
	mapKeyEvent("F22",         KeyEvent.VK_F22);
	mapKeyEvent("F23",         KeyEvent.VK_F23);
	mapKeyEvent("F24",         KeyEvent.VK_F24);
	mapKeyEvent("HOME",        KeyEvent.VK_HOME);
	mapKeyEvent("INSERT",      KeyEvent.VK_INSERT);
	mapKeyEvent("LEFT",        KeyEvent.VK_LEFT);
	mapKeyEvent("MULTIPLY",    KeyEvent.VK_MULTIPLY);
	mapKeyEvent("NUM_LOCK",    KeyEvent.VK_NUM_LOCK);
	mapKeyEvent("NUMPAD0",     KeyEvent.VK_NUMPAD0);
	mapKeyEvent("NUMPAD1",     KeyEvent.VK_NUMPAD1);
	mapKeyEvent("NUMPAD2",     KeyEvent.VK_NUMPAD2);
	mapKeyEvent("NUMPAD3",     KeyEvent.VK_NUMPAD3);
	mapKeyEvent("NUMPAD4",     KeyEvent.VK_NUMPAD4);
	mapKeyEvent("NUMPAD5",     KeyEvent.VK_NUMPAD5);
	mapKeyEvent("NUMPAD6",     KeyEvent.VK_NUMPAD6);
	mapKeyEvent("NUMPAD7",     KeyEvent.VK_NUMPAD7);
	mapKeyEvent("NUMPAD8",     KeyEvent.VK_NUMPAD8);
	mapKeyEvent("NUMPAD9",     KeyEvent.VK_NUMPAD9);
	mapKeyEvent("PAGE_DOWN",   KeyEvent.VK_PAGE_DOWN);
	mapKeyEvent("PAGE_UP",     KeyEvent.VK_PAGE_UP);
	mapKeyEvent("PLUS",        KeyEvent.VK_PLUS);
	mapKeyEvent("PRINTSCREEN", KeyEvent.VK_PRINTSCREEN);
	mapKeyEvent("RIGHT",       KeyEvent.VK_RIGHT);
	mapKeyEvent("SEPARATOR",   KeyEvent.VK_SEPARATOR);
	mapKeyEvent("SHIFT",       KeyEvent.VK_SHIFT);
	mapKeyEvent("SPACE",       KeyEvent.VK_SPACE);
	mapKeyEvent("SUBTRACT",    KeyEvent.VK_SUBTRACT);
	mapKeyEvent("UP",          KeyEvent.VK_UP);
}
 
Example #22
Source File: GPUTextNewtDemo.java    From jogl-samples with MIT License 4 votes vote down vote up
public static void main(final String[] args) {
    int width = 800, height = 400;
    int x = 10, y = 10;
    if( 0 != args.length ) {
        SceneMSAASamples = 0;
        GraphMSAASamples = 0;
        GraphVBAASamples = 0;

        for(int i=0; i<args.length; i++) {
            if(args[i].equals("-smsaa")) {
                i++;
                SceneMSAASamples = MiscUtils.atoi(args[i], SceneMSAASamples);
            } else  if(args[i].equals("-gmsaa")) {
                i++;
                GraphMSAASamples = MiscUtils.atoi(args[i], GraphMSAASamples);
                GraphVBAASamples = 0;
            } else if(args[i].equals("-gvbaa")) {
                i++;
                GraphMSAASamples = 0;
                GraphVBAASamples = MiscUtils.atoi(args[i], GraphVBAASamples);
            } else if(args[i].equals("-width")) {
                i++;
                width = MiscUtils.atoi(args[i], width);
            } else if(args[i].equals("-height")) {
                i++;
                height = MiscUtils.atoi(args[i], height);
            } else if(args[i].equals("-x")) {
                i++;
                x = MiscUtils.atoi(args[i], x);
            } else if(args[i].equals("-y")) {
                i++;
                y = MiscUtils.atoi(args[i], y);
            }
        }
    }
    System.err.println("Desired win size "+width+"x"+height);
    System.err.println("Desired win pos  "+x+"/"+y);
    System.err.println("Scene MSAA Samples "+SceneMSAASamples);
    System.err.println("Graph MSAA Samples "+GraphMSAASamples);
    System.err.println("Graph VBAA Samples "+GraphVBAASamples);

    final GLProfile glp = GLProfile.getGL2ES2();

    final GLCapabilities caps = new GLCapabilities(glp);
    caps.setAlphaBits(4);
    if( SceneMSAASamples > 0 ) {
        caps.setSampleBuffers(true);
        caps.setNumSamples(SceneMSAASamples);
    }
    System.out.println("Requested: " + caps);

    int rmode = 0; // Region.VARIABLE_CURVE_WEIGHT_BIT;
    int sampleCount = 0;
    if( GraphVBAASamples > 0 ) {
        rmode |= Region.VBAA_RENDERING_BIT;
        sampleCount += GraphVBAASamples;
    } else if( GraphMSAASamples > 0 ) {
        rmode |= Region.MSAA_RENDERING_BIT;
        sampleCount += GraphMSAASamples;
    }

    final GLWindow window = GLWindow.create(caps);
    window.setPosition(x, y);
    window.setSize(width, height);
    window.setTitle("GPU Text Newt Demo - graph[vbaa"+GraphVBAASamples+" msaa"+GraphMSAASamples+"], msaa "+SceneMSAASamples);

    final RenderState rs = RenderState.createRenderState(SVertex.factory());
    final GPUTextGLListener0A textGLListener = new GPUTextGLListener0A(rs, rmode, sampleCount, true, DEBUG, TRACE);
    // ((TextRenderer)textGLListener.getRenderer()).setCacheLimit(32);
    window.addGLEventListener(textGLListener);
    window.setVisible(true);
    // FPSAnimator animator = new FPSAnimator(60);
    final Animator animator = new Animator();
    animator.setUpdateFPSFrames(60, System.err);
    animator.add(window);

    window.addKeyListener(new KeyAdapter() {
        public void keyPressed(final KeyEvent arg0) {
            if(arg0.getKeyCode() == KeyEvent.VK_F4) {
                window.destroy();
            }
        }
    });
    window.addWindowListener(new WindowAdapter() {
        public void windowDestroyed(final WindowEvent e) {
            animator.stop();
        }
    });

    animator.start();
}
 
Example #23
Source File: DisplayEntity.java    From jaamsim with Apache License 2.0 4 votes vote down vote up
/**
 * Performs the specified keyboard event.
 * @param keyCode - newt key code
 * @param keyChar - alphanumeric character for the key (if applicable)
 * @param shift - true if the Shift key is held down
 * @param control - true if the Control key is held down
 * @param alt - true if the Alt key is held down
 * @return true if the key event was consumed by this entity
 */
public boolean handleKeyPressed(int keyCode, char keyChar, boolean shift, boolean control, boolean alt) {
	if (!isMovable())
		return false;
	double inc = getSimulation().getIncrementSize();
	if (getSimulation().isSnapToGrid())
		inc = Math.max(inc, getSimulation().getSnapGridSpacing());

	Vec3d offset = new Vec3d();
	switch (keyCode) {

		case KeyEvent.VK_LEFT:
			offset.x -= inc;
			break;

		case KeyEvent.VK_RIGHT:
			offset.x += inc;
			break;

		case KeyEvent.VK_UP:
			if (shift)
				offset.z += inc;
			else
				offset.y += inc;
			break;

		case KeyEvent.VK_DOWN:
			if (shift)
				offset.z -= inc;
			else
				offset.y -= inc;
			break;

		default:
			return false;
	}

	// Normal object
	Vec3d pos = getPosition();
	pos.add3(offset);
	if (getSimulation().isSnapToGrid())
		pos = getSimulation().getSnapGridPosition(pos, pos, shift);
	String posKey = positionInput.getKeyword();
	KeywordIndex posKw = InputAgent.formatVec3dInput(posKey, pos, DistanceUnit.class);

	if (!usePointsInput()) {
		InputAgent.storeAndExecute(new KeywordCommand(this, posKw));
		return true;
	}

	// Polyline object
	if (getSimulation().isSnapToGrid()) {
		Vec3d pts0 = new Vec3d(getPoints().get(0));
		pts0.add3(offset);
		pts0 = getSimulation().getSnapGridPosition(pts0, pts0, shift);
		offset = new Vec3d(pts0);
		offset.sub3(getPoints().get(0));
	}
	String ptsKey = pointsInput.getKeyword();
	KeywordIndex ptsKw = InputAgent.formatPointsInputs(ptsKey, getPoints(), offset);

	InputAgent.storeAndExecute(new KeywordCommand(this, posKw, ptsKw));
	return true;
}
 
Example #24
Source File: WindowInteractionListener.java    From jaamsim with Apache License 2.0 4 votes vote down vote up
@Override
public void keyPressed(KeyEvent event);
 
Example #25
Source File: WindowInteractionListener.java    From jaamsim with Apache License 2.0 4 votes vote down vote up
@Override
public void keyReleased(KeyEvent event);
 
Example #26
Source File: CameraControl.java    From jaamsim with Apache License 2.0 4 votes vote down vote up
@Override
public void keyPressed(KeyEvent e) {

	// If an entity has been selected, pass the key event to it
	boolean bool = RenderManager.inst().handleKeyPressed(e.getKeyCode(), e.getKeyChar(),
			e.isShiftDown(), e.isControlDown(), e.isAltDown());
	if (bool)
		return;

	// If no entity has been selected, the camera will handle the key event
	Vec3d pos = _updateView.getGlobalPosition();
	Vec3d cent = _updateView.getGlobalCenter();

	// Construct a unit vector in the x-y plane in the direction of the view center
	Vec3d forward = new Vec3d(cent);
	forward.sub3(pos);
	forward.z = 0.0d;
	forward.normalize3();

	// Trap the degenerate case where the camera look straight down on the x-y plane
	// For this case the normalize3 method returns a unit vector in the z-direction
	if (forward.z > 0.0)
		forward.set3(0.0d, 1.0d, 0.0d);

	// Construct a unit vector pointing to the left of the direction vector
	Vec3d left = new Vec3d( -forward.y, forward.x, 0.0d);

	// Scale the two vectors to the desired step size
	double inc = GUIFrame.getJaamSimModel().getSimulation().getIncrementSize();
	forward.scale3(inc);
	left.scale3(inc);

	int keyCode = e.getKeyCode();

	if (keyCode == KeyEvent.VK_LEFT || keyCode == KeyEvent.VK_A) {
		pos.add3(left);
		cent.add3(left);
	}

	else if (keyCode == KeyEvent.VK_RIGHT || keyCode == KeyEvent.VK_D) {
		pos.sub3(left);
		cent.sub3(left);
	}

	else if (keyCode == KeyEvent.VK_UP || keyCode == KeyEvent.VK_W) {
		if (e.isShiftDown()) {
			pos.set3(pos.x, pos.y, pos.z+inc);
			cent.set3(cent.x, cent.y, cent.z+inc);
		}
		else {
			pos.add3(forward);
			cent.add3(forward);
		}
	}

	else if (keyCode == KeyEvent.VK_DOWN || keyCode == KeyEvent.VK_S) {
		if (e.isShiftDown()) {
			pos.set3(pos.x, pos.y, pos.z-inc);
			cent.set3(cent.x, cent.y, cent.z-inc);
		}
		else {
			pos.sub3(forward);
			cent.sub3(forward);
		}
	}

	else
		return;

	_updateView.updateCenterAndPos(cent, pos);
}
 
Example #27
Source File: CubeSample2.java    From MeteoInfo with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void keyPressed(KeyEvent e) {}
 
Example #28
Source File: GPURendererListenerBase01.java    From jogl-samples with MIT License 4 votes vote down vote up
@Override
public void keyReleased(final KeyEvent arg0) {}
 
Example #29
Source File: GPURegionNewtDemo.java    From jogl-samples with MIT License 4 votes vote down vote up
public static void main(final String[] args) {
    int width = 800, height = 400;
    int x = 10, y = 10;
    if( 0 != args.length ) {
        SceneMSAASamples = 0;
        GraphMSAASamples = 0;
        GraphVBAASamples = 0;
        GraphUseWeight = false;

        for(int i=0; i<args.length; i++) {
            if(args[i].equals("-smsaa")) {
                i++;
                SceneMSAASamples = MiscUtils.atoi(args[i], SceneMSAASamples);
            } else if(args[i].equals("-gmsaa")) {
                i++;
                GraphMSAASamples = MiscUtils.atoi(args[i], GraphMSAASamples);
                GraphVBAASamples = 0;
            } else if(args[i].equals("-gvbaa")) {
                i++;
                GraphMSAASamples = 0;
                GraphVBAASamples = MiscUtils.atoi(args[i], GraphVBAASamples);
            } else if(args[i].equals("-gweight")) {
                GraphUseWeight = true;
            } else if(args[i].equals("-width")) {
                i++;
                width = MiscUtils.atoi(args[i], width);
            } else if(args[i].equals("-height")) {
                i++;
                height = MiscUtils.atoi(args[i], height);
            } else if(args[i].equals("-x")) {
                i++;
                x = MiscUtils.atoi(args[i], x);
            } else if(args[i].equals("-y")) {
                i++;
                y = MiscUtils.atoi(args[i], y);
            }
        }
    }
    System.err.println("Desired win size "+width+"x"+height);
    System.err.println("Desired win pos  "+x+"/"+y);
    System.err.println("Scene MSAA Samples "+SceneMSAASamples);
    System.err.println("Graph MSAA Samples"+GraphMSAASamples);
    System.err.println("Graph VBAA Samples "+GraphVBAASamples);
    System.err.println("Graph Weight Mode "+GraphUseWeight);

    final GLProfile glp = GLProfile.getGL2ES2();
    final GLCapabilities caps = new GLCapabilities(glp);
    caps.setAlphaBits(4);
    if( SceneMSAASamples > 0 ) {
        caps.setSampleBuffers(true);
        caps.setNumSamples(SceneMSAASamples);
    }
    System.out.println("Requested: " + caps);

    int rmode = GraphUseWeight ? Region.VARWEIGHT_RENDERING_BIT : 0;
    int sampleCount = 0;
    if( GraphVBAASamples > 0 ) {
        rmode |= Region.VBAA_RENDERING_BIT;
        sampleCount += GraphVBAASamples;
    } else if( GraphMSAASamples > 0 ) {
        rmode |= Region.MSAA_RENDERING_BIT;
        sampleCount += GraphMSAASamples;
    }

    final GLWindow window = GLWindow.create(caps);
    window.setPosition(x, y);
    window.setSize(width, height);
    window.setTitle("GPU Curve Region Newt Demo - graph[vbaa"+GraphVBAASamples+" msaa"+GraphMSAASamples+"], msaa "+SceneMSAASamples);

    final RenderState rs = RenderState.createRenderState(SVertex.factory());
    final GPURegionGLListener01 regionGLListener = new GPURegionGLListener01 (rs, rmode, sampleCount, DEBUG, TRACE);
    regionGLListener.attachInputListenerTo(window);
    window.addGLEventListener(regionGLListener);
    window.setVisible(true);

    //FPSAnimator animator = new FPSAnimator(60);
    final Animator animator = new Animator();
    animator.setUpdateFPSFrames(60, System.err);
    animator.add(window);

    window.addKeyListener(new KeyAdapter() {
        public void keyPressed(final KeyEvent arg0) {
            if(arg0.getKeyCode() == KeyEvent.VK_F4) {
                window.destroy();
            }
        }
    });
    window.addWindowListener(new WindowAdapter() {
        public void windowDestroyed(final WindowEvent e) {
            animator.stop();
        }
    });

    animator.start();
}
 
Example #30
Source File: Test.java    From jogl-samples with MIT License 4 votes vote down vote up
@Override
public void keyPressed(KeyEvent e) {
}