A bunch of fiddling to support running JME in an AWT canvas.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3601 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
//
|
||||
// $Id$
|
||||
|
||||
package com.threerings.jme;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
|
||||
import com.jme.bounding.BoundingBox;
|
||||
import com.jme.math.Vector3f;
|
||||
import com.jme.scene.shape.Box;
|
||||
|
||||
/**
|
||||
* Tests the JME/AWT integration bits.
|
||||
*/
|
||||
public class JmeCanvasTest extends JmeCanvasApp
|
||||
{
|
||||
public static void main (String[] args)
|
||||
{
|
||||
final JmeCanvasTest app = new JmeCanvasTest();
|
||||
JFrame frame = new JFrame("JmeCanvasTest");
|
||||
frame.getContentPane().add(app.getCanvas(), BorderLayout.CENTER);
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.setSize(800, 600);
|
||||
frame.setVisible(true);
|
||||
|
||||
JButton button = new JButton("Create box");
|
||||
frame.getContentPane().add(button, BorderLayout.SOUTH);
|
||||
button.addActionListener(new ActionListener() {
|
||||
public void actionPerformed (ActionEvent event) {
|
||||
app.addBox();
|
||||
}
|
||||
});
|
||||
app.run();
|
||||
}
|
||||
|
||||
public void addBox ()
|
||||
{
|
||||
Vector3f max = new Vector3f(5, 5, 5);
|
||||
Vector3f min = new Vector3f(-5, -5, -5);
|
||||
|
||||
Box box = new Box("Box", min, max);
|
||||
box.setModelBound(new BoundingBox());
|
||||
box.updateModelBound();
|
||||
box.setLocalTranslation(new Vector3f(0, 0, -10));
|
||||
_geom.attachChild(box);
|
||||
_geom.updateRenderState();
|
||||
}
|
||||
|
||||
protected JmeCanvasTest ()
|
||||
{
|
||||
super(800, 600);
|
||||
}
|
||||
|
||||
protected void initRoot ()
|
||||
{
|
||||
super.initRoot();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user