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");
}
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();
}
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;
}
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();
}
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);
}
Aggregations