Hey all,
I have a very weird problem.
I just implemented a very basic animationController to load animations from my model and play them.
The problem is that my program runs the wrong animation.
These are my available Animations:
WALK_FORWARD,
WALK_BACKWARD,
COLLISION_WITH_WALL_FORWARD,
COLLISION_WITH_WALL_BACKWARD,
COLLISION_WITH_WALL_RIGHT,
COLLISION_WITH_WALL_LEFT,
CHECKPOINT_REACHED,
SPAWN_LAST_CHECKPOINT,
PUSHED_FORWARD,
PUSHED_BACKWARD,
PUSHED_RIGHT,
PUSHED_LEFT,
TURN_RIGHT,
TURN_LEFT,
WALK_AND_PUSH_FORWARD,
WALK_AND_PUSH_BACKWARD,
WAIT,
FALL_DOWN,
DESTROY,
WIN,
DISQUALIFY,
DEAD
And It always play the COLLISION_WITH_WALL_LEFT . Code is below, thanks for your help in advance
public class AnimController {
AnimControl animcontrol;
AnimChannel channel;
Spatial model;
public AnimController(Spatial spa){
this.model = spa;
animcontrol = spa.getControl(AnimControl.class);
animcontrol.clearChannels();
channel = animcontrol.createChannel();
channel.setAnim("WAIT");
}
public float getAnimLength(AnimState animState){
channel.setAnim("WAIT");
return animcontrol.getAnimationLength(animState.toString());
}
}
public void simpleUpdate(float tpf) {
if(counter > animlength){
counter = 0;
if(!animList.isEmpty()){
animlength = animController.getAnimLength(animList.get(0));
System.out.println("Set new animation: " + animList.get(0).toString());
animList.remove(0);
}else{
for(AnimState animstate : AnimState.values()){
animList.add(animstate);
}
}
}else{
counter += tpf;
}
}
Spatial model = assetManager.loadModel(“Models/DrivingOven.mesh.j3o”);
TangentBinormalGenerator.generate(model);
Material matQuad = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
Texture difTex = assetManager.loadTexture("Textures/T_DrivingOven_albedo.png");
difTex.setWrap(Texture.WrapMode.Repeat);
matQuad.setTexture("DiffuseMap", difTex);
Texture normalTex = assetManager.loadTexture("Textures/old_T_DrivingOven_normal.png");
normalTex.setWrap(Texture.WrapMode.Repeat);
matQuad.setTexture("NormalMap", normalTex);
Texture specularTex = assetManager.loadTexture("Textures/T_DrivingOven_specular.png");
matQuad.setTexture("SpecularMap" , specularTex);
matQuad.setBoolean("UseMaterialColors", false
);
matQuad.setColor("Ambient", ColorRGBA.White);
matQuad.setColor("Diffuse", ColorRGBA.White); // minimum material color
matQuad.setColor("Specular", ColorRGBA.White); // for shininess
matQuad.setFloat("Shininess", 64f); // [1,128] for shininess
matQuad.setReceivesShadows(true);
model.setShadowMode(ShadowMode.CastAndReceive);
model.setMaterial(matQuad);
animController = new AnimController(model);
rootNode.attachChild(model);