public void run() { // Fill in the combos once the window has opened so that the insets can be read. // The assumption is made that the settings window and the display window will have the // same insets as that is used to resize the "full screen windowed" mode appropriately. updateResolutionChoices(); if (source.getWidth() != 0 && source.getHeight() != 0) { displayResCombo.setSelectedItem(source.getWidth() + " x " + source.getHeight()); } else { displayResCombo.setSelectedIndex(displayResCombo.getItemCount()-1); } updateAntialiasChoices(); colorDepthCombo.setSelectedItem(source.getBitsPerPixel() + " bpp"); } });
public void reshape(int width, int height) { super.reshape(width, height); // Need to move text relative to app height txt.setLocalTranslation(0, settings.getHeight(), 0); txt.setText("Drag the corners of the application to resize it.\n" + "Current Size: " + settings.getWidth() + "x" + settings.getHeight()); }
private void onCursorPos(long window, double xpos, double ypos) { int x = (int) Math.round(xpos); int y = context.getSettings().getHeight() - (int) Math.round(ypos); if (mouseX == 0) { mouseX = x; } if (mouseY == 0) { mouseY = y; } xDelta = x - mouseX; yDelta = y - mouseY; mouseX = x; mouseY = y; if (xDelta != 0 || yDelta != 0) { final MouseMotionEvent mouseMotionEvent = new MouseMotionEvent(x, y, xDelta, yDelta, mouseWheel, 0); mouseMotionEvent.setTime(getInputTimeNanos()); mouseMotionEvents.add(mouseMotionEvent); } }
public void loadSettings(AppSettings settings) { keyboardEventsEnabled = settings.isEmulateKeyboard(); mouseEventsEnabled = settings.isEmulateMouse(); mouseEventsInvertX = settings.isEmulateMouseFlipX(); mouseEventsInvertY = settings.isEmulateMouseFlipY(); // view width and height are 0 until the view is displayed on the screen if (androidInput.getView().getWidth() != 0 && androidInput.getView().getHeight() != 0) { scaleX = (float)settings.getWidth() / (float)androidInput.getView().getWidth(); scaleY = (float)settings.getHeight() / (float)androidInput.getView().getHeight(); } logger.log(Level.FINE, "Setting input scaling, scaleX: {0}, scaleY: {1}", new Object[]{scaleX, scaleY}); }
public Camera getDummyCamera(){ if (dummyCam == null){ if (application != null){ if (application.getCamera() != null){ dummyCam = application.getCamera().clone(); } else { if ((settings != null) && (settings.getWidth() != 0) && (settings.getHeight() != 0)){ dummyCam = new Camera(settings.getWidth(), settings.getHeight()); } else { dummyCam = new Camera(); } } } else { throw new IllegalStateException("VR environment is not attached to any application."); } } return dummyCam; }
private void updateOpenCL(float tpf) { //aquire resource texCL.acquireImageForSharingNoEvent(clQueue); //no need to wait for the returned event, since the kernel implicitely waits for it (same command queue) //execute kernel Kernel.WorkSize ws = new Kernel.WorkSize(settings.getWidth(), settings.getHeight()); kernel.Run1NoEvent(clQueue, ws, texCL, C, 16); //release resource texCL.releaseImageForSharingNoEvent(clQueue); }
public void onMouseMotionEvent(MouseMotionEvent evt) { x += evt.getDX(); y += evt.getDY(); // Prevent mouse from leaving screen AppSettings settings = TestSoftwareMouse.this.settings; x = FastMath.clamp(x, 0, settings.getWidth()); y = FastMath.clamp(y, 0, settings.getHeight()); // adjust for hotspot cursor.setPosition(x, y - 64); } public void onMouseButtonEvent(MouseButtonEvent evt) {
private Vector3f getWorldIntersection() { Vector3f origin = cam.getWorldCoordinates(new Vector2f(settings.getWidth() / 2, settings.getHeight() / 2), 0.0f); Vector3f direction = cam.getWorldCoordinates(new Vector2f(settings.getWidth() / 2, settings.getHeight() / 2), 0.3f); direction.subtractLocal(origin).normalizeLocal(); Ray ray = new Ray(origin, direction); CollisionResults results = new CollisionResults(); int numCollisions = terrain.collideWith(ray, results); if (numCollisions > 0) { CollisionResult hit = results.getClosestCollision(); return hit.getContactPoint(); } return null; }
private void initCrossHair() { BitmapText bitmapText = new BitmapText(guiFont); bitmapText.setText("+"); bitmapText.setLocalTranslation((settings.getWidth() - bitmapText.getLineWidth())*0.5f, (settings.getHeight() + bitmapText.getLineHeight())*0.5f, 0); guiNode.attachChild(bitmapText); } }
public void simpleInitApp() { flyCam.setDragToRotate(true); Box b = new Box(1, 1, 1); Geometry geom = new Geometry("Box", b); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg")); geom.setMaterial(mat); rootNode.attachChild(geom); txt = new BitmapText(loadGuiFont(), false); txt.setText("Drag the corners of the application to resize it.\n" + "Current Size: " + settings.getWidth() + "x" + settings.getHeight()); txt.setLocalTranslation(0, settings.getHeight(), 0); guiNode.attachChild(txt); }
public void simpleInitApp() { Picture p = new Picture("Picture"); p.move(0, 0, -1); // make it appear behind stats view p.setPosition(0, 0); p.setWidth(settings.getWidth()); p.setHeight(settings.getHeight()); p.setImage(assetManager, "Interface/Logo/Monkey.png", false); // attach geometry to orthoNode guiNode.attachChild(p); }
@Override public void simpleUpdate(float tpf) { Vector3f origin = cam.getWorldCoordinates(new Vector2f(settings.getWidth() / 2, settings.getHeight() / 2), 0.0f); Vector3f direction = cam.getWorldCoordinates(new Vector2f(settings.getWidth() / 2, settings.getHeight() / 2), 0.3f); direction.subtractLocal(origin).normalizeLocal(); Ray ray = new Ray(origin, direction); CollisionResults results = new CollisionResults(); int numCollisions = terrain.collideWith(ray, results); if (numCollisions > 0) { CollisionResult hit = results.getClosestCollision(); fpsText.setText(""+hit.getDistance()); dofFilter.setFocusDistance(hit.getDistance()/10.0f); } } }
/** A plus sign used as crosshairs to help the player with aiming.*/ protected void initCrossHairs() { setDisplayStatView(false); //guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt"); BitmapText ch = new BitmapText(guiFont, false); ch.setSize(guiFont.getCharSet().getRenderedSize() * 2); ch.setText("+"); // fake crosshairs :) ch.setLocalTranslation( // center settings.getWidth() / 2, settings.getHeight() / 2, 0); guiNode.attachChild(ch); } }
protected void initCrossHairs() { BitmapText ch = new BitmapText(guiFont, false); ch.setSize(guiFont.getCharSet().getRenderedSize() * 2); ch.setText("+"); // crosshairs ch.setLocalTranslation( // center settings.getWidth() / 2 - guiFont.getCharSet().getRenderedSize() / 3 * 2, settings.getHeight() / 2 + ch.getLineHeight() / 2, 0); guiNode.attachChild(ch); }
protected void initCrossHairs() { //guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt"); BitmapText ch = new BitmapText(guiFont, false); ch.setSize(guiFont.getCharSet().getRenderedSize() * 2); ch.setText("+"); // crosshairs ch.setLocalTranslation( // center settings.getWidth() / 2 - guiFont.getCharSet().getRenderedSize() / 3 * 2, settings.getHeight() / 2 + ch.getLineHeight() / 2, 0); guiNode.attachChild(ch); }
/** A centred plus sign to help the player aim. */ protected void initCrossHairs() { setDisplayStatView(false); guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt"); BitmapText ch = new BitmapText(guiFont, false); ch.setSize(guiFont.getCharSet().getRenderedSize() * 2); ch.setText("+"); // crosshairs ch.setLocalTranslation( // center settings.getWidth() / 2 - ch.getLineWidth()/2, settings.getHeight() / 2 + ch.getLineHeight()/2, 0); guiNode.attachChild(ch); }
protected void initCrossHairs() { guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt"); BitmapText ch = new BitmapText(guiFont, false); ch.setSize(guiFont.getCharSet().getRenderedSize() * 2); ch.setText("+"); // crosshairs ch.setLocalTranslation( // center settings.getWidth() / 2 - guiFont.getCharSet().getRenderedSize() / 3 * 2, settings.getHeight() / 2 + ch.getLineHeight() / 2, 0); guiNode.attachChild(ch); } }
protected void initCrossHairs() { guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt"); BitmapText ch = new BitmapText(guiFont, false); ch.setSize(guiFont.getCharSet().getRenderedSize() * 2); ch.setText("+"); // crosshairs ch.setLocalTranslation( // center settings.getWidth() / 2 - guiFont.getCharSet().getRenderedSize() / 3 * 2, settings.getHeight() / 2 + ch.getLineHeight() / 2, 0); guiNode.attachChild(ch); } }
protected void initCrossHairs() { guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt"); BitmapText ch = new BitmapText(guiFont, false); ch.setSize(guiFont.getCharSet().getRenderedSize() * 2); ch.setText("+"); // crosshairs ch.setLocalTranslation( // center settings.getWidth() / 2 - guiFont.getCharSet().getRenderedSize() / 3 * 2, settings.getHeight() / 2 + ch.getLineHeight() / 2, 0); guiNode.attachChild(ch); }
protected void initCrossHairs() { guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt"); BitmapText ch = new BitmapText(guiFont, false); ch.setSize(guiFont.getCharSet().getRenderedSize() * 2); ch.setText("+"); // crosshairs ch.setLocalTranslation( // center settings.getWidth() / 2 - guiFont.getCharSet().getRenderedSize() / 3 * 2, settings.getHeight() / 2 + ch.getLineHeight() / 2, 0); guiNode.attachChild(ch); } }