added a ship model
This commit is contained in:
parent
70d7496324
commit
5514b96257
3 changed files with 28 additions and 16 deletions
|
|
@ -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(){
|
||||
|
|
|
|||
BIN
src/sg/data/models/ships/G6.3DS
Normal file
BIN
src/sg/data/models/ships/G6.3DS
Normal file
Binary file not shown.
|
|
@ -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));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue