Exemplo n.º 1
0
  @Override
  public void simpleInitApp() {
    JmeCanvasContext ctx = (JmeCanvasContext) getContext();
    gui = new GUI(this, ctx.getCanvas());
    gui.show();

    flyCam.setEnabled(false);
    Box b = new Box(1, 1, 1);
    Geometry geom = new Geometry("Box", b);

    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat.setColor("Color", ColorRGBA.Blue);
    geom.setMaterial(mat);

    rootNode.attachChild(geom);

    cinematic = new Cinematic(rootNode, 5);
    MotionPath path = new MotionPath();
    path.addWayPoint(Vector3f.ZERO.clone());
    path.addWayPoint(new Vector3f(10, 0, 0));
    MotionEvent motionEvent = new MotionEvent(geom, path, 5);
    cinematic.addCinematicEvent(0, motionEvent);
    cinematic.fitDuration();
    cinematic.setLoopMode(LoopMode.Loop);
    stateManager.attach(cinematic);
  }
  public static void createCanvas(String appClass) {
    AppSettings settings = new AppSettings(true);
    settings.setWidth(640);
    settings.setHeight(480);

    try {
      Class<? extends Application> clazz = (Class<? extends Application>) Class.forName(appClass);
      app = clazz.newInstance();
    } catch (ClassNotFoundException ex) {
      ex.printStackTrace();
    } catch (InstantiationException ex) {
      ex.printStackTrace();
    } catch (IllegalAccessException ex) {
      ex.printStackTrace();
    }

    app.setPauseOnLostFocus(false);
    app.setSettings(settings);
    app.createCanvas();
    app.startCanvas();

    context = (JmeCanvasContext) app.getContext();
    canvas = context.getCanvas();
    canvas.setSize(settings.getWidth(), settings.getHeight());
  }
Exemplo n.º 3
0
 public static void main(String[] args) {
   EventQueue.invokeLater(
       () -> {
         Main app = new Main();
         app.setSettings(createAppSettings());
         app.setPauseOnLostFocus(false);
         try {
           UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
         } catch (Exception e) {
         }
         app.createCanvas();
         JmeCanvasContext ctx = (JmeCanvasContext) app.getContext();
         ctx.setSystemListener(app);
         Dimension dim = new Dimension(1280, 720);
         ctx.getCanvas().setPreferredSize(dim);
         app.startCanvas();
       });
 }