Package com.ardor3d.framework

Examples of com.ardor3d.framework.FrameHandler


    public static void main(final String[] args) throws Exception {
        System.setProperty("ardor3d.useMultipleContexts", "true");
        JPopupMenu.setDefaultLightWeightPopupEnabled(false);

        final Timer timer = new Timer();
        final FrameHandler frameWork = new FrameHandler(timer);

        final MyExit exit = new MyExit();
        final LogicalLayer logicalLayer = new LogicalLayer();

        final ExampleScene scene1 = new ExampleScene();
        final RotatingCubeGame game1 = new RotatingCubeGame(scene1, exit, logicalLayer, Key.T);

        final ExampleScene scene2 = new ExampleScene();
        final RotatingCubeGame game2 = new RotatingCubeGame(scene2, exit, logicalLayer, Key.G);

        frameWork.addUpdater(game1);
        frameWork.addUpdater(game2);

        final JFrame frame = new JFrame("AWT Example");
        final JDesktopPane desktop = new JDesktopPane();
        frame.setContentPane(desktop);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(final WindowEvent e) {
                exit.exit();
            }
        });

        AWTImageLoader.registerLoader();

        try {
            final SimpleResourceLocator srl = new SimpleResourceLocator(ResourceLocatorTool.getClassPathResource(
                    JoglAwtDesktopExample.class, "com/ardor3d/example/media/"));
            ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_TEXTURE, srl);
        } catch (final URISyntaxException ex) {
            ex.printStackTrace();
        }

        final AWTImageLoader awtImageLoader = new AWTImageLoader();
        _cursor1 = createMouseCursor(awtImageLoader, "com/ardor3d/example/media/input/wait_cursor.png");
        _cursor2 = createMouseCursor(awtImageLoader, "com/ardor3d/example/media/input/movedata.gif");

        addCanvas(desktop, scene1, logicalLayer, frameWork, 1);
        addCanvas(desktop, scene1, logicalLayer, frameWork, 2);
        addCanvas(desktop, scene2, logicalLayer, frameWork, 3);

        frame.setPreferredSize(new Dimension(1024, 768));
        frame.pack();
        frame.setVisible(true);

        game1.init();
        game2.init();

        while (!exit.isExit()) {
            frameWork.updateFrame();
            Thread.yield();
        }

        frame.dispose();
        System.exit(0);
View Full Code Here


    public static void main(final String[] args) throws Exception {
        System.setProperty("ardor3d.useMultipleContexts", "true");

        final Timer timer = new Timer();
        final FrameHandler frameWork = new FrameHandler(timer);

        final MyExit exit = new MyExit();
        final LogicalLayer logicalLayer = new LogicalLayer();

        final ExampleScene scene1 = new ExampleScene();
        final RotatingCubeGame game1 = new RotatingCubeGame(scene1, exit, logicalLayer, Key.T);

        final ExampleScene scene2 = new ExampleScene();
        final RotatingCubeGame game2 = new RotatingCubeGame(scene2, exit, logicalLayer, Key.G);

        frameWork.addUpdater(game1);
        frameWork.addUpdater(game2);

        final JFrame frame = new JFrame("AWT Example");
        frame.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(final WindowEvent e) {
                exit.exit();
            }
        });

        frame.setLayout(new GridLayout(2, 3));

        AWTImageLoader.registerLoader();

        try {
            final SimpleResourceLocator srl = new SimpleResourceLocator(ResourceLocatorTool.getClassPathResource(
                    JoglNewtAwtExample.class, "com/ardor3d/example/media/"));
            ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_TEXTURE, srl);
        } catch (final URISyntaxException ex) {
            ex.printStackTrace();
        }

        final AWTImageLoader awtImageLoader = new AWTImageLoader();
        _cursor1 = createMouseCursor(awtImageLoader, "com/ardor3d/example/media/input/wait_cursor.png");
        _cursor2 = createMouseCursor(awtImageLoader, "com/ardor3d/example/media/input/movedata.gif");

        addCanvas(frame, scene1, logicalLayer, frameWork);
        frame.add(new JLabel(
                "<html>"
                        + "<table>"
                        + "<tr><th align=\"left\" style=\"font-size: 16\">Action</th><th align=\"left\" style=\"font-size: 16\">Command</th></tr>"
                        + "<tr><td>WS</td><td>Move camera position forward/back</td></tr>"
                        + "<tr><td>AD</td><td>Turn camera left/right</td></tr>"
                        + "<tr><td>QE</td><td>Strafe camera left/right</td></tr>"
                        + "<tr><td>T</td><td>Toggle cube rotation for scene 1 on press</td></tr>"
                        + "<tr><td>G</td><td>Toggle cube rotation for scene 2 on press</td></tr>"
                        + "<tr><td>U</td><td>Toggle both cube rotations on release</td></tr>"
                        + "<tr><td>0 (zero)</td><td>Reset camera position</td></tr>"
                        + "<tr><td>9</td><td>Face camera towards cube without changing position</td></tr>"
                        + "<tr><td>ESC</td><td>Quit</td></tr>"
                        + "<tr><td>Mouse</td><td>Press left button to rotate camera.</td></tr>" + "</table>"
                        + "</html>", SwingConstants.CENTER));
        addCanvas(frame, scene1, logicalLayer, frameWork);
        frame.add(new JLabel("", SwingConstants.CENTER));
        addCanvas(frame, scene2, logicalLayer, frameWork);
        frame.add(new JLabel("", SwingConstants.CENTER));

        frame.pack();
        frame.setVisible(true);

        game1.init();
        game2.init();

        while (!exit.isExit()) {
            frameWork.updateFrame();
            Thread.yield();
        }

        frame.dispose();
        System.exit(0);
View Full Code Here

    public static void main(final String[] args) throws Exception {
        System.setProperty("ardor3d.useMultipleContexts", "true");

        final Timer timer = new Timer();
        final FrameHandler frameWork = new FrameHandler(timer);

        final MyExit exit = new MyExit();
        final LogicalLayer logicalLayer = new LogicalLayer();

        final ExampleScene scene1 = new ExampleScene();
        final RotatingCubeGame game1 = new RotatingCubeGame(scene1, exit, logicalLayer, Key.T);

        final ExampleScene scene2 = new ExampleScene();
        final RotatingCubeGame game2 = new RotatingCubeGame(scene2, exit, logicalLayer, Key.G);

        frameWork.addUpdater(game1);
        frameWork.addUpdater(game2);

        final JFrame frame = new JFrame("AWT Example");
        frame.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(final WindowEvent e) {
                exit.exit();
            }
        });

        frame.setLayout(new GridLayout(2, 3));

        AWTImageLoader.registerLoader();

        try {
            final SimpleResourceLocator srl = new SimpleResourceLocator(ResourceLocatorTool.getClassPathResource(
                    JoglAwtExample.class, "com/ardor3d/example/media/"));
            ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_TEXTURE, srl);
        } catch (final URISyntaxException ex) {
            ex.printStackTrace();
        }

        final AWTImageLoader awtImageLoader = new AWTImageLoader();
        _cursor1 = createMouseCursor(awtImageLoader, "com/ardor3d/example/media/input/wait_cursor.png");
        _cursor2 = createMouseCursor(awtImageLoader, "com/ardor3d/example/media/input/movedata.gif");

        addCanvas(frame, scene1, logicalLayer, frameWork);
        frame.add(new JLabel(
                "<html>"
                        + "<table>"
                        + "<tr><th align=\"left\" style=\"font-size: 16\">Action</th><th align=\"left\" style=\"font-size: 16\">Command</th></tr>"
                        + "<tr><td>WS</td><td>Move camera position forward/back</td></tr>"
                        + "<tr><td>AD</td><td>Turn camera left/right</td></tr>"
                        + "<tr><td>T</td><td>Toggle cube rotation for scene 1 on press</td></tr>"
                        + "<tr><td>G</td><td>Toggle cube rotation for scene 2 on press</td></tr>"
                        + "<tr><td>U</td><td>Toggle both cube rotations on release</td></tr>"
                        + "<tr><td>0 (zero)</td><td>Reset camera position</td></tr>"
                        + "<tr><td>9</td><td>Face camera towards cube without changing position</td></tr>"
                        + "<tr><td>ESC</td><td>Quit</td></tr>"
                        + "<tr><td>Mouse</td><td>Press left button to rotate camera.</td></tr>" + "</table>"
                        + "</html>", SwingConstants.CENTER));
        addCanvas(frame, scene1, logicalLayer, frameWork);
        frame.add(new JLabel("", SwingConstants.CENTER));
        addCanvas(frame, scene2, logicalLayer, frameWork);
        frame.add(new JLabel("", SwingConstants.CENTER));

        frame.pack();
        frame.setVisible(true);

        game1.init();
        game2.init();

        while (!exit.isExit()) {
            frameWork.updateFrame();
            Thread.yield();
        }

        frame.dispose();
        System.exit(0);
View Full Code Here

    public static void main(final String[] args) {
        System.setProperty("ardor3d.useMultipleContexts", "true");

        final Timer timer = new Timer();
        final FrameHandler frameWork = new FrameHandler(timer);
        final LogicalLayer logicalLayer = new LogicalLayer();

        final MyExit exit = new MyExit();
        final ExampleScene scene = new ExampleScene();
        final RotatingCubeGame game = new RotatingCubeGame(scene, exit, logicalLayer, Key.T);

        frameWork.addUpdater(game);

        // INIT SWT STUFF
        final Display display = new Display();
        final Shell shell = new Shell(display);
        shell.setLayout(new FillLayout());

        // This is our tab folder, it will be accepting our 3d canvases
        final TabFolder tabFolder = new TabFolder(shell, SWT.BORDER);

        // Add a menu item that will create and add a new canvas.
        final Menu bar = new Menu(shell, SWT.BAR);
        shell.setMenuBar(bar);

        final MenuItem fileItem = new MenuItem(bar, SWT.CASCADE);
        fileItem.setText("&Tasks");

        final Menu submenu = new Menu(shell, SWT.DROP_DOWN);
        fileItem.setMenu(submenu);
        final MenuItem item = new MenuItem(submenu, SWT.PUSH);
        item.addListener(SWT.Selection, new Listener() {
            public void handleEvent(final Event e) {
                Display.getDefault().asyncExec(new Runnable() {
                    public void run() {
                        addNewCanvas(tabFolder, scene, frameWork, logicalLayer);
                    }
                });
            }
        });
        item.setText("Add &3d Canvas");
        item.setAccelerator(SWT.MOD1 + '3');

        AWTImageLoader.registerLoader();

        try {
            final SimpleResourceLocator srl = new SimpleResourceLocator(ResourceLocatorTool.getClassPathResource(
                    LwjglSwtExample.class, "com/ardor3d/example/media/"));
            ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_TEXTURE, srl);
        } catch (final URISyntaxException ex) {
            ex.printStackTrace();
        }

        addNewCanvas(tabFolder, scene, frameWork, logicalLayer);

        shell.open();

        game.init();
        // frameWork.init();

        while (!shell.isDisposed() && !exit.isExit()) {
            display.readAndDispatch();
            frameWork.updateFrame();
            Thread.yield();

            // using the below way makes things really jerky. Not sure how to handle that.

            // if (display.readAndDispatch()) {
View Full Code Here

    public static void main(final String[] args) throws Exception {
        System.setProperty("ardor3d.useMultipleContexts", "true");

        final Timer timer = new Timer();
        final FrameHandler frameWork = new FrameHandler(timer);

        final MyExit exit = new MyExit();
        final LogicalLayer logicalLayer = new LogicalLayer();

        final ExampleScene scene1 = new ExampleScene();
        final RotatingCubeGame game1 = new RotatingCubeGame(scene1, exit, logicalLayer, Key.T);

        final ExampleScene scene2 = new ExampleScene();
        final RotatingCubeGame game2 = new RotatingCubeGame(scene2, exit, logicalLayer, Key.G);

        frameWork.addUpdater(game1);
        frameWork.addUpdater(game2);

        final JFrame frame = new JFrame("AWT Example");
        frame.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(final WindowEvent e) {
                exit.exit();
            }
        });

        frame.setLayout(new GridLayout(2, 3));

        AWTImageLoader.registerLoader();

        try {
            final SimpleResourceLocator srl = new SimpleResourceLocator(ResourceLocatorTool.getClassPathResource(
                    LwjglAwtExample.class, "com/ardor3d/example/media/"));
            ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_TEXTURE, srl);
        } catch (final URISyntaxException ex) {
            ex.printStackTrace();
        }

        final AWTImageLoader awtImageLoader = new AWTImageLoader();
        _cursor1 = createMouseCursor(awtImageLoader, "com/ardor3d/example/media/input/wait_cursor.png");
        _cursor2 = createMouseCursor(awtImageLoader, "com/ardor3d/example/media/input/movedata.gif");

        addCanvas(frame, scene1, logicalLayer, frameWork);
        frame.add(new JLabel(
                "<html>"
                        + "<table>"
                        + "<tr><th align=\"left\" style=\"font-size: 16\">Action</th><th align=\"left\" style=\"font-size: 16\">Command</th></tr>"
                        + "<tr><td>WS</td><td>Move camera position forward/back</td></tr>"
                        + "<tr><td>AD</td><td>Turn camera left/right</td></tr>"
                        + "<tr><td>T</td><td>Toggle cube rotation for scene 1 on press</td></tr>"
                        + "<tr><td>G</td><td>Toggle cube rotation for scene 2 on press</td></tr>"
                        + "<tr><td>U</td><td>Toggle both cube rotations on release</td></tr>"
                        + "<tr><td>0 (zero)</td><td>Reset camera position</td></tr>"
                        + "<tr><td>9</td><td>Face camera towards cube without changing position</td></tr>"
                        + "<tr><td>ESC</td><td>Quit</td></tr>"
                        + "<tr><td>Mouse</td><td>Press left button to rotate camera.</td></tr>" + "</table>"
                        + "</html>", SwingConstants.CENTER));
        addCanvas(frame, scene1, logicalLayer, frameWork);
        frame.add(new JLabel("", SwingConstants.CENTER));
        addCanvas(frame, scene2, logicalLayer, frameWork);
        frame.add(new JLabel("", SwingConstants.CENTER));

        frame.pack();
        frame.setVisible(true);

        game1.init();
        game2.init();

        while (!exit.isExit()) {
            frameWork.updateFrame();
            Thread.yield();
        }

        frame.dispose();
        System.exit(0);
View Full Code Here

    public static void main(final String[] args) {
        System.setProperty("ardor3d.useMultipleContexts", "true");

        final Timer timer = new Timer();
        final FrameHandler frameWork = new FrameHandler(timer);
        final LogicalLayer logicalLayer = new LogicalLayer();

        final MyExit exit = new MyExit();
        final ExampleScene scene = new ExampleScene();
        final RotatingCubeGame game = new RotatingCubeGame(scene, exit, logicalLayer, Key.T);

        frameWork.addUpdater(game);

        // INIT SWT STUFF
        final Display display = new Display();
        final Shell shell = new Shell(display);
        shell.setLayout(new FillLayout());

        // This is our tab folder, it will be accepting our 3d canvases
        final TabFolder tabFolder = new TabFolder(shell, SWT.BORDER);

        // Add a menu item that will create and add a new canvas.
        final Menu bar = new Menu(shell, SWT.BAR);
        shell.setMenuBar(bar);

        final MenuItem fileItem = new MenuItem(bar, SWT.CASCADE);
        fileItem.setText("&Tasks");

        final Menu submenu = new Menu(shell, SWT.DROP_DOWN);
        fileItem.setMenu(submenu);
        final MenuItem item = new MenuItem(submenu, SWT.PUSH);
        item.addListener(SWT.Selection, new Listener() {
            public void handleEvent(final Event e) {
                Display.getDefault().asyncExec(new Runnable() {
                    public void run() {
                        addNewCanvas(tabFolder, scene, frameWork, logicalLayer);
                    }
                });
            }
        });
        item.setText("Add &3d Canvas");
        item.setAccelerator(SWT.MOD1 + '3');

        AWTImageLoader.registerLoader();

        try {
            final SimpleResourceLocator srl = new SimpleResourceLocator(ResourceLocatorTool.getClassPathResource(
                    JoglSwtExample.class, "com/ardor3d/example/media/"));
            ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_TEXTURE, srl);
        } catch (final URISyntaxException ex) {
            ex.printStackTrace();
        }

        addNewCanvas(tabFolder, scene, frameWork, logicalLayer);

        shell.open();

        game.init();

        while (!shell.isDisposed() && !exit.isExit()) {
            display.readAndDispatch();
            frameWork.updateFrame();
            Thread.yield();
        }

        display.dispose();
        System.exit(0);
View Full Code Here

TOP

Related Classes of com.ardor3d.framework.FrameHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.