Why my mesh cannot move with bone?

i have create and succesfully import the mesh and skeleton.



when i run the animation, i just get animation of my skeleton but mesh not follow the bone…

how can i fix this?

anyone can help me?

  1. are your bones assigned to any vertices?
  2. how did you export/import the mesh+animation?

yes i have assign it to any vertices.

i have animated it in blender but when i export with ogre and i got

cube.mesh.xml

cube.mesh

cube.skeleton.xml

cube.skeleton

cube.scene

cube.material



yes i have successfuly export and import it all…



but why the just the bone was animated?

There should be a boneAssignments section in the mesh.xml file:

[xml]<boneassignments>

<vertexboneassignment vertexindex=“0” weight=“1.0” boneindex=“0”/>

<vertexboneassignment vertexindex=“1” weight=“1.0” boneindex=“13”/>

<vertexboneassignment vertexindex=“2” weight=“1.0” boneindex=“13”/>

<vertexboneassignment vertexindex=“2” weight=“1.0” boneindex=“15”/>

<vertexboneassignment vertexindex=“3” weight=“1.0” boneindex=“13”/>

<vertexboneassignment vertexindex=“4” weight=“1.0” boneindex=“13”/>[/xml]

Just confirm that it is there.



Can you post the code that you are using to call the animation?

Also when you import the model into the scene explorer, do you have an AnimControl there?

http://i.imgur.com/xr5CU.png

And does it have the animations you wanted? You can check those in the properties window on the right side of the SDK, there should be a dropdown list of your exported animations. It is a good place there to test the animations. If they work there but not in your code then the issue is in your code. But first make sure the animations work in the scene explorer.



Some things you will have to make sure:

  • Do not use envelopes for bone-vertex assignments
  • Do not scale,rotate,translate the model in blender

    This page has some tips on getting animations to work. They are a bit fiddly at the moment.

this is my code to call the animation



package mygame;

import com.jme3.animation.AnimChannel;
import com.jme3.animation.AnimControl;
import com.jme3.animation.AnimEventListener;
import com.jme3.animation.LoopMode;
import com.jme3.bullet.BulletAppState;
import com.jme3.app.SimpleApplication;
import com.jme3.bullet.PhysicsSpace;
import com.jme3.bullet.collision.PhysicsCollisionEvent;
import com.jme3.bullet.collision.PhysicsCollisionListener;
import com.jme3.bullet.collision.shapes.CapsuleCollisionShape;
import com.jme3.bullet.collision.shapes.SphereCollisionShape;
import com.jme3.bullet.control.CharacterControl;
import com.jme3.bullet.control.RigidBodyControl;
import com.jme3.bullet.util.CollisionShapeFactory;
import com.jme3.effect.ParticleEmitter;
import com.jme3.effect.ParticleMesh.Type;
import com.jme3.effect.shapes.EmitterSphereShape;
import com.jme3.input.ChaseCamera;
import com.jme3.input.KeyInput;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.light.DirectionalLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector2f;
import com.jme3.math.Vector3f;
import com.jme3.post.FilterPostProcessor;
import com.jme3.post.filters.BloomFilter;
import com.jme3.renderer.Camera;
import com.jme3.renderer.queue.RenderQueue.ShadowMode;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.scene.debug.SkeletonDebugger;
import com.jme3.scene.shape.Box;
import com.jme3.scene.shape.Sphere;
import com.jme3.scene.shape.Sphere.TextureMode;
import com.jme3.terrain.geomipmap.TerrainLodControl;
import com.jme3.terrain.geomipmap.TerrainQuad;
import com.jme3.terrain.heightmap.AbstractHeightMap;
import com.jme3.terrain.heightmap.ImageBasedHeightMap;
import com.jme3.texture.Texture;
import com.jme3.texture.Texture.WrapMode;
import com.jme3.util.SkyFactory;
import java.util.ArrayList;
import java.util.List;
import jme3tools.converters.ImageToAwt;
import mygame.BombControl;

/**
* A walking animated character followed by a 3rd person camera on a terrain with LOD.
* @author normenhansen
*/
public class TestWalkingChar extends SimpleApplication implements ActionListener, PhysicsCollisionListener, AnimEventListener {
private ActionListener actionListener = new ActionListener() {
public void onAction(String name, boolean keyPressed, float tpf) {
if (name.equals("Walk") && !keyPressed) {
if (!animationChannel.getAnimationName().equals("Walk")){
animationChannel.setAnim("Walk", 0.50f);
animationChannel.setLoopMode(LoopMode.Cycle);
}
}
}
};
private BulletAppState bulletAppState;
//character
CharacterControl character;
Node model;
//temp vectors
Vector3f walkDirection = new Vector3f();
//terrain
TerrainQuad terrain;
RigidBodyControl terrainPhysicsNode;
//Materials
Material matRock;
Material matBullet;
//animation
AnimChannel animationChannel;
AnimChannel shootingChannel;
AnimControl animationControl;
float airTime = 0;
//camera
boolean left = false, right = false, up = false, down = false;
ChaseCamera chaseCam;
//bullet
Sphere bullet;
SphereCollisionShape bulletCollisionShape;
//explosion
ParticleEmitter effect;
//brick wall
Box brick;
float bLength = 0.8f;
float bWidth = 0.4f;
float bHeight = 0.4f;
FilterPostProcessor fpp;

public static void main(String[] args) {
TestWalkingChar app = new TestWalkingChar();
app.start();
}

@Override
public void simpleInitApp() {
bulletAppState = new BulletAppState();
bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
stateManager.attach(bulletAppState);
setupKeys();
prepareBullet();
prepareEffect();
createLight();
createSky();
createTerrain();
createWall();
createCharacter();
setupChaseCamera();
setupAnimationController();
setupFilter();
skel();
}

private void setupFilter() {
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
BloomFilter bloom = new BloomFilter(BloomFilter.GlowMode.Objects);
fpp.addFilter(bloom);
viewPort.addProcessor(fpp);
}

private PhysicsSpace getPhysicsSpace() {
return bulletAppState.getPhysicsSpace();
}

private void setupKeys() {
inputManager.addMapping("wireframe", new KeyTrigger(KeyInput.KEY_T));
inputManager.addListener(this, "wireframe");
inputManager.addMapping("CharLeft", new KeyTrigger(KeyInput.KEY_A));
inputManager.addMapping("CharRight", new KeyTrigger(KeyInput.KEY_D));
inputManager.addMapping("CharUp", new KeyTrigger(KeyInput.KEY_W));
inputManager.addMapping("CharDown", new KeyTrigger(KeyInput.KEY_S));
inputManager.addMapping("CharSpace", new KeyTrigger(KeyInput.KEY_RETURN));
inputManager.addListener(this, "CharLeft");
inputManager.addListener(this, "CharRight");
inputManager.addListener(this, "CharUp");
inputManager.addListener(this, "CharDown");
inputManager.addListener(this, "CharSpace");

inputManager.addMapping("yoyo", new KeyTrigger(KeyInput.KEY_SPACE));
inputManager.addListener(actionListener, "yoyo");
}

private void createWall() {
float xOff = -144;
float zOff = -40;
float startpt = bLength / 4 - xOff;
float height = 6.1f;
brick = new Box(Vector3f.ZERO, bLength, bHeight, bWidth);
brick.scaleTextureCoordinates(new Vector2f(1f, .5f));
for (int j = 0; j < 15; j++) {
for (int i = 0; i < 4; i++) {
Vector3f vt = new Vector3f(i * bLength * 2 + startpt, bHeight + height, zOff);
addBrick(vt);
}
startpt = -startpt;
height += 1.01f * bHeight;
}
}

private void addBrick(Vector3f ori) {
Geometry reBoxg = new Geometry("brick", brick);
reBoxg.setMaterial(matBullet);
reBoxg.setLocalTranslation(ori);
reBoxg.addControl(new RigidBodyControl(1.5f));
reBoxg.setShadowMode(ShadowMode.CastAndReceive);
this.rootNode.attachChild(reBoxg);
this.getPhysicsSpace().add(reBoxg);
}

private void prepareBullet() {
bullet = new Sphere(32, 32, 0.4f, true, false);
bullet.setTextureMode(TextureMode.Projected);
bulletCollisionShape = new SphereCollisionShape(0.4f);
matBullet = new Material(getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
matBullet.setColor("Color", ColorRGBA.Green);
matBullet.setColor("m_GlowColor", ColorRGBA.Green);
getPhysicsSpace().addCollisionListener(this);
}

private void prepareEffect() {
int COUNT_FACTOR = 1;
float COUNT_FACTOR_F = 1f;
effect = new ParticleEmitter("Flame", Type.Triangle, 32 * COUNT_FACTOR);
effect.setSelectRandomImage(true);
effect.setStartColor(new ColorRGBA(1f, 0.4f, 0.05f, (float) (1f / COUNT_FACTOR_F)));
effect.setEndColor(new ColorRGBA(.4f, .22f, .12f, 0f));
effect.setStartSize(1.3f);
effect.setEndSize(2f);
effect.setShape(new EmitterSphereShape(Vector3f.ZERO, 1f));
effect.setParticlesPerSec(0);
effect.setGravity(0, -5, 0);
effect.setLowLife(.4f);
effect.setHighLife(.5f);
effect.setInitialVelocity(new Vector3f(0, 7, 0));
effect.setVelocityVariation(1f);
effect.setImagesX(2);
effect.setImagesY(2);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
mat.setTexture("Texture", assetManager.loadTexture("Effects/Explosion/flame.png"));
effect.setMaterial(mat);
// effect.setLocalScale(100);
rootNode.attachChild(effect);
}

private void createLight() {
Vector3f direction = new Vector3f(-0.1f, -0.7f, -1).normalizeLocal();
DirectionalLight dl = new DirectionalLight();
dl.setDirection(direction);
dl.setColor(new ColorRGBA(1f, 1f, 1f, 1.0f));
rootNode.addLight(dl);
}

private void createSky() {
rootNode.attachChild(SkyFactory.createSky(assetManager, "Textures/Sky/Bright/BrightSky.dds", false));
}

private void createTerrain() {
matRock = new Material(assetManager, "Common/MatDefs/Terrain/TerrainLighting.j3md");
matRock.setBoolean("useTriPlanarMapping", false);
matRock.setBoolean("WardIso", true);
matRock.setTexture("AlphaMap", assetManager.loadTexture("Textures/Terrain/splat/alphamap.png"));
Texture heightMapImage = assetManager.loadTexture("Textures/Terrain/splat/mountains512.png");
Texture grass = assetManager.loadTexture("Textures/Terrain/splat/grass.jpg");
grass.setWrap(WrapMode.Repeat);
matRock.setTexture("DiffuseMap", grass);
matRock.setFloat("DiffuseMap_0_scale", 64);
Texture dirt = assetManager.loadTexture("Textures/Terrain/splat/dirt.jpg");
dirt.setWrap(WrapMode.Repeat);
matRock.setTexture("DiffuseMap_1", dirt);
matRock.setFloat("DiffuseMap_1_scale", 16);
Texture rock = assetManager.loadTexture("Textures/Terrain/splat/road.jpg");
rock.setWrap(WrapMode.Repeat);
matRock.setTexture("DiffuseMap_2", rock);
matRock.setFloat("DiffuseMap_2_scale", 128);
Texture normalMap0 = assetManager.loadTexture("Textures/Terrain/splat/grass_normal.jpg");
normalMap0.setWrap(WrapMode.Repeat);
Texture normalMap1 = assetManager.loadTexture("Textures/Terrain/splat/dirt_normal.png");
normalMap1.setWrap(WrapMode.Repeat);
Texture normalMap2 = assetManager.loadTexture("Textures/Terrain/splat/road_normal.png");
normalMap2.setWrap(WrapMode.Repeat);
matRock.setTexture("NormalMap", normalMap0);
matRock.setTexture("NormalMap_1", normalMap2);
matRock.setTexture("NormalMap_2", normalMap2);

AbstractHeightMap heightmap = null;
try {
heightmap = new ImageBasedHeightMap(ImageToAwt.convert(heightMapImage.getImage(), false, true, 0), 0.25f);
heightmap.load();

} catch (Exception e) {
e.printStackTrace();
}

terrain = new TerrainQuad("terrain", 65, 513, heightmap.getHeightMap());
List cameras = new ArrayList();
cameras.add(getCamera());
TerrainLodControl control = new TerrainLodControl(terrain, cameras);
terrain.addControl(control);
terrain.setMaterial(matRock);
terrain.setLocalScale(new Vector3f(2, 2, 2));

terrainPhysicsNode = new RigidBodyControl(CollisionShapeFactory.createMeshShape(terrain), 0);
terrain.addControl(terrainPhysicsNode);
rootNode.attachChild(terrain);
getPhysicsSpace().add(terrainPhysicsNode);
}

private void createCharacter() {
CapsuleCollisionShape capsule = new CapsuleCollisionShape(3f, 4f);
character = new CharacterControl(capsule, 0.01f);
model = (Node) assetManager.loadModel("Models/testing/falcon.mesh.xml");
//model.setLocalScale(0.5f);
model.addControl(character);
character.setPhysicsLocation(new Vector3f(-140, 15, -10));
rootNode.attachChild(model);
getPhysicsSpace().add(character);
}

private void setupChaseCamera() {
flyCam.setEnabled(false);
chaseCam = new ChaseCamera(cam, model, inputManager);
}

private void setupAnimationController() {
animationControl = model.getControl(AnimControl.class);
animationControl.addListener(this);
animationChannel = animationControl.createChannel();
for (String anim : animationControl.getAnimationNames()) { System.out.println(anim); }

//posisi awal
animationChannel.setAnim("my_animation");
}

@Override
public void simpleUpdate(float tpf) {
Vector3f camDir = cam.getDirection().clone().multLocal(0.1f);
Vector3f camLeft = cam.getLeft().clone().multLocal(0.1f);
camDir.y = 0;
camLeft.y = 0;
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());
}
if (!character.onGround()) {
airTime = airTime + tpf;
} else {
airTime = 0;
}



if (walkDirection.length() != 0) {


character.setViewDirection(walkDirection);

}

character.setWalkDirection(walkDirection);

}

public void onAction(String binding, boolean value, float tpf) {
if (binding.equals("CharLeft")) {
if (value) {
left = true;
} else {
left = false;
}
} else if (binding.equals("CharRight")) {
if (value) {
right = true;
} else {
right = false;
}
} else if (binding.equals("CharUp")) {
if (value) {
up = true;
} else {
up = false;
}
} else if (binding.equals("CharDown")) {
if (value) {
down = true;
} else {
down = false;
}
} else if (binding.equals("CharSpace")) {
character.jump();
} else if (binding.equals("CharShoot") && !value) {
bulletControl();
}
}

private void bulletControl() {
shootingChannel.setAnim("Dodge", 0.1f);
shootingChannel.setLoopMode(LoopMode.DontLoop);
Geometry bulletg = new Geometry("bullet", bullet);
bulletg.setMaterial(matBullet);
bulletg.setShadowMode(ShadowMode.CastAndReceive);
bulletg.setLocalTranslation(character.getPhysicsLocation().add(cam.getDirection().mult(5)));
RigidBodyControl bulletControl = new BombControl(bulletCollisionShape, 1);
bulletControl.setCcdMotionThreshold(0.1f);
bulletControl.setLinearVelocity(cam.getDirection().mult(80));
bulletg.addControl(bulletControl);
rootNode.attachChild(bulletg);
getPhysicsSpace().add(bulletControl);
}

public void collision(PhysicsCollisionEvent event) {
if (event.getObjectA() instanceof BombControl) {
final Spatial node = event.getNodeA();
effect.killAllParticles();
effect.setLocalTranslation(node.getLocalTranslation());
effect.emitAllParticles();
} else if (event.getObjectB() instanceof BombControl) {
final Spatial node = event.getNodeB();
effect.killAllParticles();
effect.setLocalTranslation(node.getLocalTranslation());
effect.emitAllParticles();
}
}

public void onAnimCycleDone(AnimControl control,
AnimChannel channel, String animName) {
if (animName.equals("yoyo")) {
channel.setAnim("yoyo", 0.50f);
channel.setLoopMode(LoopMode.DontLoop);
channel.setSpeed(1f);
}
}

public void onAnimChange(AnimControl control, AnimChannel channel, String animName) {
}

private void skel() {
SkeletonDebugger skeletonDebug =
new SkeletonDebugger("skeleton", animationControl.getSkeleton());
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.Green);
mat.getAdditionalRenderState().setDepthTest(false);
skeletonDebug.setMaterial(mat);
model.attachChild(skeletonDebug); }
}

Can you confirm first if the animations work in the scene explorer?

ahh you right, i can test it there…

yes i have found anim control…

and my animation that i want, but no animation done…

when i try oto.mesh example from jme3 i can play the animation…





i have create root bone,turn off the envelopes …



can you explain the mean of apply loc,rot,scale…?



what i want to ask is…

when we animate something we must change the location right?

so apply loc,rot,scale to 0 , is for the first time or what?

i think the blender and ogre have many trouble…

can you tell me what program that i can use for modelling and make animation in the jme3…

i have 2 weeks do it…

from i download the blender 2.63 , then i use 2.59 so the xml can be read in the jme3…

try many exporter version…

any suggest?

The ogre exporter is finicky.

Your model cannot have any transforms on it in its resting position:

http://i.imgur.com/AdLo0.png



Animations can move it however they want, but the original mesh and the root bone cannot be transformed. You can translate/scale/rotate the mesh in edit mode in blender as much as you want, but outside of edit mode the mesh cannot be transformed.



Right now the ogre exporter is the best bet for loading in animations.

yes mr sploreg i am very thanks ful for your information…



here is my some example i have create many blender file…

please open it and export it with the ogre…

http://www.ziddu.com/download/19887877/falcon.rar.html

after you can export it and animated it…

please tell me what wrong with my blender…



and can you tell me the blender version + ogre xml you use for export it…



really thanks mr Sploreg :slight_smile:

I exported it with the animation and it works fine in the scene explorer. I didn’t change anything on it.

Did you select the armature when you exported?

http://i.imgur.com/OsYe0.png



I’m using Blender v2.6.2 and Ogre exporter v0.5.5 found in the table on this page.

yes i have select it… oh god…

so i spare my 4 days with 3 hours sleep for nothing?

i think i should download that version of blender now…

i hate if the problem is like this…

hey mr sploreg do you have a facebook account / yahoo messenger?

or anything else…

i am very appreciate your help …

i hope i can help you someday…

yea I feel ya. The ogre exporter is a tough one to figure out. Maybe if someone writes an fbx importer things could be easier. Or when the .blend importer is fully stable (it’s getting close, I haven’t tried animations with it however)

yes i have tried to import the blend, but i never animated it too…

I don’t use facebook anymore; tired of them knowing everything I think and do :slight_smile:

Thanks here are enough. Glad I could help and I hope you get it exported successfully.

hey mr Sploreg… so how i can contact you if i got another problem? maybe email at least?

hey mr sploreg , i have download the blender 2.62 and 5.5 ogre …

but still just the bone that can move but the mesh is stay…?

hello mr sploreg?

anyone can tell me step by step export then import it into jme3?

when export we got *.scene right?

when import what file that we choose for the asset?

or just copy all file in the asset/models/ folder?

then for testing in the scene explorer what file is it?

falcon.j3o or

falcon.mesh.xml or

falcon.scene?

please tell me

@choprapancavoohunn said:
hey mr Sploreg.. so how i can contact you if i got another problem? maybe email at least?

Just on the forums with the @Sploreg tag is easiest.

To import the model right-click on the falcon.mesh.xml file. That will create the falcon.j3o file. You might want to update jme to the latest stable beta, or even try the latest nightly build (I'm using a build from a week ago).