Search in sources :

Example 21 with Application

use of com.jme3.app.Application in project jmonkeyengine by jMonkeyEngine.

the class PhysicsTestHelper method createBallShooter.

/**
     * creates the necessary inputlistener and action to shoot balls from teh camera
     * @param app
     * @param rootNode
     * @param space
     */
public static void createBallShooter(final Application app, final Node rootNode, final PhysicsSpace space) {
    ActionListener actionListener = new ActionListener() {

        public void onAction(String name, boolean keyPressed, float tpf) {
            Sphere bullet = new Sphere(32, 32, 0.4f, true, false);
            bullet.setTextureMode(TextureMode.Projected);
            Material mat2 = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
            TextureKey key2 = new TextureKey("Textures/Terrain/Rock/Rock.PNG");
            key2.setGenerateMips(true);
            Texture tex2 = app.getAssetManager().loadTexture(key2);
            mat2.setTexture("ColorMap", tex2);
            if (name.equals("shoot") && !keyPressed) {
                Geometry bulletg = new Geometry("bullet", bullet);
                bulletg.setMaterial(mat2);
                bulletg.setShadowMode(ShadowMode.CastAndReceive);
                bulletg.setLocalTranslation(app.getCamera().getLocation());
                RigidBodyControl bulletControl = new RigidBodyControl(10);
                bulletg.addControl(bulletControl);
                bulletControl.setLinearVelocity(app.getCamera().getDirection().mult(25));
                bulletg.addControl(bulletControl);
                rootNode.attachChild(bulletg);
                space.add(bulletControl);
            }
        }
    };
    app.getInputManager().addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
    app.getInputManager().addListener(actionListener, "shoot");
}
Also used : Sphere(com.jme3.scene.shape.Sphere) Geometry(com.jme3.scene.Geometry) TextureKey(com.jme3.asset.TextureKey) ActionListener(com.jme3.input.controls.ActionListener) Material(com.jme3.material.Material) MouseButtonTrigger(com.jme3.input.controls.MouseButtonTrigger) Texture(com.jme3.texture.Texture) RigidBodyControl(com.jme3.bullet.control.RigidBodyControl)

Example 22 with Application

use of com.jme3.app.Application in project jmonkeyengine by jMonkeyEngine.

the class TestGhostObject method main.

public static void main(String[] args) {
    Application app = new TestGhostObject();
    app.start();
}
Also used : SimpleApplication(com.jme3.app.SimpleApplication) Application(com.jme3.app.Application)

Example 23 with Application

use of com.jme3.app.Application in project TeachingInSimulation by ScOrPiOzzy.

the class TestJmeToJFXCanvas method makeJmeApplication.

@NotNull
private static JmeToJFXApplication makeJmeApplication() {
    final AppSettings settings = JmeToJFXIntegrator.prepareSettings(new AppSettings(true), 60);
    final JmeToJFXApplication application = new JmeToJFXApplication() {

        protected Geometry player;

        Boolean isRunning = true;

        @Override
        public void simpleInitApp() {
            super.simpleInitApp();
            flyCam.setDragToRotate(true);
            Box b = new Box(1, 1, 1);
            player = new Geometry("Player", b);
            Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
            mat.setColor("Color", ColorRGBA.Blue);
            player.setMaterial(mat);
            rootNode.attachChild(player);
            // 添加鼠标监听
            inputManager.addMapping("pick", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
            inputManager.addListener((ActionListener) (name, isPressed, tpf) -> {
                if (isPressed) {
                    System.out.println(inputManager.getCursorPosition());
                    System.out.println(settings.getWidth());
                    System.out.println(settings.getHeight());
                    // @Nullable
                    // Geometry picked = JmeUtil.getGeometryFromCursor(root, cam, inputManager);
                    // if (picked != null) {
                    // System.err.println(picked);
                    // }
                    @Nullable Vector3f point = JmeUtil.getContactPointFromCursor(rootNode, cam, inputManager);
                    if (point != null) {
                        Geometry ball = JmeUtil.getSphere(assetManager, 32, 0.1f, ColorRGBA.Red);
                        rootNode.attachChild(ball);
                        ball.setLocalTranslation(point);
                    }
                }
            }, "pick");
        // initKeys(); // load my custom keybinding
        }
    };
    application.setSettings(settings);
    application.setShowSettings(false);
    return application;
}
Also used : Geometry(com.jme3.scene.Geometry) Button(javafx.scene.control.Button) Scene(javafx.scene.Scene) JmeToJFXApplication(com.jme3x.jfx.injfx.JmeToJFXApplication) AppSettings(com.jme3.system.AppSettings) JmeUtil(com.cas.sim.tis.util.JmeUtil) Vector3f(com.jme3.math.Vector3f) ActionListener(com.jme3.input.controls.ActionListener) Canvas(javafx.scene.canvas.Canvas) MouseButtonTrigger(com.jme3.input.controls.MouseButtonTrigger) StackPane(javafx.scene.layout.StackPane) MouseInput(com.jme3.input.MouseInput) Application(javafx.application.Application) Nullable(org.jetbrains.annotations.Nullable) JFXMouseInput(com.jme3x.jfx.injfx.input.JFXMouseInput) Stage(javafx.stage.Stage) Material(com.jme3.material.Material) JmeToJFXIntegrator(com.jme3x.jfx.injfx.JmeToJFXIntegrator) ColorRGBA(com.jme3.math.ColorRGBA) NotNull(org.jetbrains.annotations.NotNull) Geometry(com.jme3.scene.Geometry) Box(com.jme3.scene.shape.Box) JmeToJFXApplication(com.jme3x.jfx.injfx.JmeToJFXApplication) AppSettings(com.jme3.system.AppSettings) Vector3f(com.jme3.math.Vector3f) Box(com.jme3.scene.shape.Box) Material(com.jme3.material.Material) MouseButtonTrigger(com.jme3.input.controls.MouseButtonTrigger) NotNull(org.jetbrains.annotations.NotNull)

Example 24 with Application

use of com.jme3.app.Application in project openmrs-core by openmrs.

the class HL7ServiceTest method processHL7Message_shouldParseMessageTypeSuppliedByModule.

/**
 * @see HL7Service#processHL7Message(Message)
 */
@Test
@Ignore("TRUNK-3945")
public void processHL7Message_shouldParseMessageTypeSuppliedByModule() throws Exception {
    Properties props = super.getRuntimeProperties();
    props.setProperty(ModuleConstants.RUNTIMEPROPERTY_MODULE_LIST_TO_LOAD, "org/openmrs/hl7/include/examplehl7handlers-0.1.omod");
    // the above module provides a handler for messages of type "ADR" with trigger "A19"
    ModuleUtil.startup(props);
    // the application context cannot restart here to load in the moduleApplicationContext that
    // calls the setHL7Handlers method so we're doing it manually here
    Class<Application> c = (Class<Application>) Context.loadClass("org.openmrs.module.examplehl7handlers.ADRHandler");
    Application classInstance = c.newInstance();
    HashMap<String, Application> map = new HashMap<>();
    map.put("ADR_A19", classInstance);
    HL7ServiceImpl.getInstance().setHL7Handlers(map);
    HL7Service hl7service = Context.getHL7Service();
    Message message = hl7service.parseHL7String("MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20080226102656||ADR^A19|JqnfhKKtouEz8kzTk6Zo|P|2.5|1||||||||16^AMRS.ELD.FORMID\r" + "PID|||3^^^^||John3^Doe^||\r" + "PV1||O|1^Unknown Location||||1^Super User (1-8)|||||||||||||||||||||||||||||||||||||20080212|||||||V\r" + "ORC|RE||||||||20080226102537|1^Super User\r" + "OBR|1|||1238^MEDICAL RECORD OBSERVATIONS^99DCT\r" + "OBX|1|NM|5497^CD4, BY FACS^99DCT||450|||||||||20080206\r" + "OBX|2|DT|5096^RETURN VISIT DATE^99DCT||20080229|||||||||20080212");
    Assert.assertNotNull(message);
    try {
        hl7service.processHL7Message(message);
        Assert.fail("Should not be here. The ADR_A19 parser provided by the module throws an ApplicationException.");
    } catch (HL7Exception e) {
        if (e.getCause() != null)
            Assert.assertEquals("In ADR A19 parser", e.getCause().getMessage());
        else {
            log.error("unable to parse message", e);
            Assert.fail("something bad happened, check the log statement 1 line up");
        }
    }
    ModuleUtil.shutdown();
}
Also used : Message(ca.uhn.hl7v2.model.Message) HashMap(java.util.HashMap) HL7Exception(ca.uhn.hl7v2.HL7Exception) Properties(java.util.Properties) Application(ca.uhn.hl7v2.app.Application) Ignore(org.junit.Ignore) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 25 with Application

use of com.jme3.app.Application in project jmonkeyengine by jMonkeyEngine.

the class BulletDebugAppState method setupMaterials.

private void setupMaterials(Application app) {
    AssetManager manager = app.getAssetManager();
    DEBUG_BLUE = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md");
    DEBUG_BLUE.getAdditionalRenderState().setWireframe(true);
    DEBUG_BLUE.setColor("Color", ColorRGBA.Blue);
    DEBUG_GREEN = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md");
    DEBUG_GREEN.getAdditionalRenderState().setWireframe(true);
    DEBUG_GREEN.setColor("Color", ColorRGBA.Green);
    DEBUG_RED = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md");
    DEBUG_RED.getAdditionalRenderState().setWireframe(true);
    DEBUG_RED.setColor("Color", ColorRGBA.Red);
    DEBUG_YELLOW = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md");
    DEBUG_YELLOW.getAdditionalRenderState().setWireframe(true);
    DEBUG_YELLOW.setColor("Color", ColorRGBA.Yellow);
    DEBUG_MAGENTA = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md");
    DEBUG_MAGENTA.getAdditionalRenderState().setWireframe(true);
    DEBUG_MAGENTA.setColor("Color", ColorRGBA.Magenta);
    DEBUG_PINK = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md");
    DEBUG_PINK.getAdditionalRenderState().setWireframe(true);
    DEBUG_PINK.setColor("Color", ColorRGBA.Pink);
}
Also used : AssetManager(com.jme3.asset.AssetManager) Material(com.jme3.material.Material)

Aggregations

AppSettings (com.jme3.system.AppSettings)11 Material (com.jme3.material.Material)10 Vector2f (com.jme3.math.Vector2f)8 ViewPort (com.jme3.renderer.ViewPort)8 Geometry (com.jme3.scene.Geometry)8 Camera (com.jme3.renderer.Camera)6 Spatial (com.jme3.scene.Spatial)6 Texture2D (com.jme3.texture.Texture2D)6 Node (com.jme3.scene.Node)5 FrameBuffer (com.jme3.texture.FrameBuffer)5 KeyTrigger (com.jme3.input.controls.KeyTrigger)4 InputManager (com.jme3.input.InputManager)3 OSVR (com.jme3.input.vr.OSVR)3 VRAPI (com.jme3.input.vr.VRAPI)3 Application (ca.uhn.hl7v2.app.Application)2 BitmapText (com.jme3.font.BitmapText)2 MouseInput (com.jme3.input.MouseInput)2 ActionListener (com.jme3.input.controls.ActionListener)2 MouseButtonTrigger (com.jme3.input.controls.MouseButtonTrigger)2 Vector3f (com.jme3.math.Vector3f)2