Where do i place the zip file in the 9th tutorial?
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:beginner:hello_collision
Place town.zip in the root directory of your JME3 project.
i did but it didn’t work
Where did u put it?
C:UsersUserName.jmonkeyplatformassetpacksIDK
IDK is the project name
what is the error?
[java]run:
22/12/2011 21:35:58 com.jme3.system.JmeSystem initialize
INFO: Running on jMonkeyEngine 3.0.0 Beta
22/12/2011 21:35:58 com.jme3.system.Natives extractNativeLibs
INFO: Extraction Directory: C:UsersAnonymous.jmonkeyplatformassetpacksIDK
22/12/2011 21:35:58 com.jme3.system.lwjgl.LwjglAbstractDisplay run
INFO: Using LWJGL 2.8.2
22/12/2011 21:35:58 com.jme3.system.lwjgl.LwjglDisplay createContext
INFO: Selected display mode: 1024 x 768 x 0 @0Hz
22/12/2011 21:35:59 com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Adapter: aticfx64
22/12/2011 21:35:59 com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Driver Version: null
22/12/2011 21:35:59 com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Vendor: ATI Technologies Inc.
22/12/2011 21:35:59 com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: OpenGL Version: 4.1.11251 Compatibility Profile Context
22/12/2011 21:35:59 com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Renderer: AMD Radeon HD 6800 Series
22/12/2011 21:35:59 com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: GLSL Ver: 4.10
22/12/2011 21:35:59 com.jme3.system.lwjgl.LwjglTimer <init>
INFO: Timer resolution: 1,000 ticks per second
22/12/2011 21:35:59 com.jme3.renderer.lwjgl.LwjglRenderer initialize
INFO: Caps: [FrameBuffer, FrameBufferMRT, FrameBufferMultisample, TextureMultisample, OpenGL20, OpenGL21, OpenGL30, OpenGL31, OpenGL32, ARBprogram, GLSL100, GLSL110, GLSL120, GLSL130, GLSL140, GLSL150, VertexTextureFetch, TextureArray, TextureBuffer, FloatTexture, FloatColorBuffer, FloatDepthBuffer, PackedFloatTexture, SharedExponentTexture, PackedFloatColorBuffer, TextureCompressionLATC, NonPowerOfTwoTextures, MeshInstancing, VertexBufferArray]
22/12/2011 21:35:59 com.jme3.asset.DesktopAssetManager <init>
INFO: DesktopAssetManager created.
22/12/2011 21:35:59 com.jme3.renderer.Camera <init>
INFO: Camera created (W: 1,024, H: 768)
22/12/2011 21:35:59 com.jme3.renderer.Camera <init>
INFO: Camera created (W: 1,024, H: 768)
22/12/2011 21:35:59 com.jme3.input.lwjgl.LwjglMouseInput initialize
INFO: Mouse created.
22/12/2011 21:35:59 com.jme3.input.lwjgl.LwjglKeyInput initialize
INFO: Keyboard created.
22/12/2011 21:35:59 com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: AudioRenderer supports 64 channels
22/12/2011 21:35:59 com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio effect extension version: 1.0
22/12/2011 21:35:59 com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio max auxilary sends: 4
22/12/2011 21:35:59 com.jme3.material.MaterialDef <init>
INFO: Loaded material definition: Unshaded
22/12/2011 21:35:59 com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
22/12/2011 21:35:59 com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Gui Node)
22/12/2011 21:35:59 com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
22/12/2011 21:35:59 com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
22/12/2011 21:35:59 com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
22/12/2011 21:35:59 com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
22/12/2011 21:35:59 com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
22/12/2011 21:35:59 com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
22/12/2011 21:35:59 com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
22/12/2011 21:35:59 com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
22/12/2011 21:35:59 com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
22/12/2011 21:35:59 com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
22/12/2011 21:35:59 com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
22/12/2011 21:35:59 com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
22/12/2011 21:35:59 com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
22/12/2011 21:35:59 com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
22/12/2011 21:35:59 com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
22/12/2011 21:35:59 com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
22/12/2011 21:35:59 com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
22/12/2011 21:35:59 com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
22/12/2011 21:35:59 com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
22/12/2011 21:35:59 com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
22/12/2011 21:35:59 com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
22/12/2011 21:35:59 com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
22/12/2011 21:35:59 com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
22/12/2011 21:35:59 com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
22/12/2011 21:35:59 com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
22/12/2011 21:35:59 com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
22/12/2011 21:35:59 com.jme3.scene.Node attachChild
INFO: Child (Statistics View) attached to this node (Gui Node)
22/12/2011 21:35:59 com.jme3.asset.DesktopAssetManager registerLoader
WARNING: Failed to find loader: town.zip
java.lang.ClassNotFoundException: town.zip
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at com.jme3.asset.DesktopAssetManager.registerLoader(DesktopAssetManager.java:135)
at mygame.Main.simpleInitApp(Main.java:49)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:231)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:129)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:205)
at java.lang.Thread.run(Thread.java:662)
22/12/2011 21:35:59 com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
com.jme3.asset.AssetNotFoundException: main.scene
at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:268)
at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:408)
at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:418)
at mygame.Main.simpleInitApp(Main.java:50)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:231)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:129)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:205)
at java.lang.Thread.run(Thread.java:662)
22/12/2011 21:35:59 com.jme3.renderer.lwjgl.LwjglRenderer cleanup
INFO: Deleting objects and invalidating state
22/12/2011 21:35:59 com.jme3.input.lwjgl.LwjglMouseInput destroy
INFO: Mouse destroyed.
22/12/2011 21:35:59 com.jme3.input.lwjgl.LwjglKeyInput destroy
INFO: Keyboard destroyed.
22/12/2011 21:35:59 com.jme3.system.lwjgl.LwjglAbstractDisplay deinitInThread
INFO: Display destroyed.
[/java]
the code:
[java]package mygame;
import com.jme3.app.SimpleApplication;
import com.jme3.asset.plugins.ZipLocator;
import com.jme3.bullet.BulletAppState;
import com.jme3.bullet.collision.shapes.CapsuleCollisionShape;
import com.jme3.bullet.collision.shapes.CollisionShape;
import com.jme3.bullet.control.CharacterControl;
import com.jme3.bullet.control.RigidBodyControl;
import com.jme3.bullet.util.CollisionShapeFactory;
import com.jme3.input.KeyInput;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.light.AmbientLight;
import com.jme3.light.DirectionalLight;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
/**
- test
-
@author normenhansen
*/
public class Main extends SimpleApplication implements ActionListener{
public static void main(String[] args) {
Main app = new Main();
app.start();
}
private Spatial sceneModel;
private BulletAppState bulletAppState;
private RigidBodyControl landscape;
private CharacterControl player;
private Vector3f walkDirection = new Vector3f();
private boolean left=false,right=false,up=false,down=false;
public void simpleInitApp() {
bulletAppState = new BulletAppState();
stateManager.attach(bulletAppState);
//bulletAppState.getPhysicsSpace().enableDebug(assetManager);
viewPort.setBackgroundColor(new ColorRGBA(0.7f,0.8f,1f,1f));
flyCam.setMoveSpeed(100);
setUpKeys();
setUpLight();
assetManager.registerLoader("town.zip", ZipLocator.class.getName());
sceneModel = assetManager.loadModel("main.scene");
sceneModel.setLocalScale(2f);
CollisionShape sceneShape = CollisionShapeFactory.createMeshShape((Node) sceneModel);
landscape = new RigidBodyControl(sceneShape,0);
sceneModel.addControl(landscape);
CapsuleCollisionShape capsuleShape = new CapsuleCollisionShape(1.5f,6f,1);
player = new CharacterControl(capsuleShape, 0.05f);
player.setJumpSpeed(20);
player.setFallSpeed(30);
player.setGravity(30);
player.setPhysicsLocation(new Vector3f(0,10,0));
rootNode.attachChild(sceneModel);
bulletAppState.getPhysicsSpace().add(landscape);
bulletAppState.getPhysicsSpace().add(player);
}
private void setUpLight(){
AmbientLight al = new AmbientLight();
al.setColor(ColorRGBA.White.mult(1.3f));
rootNode.addLight(al);
DirectionalLight dl = new DirectionalLight();
dl.setColor(ColorRGBA.White);
dl.setDirection(new Vector3f(2.8f, -2.8f, -2.8f).normalizeLocal());
rootNode.addLight(dl);
}
private void setUpKeys(){
inputManager.addMapping("Left", new KeyTrigger(KeyInput.KEY_A));
inputManager.addMapping("Right", new KeyTrigger(KeyInput.KEY_D));
inputManager.addMapping("Up", new KeyTrigger(KeyInput.KEY_W));
inputManager.addMapping("Down", new KeyTrigger(KeyInput.KEY_S));
inputManager.addMapping("Jump", new KeyTrigger(KeyInput.KEY_SPACE));
inputManager.addListener(this, "Left");
inputManager.addListener(this, "Right");
inputManager.addListener(this, "Up");
inputManager.addListener(this, "Down");
inputManager.addListener(this, "Jump");
}
public void onAction(String binding, boolean value, float tpf){
if(binding.equals("Left")){
if(value){
left = true;
} else { left = false;}
}else if(binding.equals("Right")){
if(value){
right = true;
} else { right = false;}
} else if(binding.equals("Up")){
if(value){
up = true;
} else { up = false; }
} else if(binding.equals("Down")){
if(value){
down = true;
} else { down = false; }
} else if(binding.equals("Jump")){
player.jump();
}
}
public void simpleUpdate(float tpf){
Vector3f camDir = cam.getDirection().clone().multLocal(0.6f);
Vector3f camLeft = cam.getLeft().clone().multLocal(0.4f);
walkDirection.set(0, 0, 0);
if(left){ walkDirection.addLocal(camLeft);}
if(right){walkDirection.addLocal(camLeft.negate());}
if(up){ walkDirection.addLocal(camDir);}
if(down){ walkDirection.addLocal(camDir.negate());}
player.setWalkDirection(walkDirection);
cam.setLocation(player.getPhysicsLocation());
}
}[/java]
assetManager.registerLoader
Is not the same as:
assetManager.registerLocator
lol that auto-type, thanks alot!
Yes, auto-complete can be evil sometimes.