diff --git a/src/sg/SpaceGame.java b/src/sg/SpaceGame.java index 77901b4..26b1b6d 100644 --- a/src/sg/SpaceGame.java +++ b/src/sg/SpaceGame.java @@ -4,11 +4,15 @@ import java.util.logging.Level; import java.util.logging.Logger; import sg.env.Environment; +import sg.util.SGUtil; import com.jme.bounding.BoundingBox; +import com.jme.scene.Node; import com.jme.scene.shape.Sphere; import com.jme.scene.state.TextureState; +import com.jme.system.DisplaySystem; import com.jme.image.Texture; +import com.jme.input.ChaseCamera; import com.jme.input.InputHandler; import com.jme.input.KeyInput; import com.jme.input.action.InputAction; @@ -28,7 +32,7 @@ public class SpaceGame extends SimplePhysicsGame { private InputHandler physicsStepInputHandler; public static void main(String[] args) { - Logger.getLogger("").setLevel( Level.WARNING ); + //Logger.getLogger("").setLevel( Level.WARNING ); SpaceGame game = new SpaceGame(); game.setConfigShowMode(ConfigShowMode.AlwaysShow); game.start(); @@ -61,12 +65,13 @@ public class SpaceGame extends SimplePhysicsGame { } } ); - physicsStepInputHandler.addAction( new MyInputAction( new Vector3f( 700, 0, 0 ) ), + physicsStepInputHandler.addAction( new MyInputAction( new Vector3f( 0, 700, 0 ) ), InputHandler.DEVICE_KEYBOARD, KeyInput.KEY_HOME, InputHandler.AXIS_NONE, true ); - physicsStepInputHandler.addAction( new MyInputAction( new Vector3f( -700, 0, 0 ) ), + physicsStepInputHandler.addAction( new MyInputAction( new Vector3f( 0, -700, 0 ) ), InputHandler.DEVICE_KEYBOARD, KeyInput.KEY_END, InputHandler.AXIS_NONE, true ); //sphere + /* Sphere s = new Sphere("Sphere", 10, 10, 25); s.setLocalTranslation(new Vector3f(0,0,-40)); s.setModelBound(new BoundingBox()); @@ -81,6 +86,15 @@ public class SpaceGame extends SimplePhysicsGame { ts.setTexture(texture); s.setRenderState(ts); dynamicNode.attachChild(s); + */ + + Node ship = SGUtil.loadModel("sg/data/models/ships/G6.3ds"); + ship.setLocalTranslation(new Vector3f(0,0,-40)); + //ship.setLocalScale(0.01f); + dynamicNode.attachChild(ship); + + //ChaseCamera ccam = new ChaseCamera( cam, ship); + //input = ccam; } public void simpleUpdate(){ diff --git a/src/sg/data/models/ships/G6.3DS b/src/sg/data/models/ships/G6.3DS new file mode 100644 index 0000000..6e6bcc7 Binary files /dev/null and b/src/sg/data/models/ships/G6.3DS differ diff --git a/src/sg/util/SGUtil.java b/src/sg/util/SGUtil.java index c0488f9..c9bddf4 100644 --- a/src/sg/util/SGUtil.java +++ b/src/sg/util/SGUtil.java @@ -29,19 +29,7 @@ import com.jmex.model.converters.ObjToJme; * @author Erick B Passos * */ -public class SGUtil { - // So JME can find the model textures easily. - private static URL textureSearchPath; - - static { - textureSearchPath = SGUtil.class.getClassLoader().getResource("sg/data/"); - try { - ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_TEXTURE, new SimpleResourceLocator(textureSearchPath)); - } catch (URISyntaxException e) { - e.printStackTrace(); - } - } - +public class SGUtil { /** * Loads a model from file, creating a bounding box for it. @@ -54,6 +42,16 @@ public class SGUtil { Node node = new Node(); BufferedInputStream in = new BufferedInputStream(FileFinder.findURL(path).openStream()); String ext = FileFinder.fileExtension(path); + + // So JME can find the model textures easily. + try { + ResourceLocatorTool.addResourceLocator( + ResourceLocatorTool.TYPE_TEXTURE, + new SimpleResourceLocator( + SGUtil.class.getClassLoader().getResource(path))); + } catch (URISyntaxException e) { + e.printStackTrace(); + } if(ext.equalsIgnoreCase("jme")){ node.attachChild((Spatial)BinaryImporter.getInstance().load(in));