I used the md5reader2 to load up a MD5 model, but nothing is showing up on the JME screen.
the FPS printout show that there is TriMesh(1), Vert(513)
Would that means the model is loaded and it's just not in the viewing area? may be scale is set too small, or camera viewing angel is incorrect?
http://www.oniva.com/upload/1356/md5.jpg
http://www.oniva.com/upload/1356/3ds.jpg
http://www.oniva.com/upload/1356/3ds2.jpg
both MD5 model files:
http://www.oniva.com/upload/1356/aaa.md5mesh
http://www.oniva.com/upload/1356/aaa.md5anim
Code to run load the model
http://www.oniva.com/upload/1356/FishTest.java
import com.jme.app.SimpleGame;
import com.jme.input.Mouse;
import com.jme.math.Vector3f;
import com.jme.renderer.ColorRGBA;
import md5reader.MD5AnimReader;
import md5reader.MD5MeshReader;
import model.Model;
import model.SkeletalModelInstance;
import model.animation.Animation;
import model.animation.AnimationAnimator;
import model.animation.AnimationController;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.logging.Level;
public class FishTest extends SimpleGame {
private static final String BODYMODEL = "models/aaa.md5mesh";
private static final String BODYANIM = "models/aaa.md5anim";
private Model bodyModel;
private Animation bodyAnimation;
private AnimationController bodyAnimator;
private SkeletalModelInstance bodyInstance;
public FishTest() throws IOException {
bodyModel = loadModel(BODYMODEL);
bodyAnimation = loadAnimation(BODYANIM);
}
public static void main(String[] args) throws IOException {
final FishTest app = new FishTest();
app.setDialogBehaviour(SimpleGame.ALWAYS_SHOW_PROPS_DIALOG);
// Turn the logger off so we can see the XML later on
app.start();
}
protected void simpleInitGame() {
lightState.get(0).setAmbient(new ColorRGBA(1.5f, 1.5f, 1.5f, 1.0f));
bodyInstance = new SkeletalModelInstance(bodyModel);
bodyAnimator = bodyInstance.addAnimationController();
AnimationAnimator anim = bodyAnimator.addAnimation(bodyAnimation);
anim.setInterpolationThreshold(0f);
bodyAnimator.update(0f);
bodyInstance.updateModelBound();
bodyInstance.setLocalScale(1.00f);
cam.setLocation(bodyInstance.getLocalTranslation().add(2.0f, 0.0f, 0.0f));
cam.lookAt(bodyInstance.getLocalTranslation(), new Vector3f(0.0f, 1.0f, 0.0f));
rootNode.detachAllChildren();
rootNode.attachChild(bodyInstance);
}
private Model loadModel(String path) throws IOException {
InputStream in = getClass().getResourceAsStream("/" + path);
if (in == null) {
throw new FileNotFoundException("Cannot find " + path);
}
MD5MeshReader reader = new MD5MeshReader();
reader.setProperty(MD5MeshReader.CLASSLOADER, getClass().getClassLoader());
return reader.readModel(in);
}
private Animation loadAnimation(String path) throws IOException {
InputStream in = getClass().getResourceAsStream("/" + path);
if (in == null) {
throw new FileNotFoundException("Cannot find " + path);
}
MD5AnimReader animReader = new MD5AnimReader();
Animation animation = animReader.readAnimation(in);
return animation;
}
}
JME log as following in elcipse
Dec 21, 2007 2:27:11 PM com.jme.app.BaseGame start
INFO: Application started.
Dec 21, 2007 2:27:11 PM com.jme.system.PropertiesIO <init>
INFO: PropertiesIO created
Dec 21, 2007 2:27:11 PM com.jme.system.PropertiesIO load
INFO: Read properties
Dec 21, 2007 2:27:14 PM com.jme.input.joystick.DummyJoystickInput <init>
INFO: Joystick support is disabled
Dec 21, 2007 2:27:14 PM com.jme.system.lwjgl.LWJGLDisplaySystem <init>
INFO: LWJGL Display System created.
Dec 21, 2007 2:27:15 PM com.jme.system.PropertiesIO save
INFO: Saved properties
Dec 21, 2007 2:27:15 PM com.jme.app.BaseSimpleGame initSystem
INFO: jME version 1.0
Dec 21, 2007 2:27:15 PM com.jme.renderer.lwjgl.LWJGLRenderer <init>
INFO: LWJGLRenderer created. W: 640H: 480
Dec 21, 2007 2:27:15 PM com.jme.app.BaseSimpleGame initSystem
INFO: Running on: ialmrnt5
Driver version: 6.14.10.4396
Intel - Intel 945G - 1.4.0 - Build 4.14.10.4396
Dec 21, 2007 2:27:15 PM com.jme.renderer.AbstractCamera <init>
INFO: Camera created.
Dec 21, 2007 2:27:15 PM com.jme.util.lwjgl.LWJGLTimer <init>
INFO: Timer resolution: 1000 ticks per second
Dec 21, 2007 2:27:15 PM com.jme.scene.Node <init>
INFO: Node created.
Dec 21, 2007 2:27:15 PM com.jme.scene.Node <init>
INFO: Node created.
Dec 21, 2007 2:27:15 PM com.jme.scene.Node attachChild
INFO: Child (FPS label) attached to this node (FPS node)
Dec 21, 2007 2:27:15 PM com.jme.scene.Node <init>
INFO: Node created.
Dec 21, 2007 2:27:15 PM com.jme.scene.Node attachChild
INFO: Child (Skin) attached to this node (MD5Model)
Dec 21, 2007 2:27:15 PM com.jme.scene.Node attachChild
INFO: Child (MD5Model) attached to this node (rootNode)
Dec 21, 2007 2:27:19 PM com.jme.app.BaseSimpleGame cleanup
INFO: Cleaning up resources.
Dec 21, 2007 2:27:19 PM com.jme.app.BaseGame start