Hello,
I’ve got a model which has two animations; created in Blender and exported using Ogre3D. It is being loaded into my game and it plays the walk animation. When I shoot it (currently just a ray checking fo the hit), I load the AnimChannel of a map and play the die animation without a loop. Then the model is lyiing on the ground. Everything is working fine, but when I get too close to the model and look at it, the head suddenly disappears. It’s really odd and I double checked the model in blender but there’s no strange behaviour there… Here is a video because it’s quite difficult to describe: http://youtu.be/K6fNQZyBPm4
As you see, sometimes the whole model disappears (more obvious at the big one).
Here is the Code I use for the models and the animation:
[java]
private AnimChannel getChannel(Spatial s) {
Node n = (Node) s;
Node metarig = (Node) n.getChild(“metarig”);
Node pelvis = (Node) metarig.getChild(“Pelvis”);
Node polySurface1 = (Node) pelvis.getChild(“polySurface2.006-entity”);
Node polySurface2 = (Node) polySurface1.getChild(“polySurface2.006-ogremesh”);
AnimControl control = polySurface2.getControl(AnimControl.class);
AnimChannel channel = control.createChannel();
return channel;
}
private void initEnemies() {
enemies = new Node(“Enemies”);
Spatial e1 = assetManager.loadModel("Models/skeleton.j3o");
e1.scale(5);
BetterCharacterControl e1Control = new BetterCharacterControl(2f, 10f, 170f);
e1.addControl(e1Control);
bulletAppState.getPhysicsSpace().add(e1Control);
e1Control.warp(new Vector3f(100f, 0.2f, 0.0f));
e1Control.setGravity(new Vector3f(0f, -50f, 0f));
AnimChannel bigChannel = getChannel(e1);
bigChannel.setAnim("Walk");
bigEnemies.put(e1, bigChannel);
enemies.attachChild(e1);
Spatial t1 = assetManager.loadModel("Models/skeleton.j3o");
BetterCharacterControl t1Control = new BetterCharacterControl(1f, 2f, 30f);
t1.addControl(t1Control);
bulletAppState.getPhysicsSpace().add(t1Control);
t1Control.warp(new Vector3f(20f, 0.2f, 0.0f));
t1Control.setGravity(new Vector3f(0f, -30f, 0f));
AnimChannel channel = getChannel(t1);
channel.setAnim("Walk");
enemies.attachChild(t1);
smallEnemies.put(t1, channel);
rootNode.attachChild(enemies);
}
public void shoot(int damage) {
CollisionResults results = new CollisionResults();
Ray ray = new Ray(cam.getLocation(), cam.getDirection());
enemies.collideWith(ray, results);
if (results.size() > 0) {
CollisionResult closest = results.getClosestCollision();
Spatial result = closest.getGeometry().getParent().getParent().getParent().getParent().getParent();
for (Spatial s : enemies.getChildren()) {
if (result.equals(s)) {
AnimChannel channel;
if(bigEnemies.containsKey(s)) {
channel = bigEnemies.get(s);
} else {
channel = smallEnemies.get(s);
}
channel.setAnim(“Die”, 0.3f);
channel.setSpeed(0.8f);
channel.setLoopMode(LoopMode.DontLoop);
}
}
}
}[/java]
The strange thing is, that the model works perfectly fine if I run the walk animation / no animation. At the start of the die animation the head disappears (if I am too close and look down with the camera).Is something wrong with the blender model / animation? I really can’t find a solution…