Ok i have a strange problem. I tried to load some models into a chase view (merged some tutorials).
When i did that with the "obj" file in jmetest it worked fine.
So i tried to load an MD3 model (supplied as well with jme).
Here is the code
private void buildPlayer() {
Md3ToJme converter=new Md3ToJme();
URL laura=TestMd3JmeWrite.class.getClassLoader().getResource("jmetest/data/model/lara/lara_lower.md3");
URL model=TestMd3JmeWrite.class.getClassLoader().getResource("jmetest/data/model/lara/default.bmp");
ByteArrayOutputStream BO=new ByteArrayOutputStream();
try {
converter.convert(laura.openStream(),BO);
JmeBinaryReader jbr=new JmeBinaryReader();
player=jbr.loadBinaryFormat(new ByteArrayInputStream(BO.toByteArray()));
TextureState ts=display.getRenderer().createTextureState();
ts.setTexture(TextureManager.loadTexture(model,Texture.MM_LINEAR,Texture.FM_LINEAR));
ts.setEnabled(true);
player.setRenderState(ts);
player.setLocalTranslation(new Vector3f(100,0, 100));
player.setWorldBound(new BoundingBox());
player.updateWorldBound();
rootNode.attachChild(player);
} catch (IOException e) { // Just in case anything happens
System.out.println("Damn exceptions!" + e);
e.printStackTrace();
System.exit(0);
}
}
As you can see i set the WorldBound to be a BoundingBox (just as i did with the obj file).
After this method buildChaseCam is invoked which looks like this:
private void buildChaseCamera() {
Vector3f targetOffset = new Vector3f();
targetOffset.y = ((BoundingBox) player.getWorldBound()).yExtent * 10.5f;
HashMap props = new HashMap();
props.put(ThirdPersonMouseLook.PROP_MAXROLLOUT, "30");
props.put(ThirdPersonMouseLook.PROP_MINROLLOUT, "0");
props.put(ChaseCamera.PROP_TARGETOFFSET, targetOffset);
chaser = new ChaseCamera(cam, player, props);
chaser.setActionSpeed(100f);
}
That WORKS !
So at that point i MUST have a bounding box !
But then when it goes to stateUpdate i get a class cast exception saying: "java.lang.ClassCastException: com.jme.bounding.BoundingSphere"
The code where that happens is below (line in bold)
float characterMinHeight = tb.getHeight(player
.getLocalTranslation())+((BoundingBox)player.getWorldBound()).yExtent;
if (!Float.isInfinite(characterMinHeight) && !Float.isNaN(characterMinHeight)) {
player.getLocalTranslation().y = characterMinHeight;
}
This happens when stateUpdate is called by the GameStateManager.
I dont see how this can happen since BEFORE that exception the log says:
INFO: Child (MD3 File) attached to this node (XML loaded scene)
21.10.2005 11:11:51 com.jme.scene.Node attachChild
INFO: Child (XML loaded scene) attached to this node (Scene graph node)
So there seems to be no way the player wasnt already loaded and the bounding box set ?
Any ideas ?