Hey,
I have physical object and everything works well until I add to it animation. After it it’s not rigid anymore, and other objects can go through ir, here is the code how I add animation. Do you have any suggestions how to make it rigid? Or what is the problem?
float[] knots = {0.0f, 0.4f, 0.5f, 0.9f, 1.0f };
// Transform[] transforms = new Transform[knots.length];
Transform[] transform = new Transform[knots.length];
transform[0] = new Transform(new Vector3f(0.0f, 2.0f, 5.0f),
new Quaternion(0.0f, 0.0f, 0.0f, 1.0f) , Vector3f.UNIT_XYZ);
transform[1] = new Transform(new Vector3f(0.0f, 2.0f, 200.0f),
new Quaternion(0.0f, 0.0f, 0.0f, 1.0f), Vector3f.UNIT_XYZ);
transform[2] = new Transform(new Vector3f(0.0f, 2.0f, 200.0f),
(new Quaternion().fromAngleAxis(FastMath.PI, new Vector3f(0, 1, 0))), Vector3f.UNIT_XYZ);
transform[3] = new Transform(new Vector3f(0.0f, 2.0f, 5.0f),
new Quaternion().fromAngleAxis(FastMath.PI, new Vector3f(0, 1, 0)), Vector3f.UNIT_XYZ);
transform[4] = new Transform(new Vector3f(0.0f, 2.0f, 5.0f),
(new Quaternion().fromAngleAxis(2*FastMath.PI, new Vector3f(0, 1, 0))), Vector3f.UNIT_XYZ);
// Time duration for the animation
float animTime = 30;
// Frames per second for the animation
int fps = 60;
AnimationFactory animFactory = new AnimationFactory(animTime, "OtoPath", fps);
for (int i = 0; i < knots.length; i++) {
// Add the knot to the AnimationFactory
animFactory.addTimeTransform(knots[i] * animTime, transform[i]);
}
// Build the animation
Animation anim = animFactory.buildAnimation();
// Create control for the spatial animation
AnimControl control = new AnimControl();
// Hashmap of available animations
HashMap<String, Animation> animations = new HashMap<String, Animation>();
animations.put("OtoPath", anim);
control.setAnimations(animations);
// Add control to target spatial
Oto.addControl(control);
// Create channel for the animation, that enables us to play the animation
AnimChannel channel = control.createChannel();
channel.setAnim("OtoPath");
channel.setLoopMode(LoopMode.Loop); [/java]
and this is the node itself
Oto = (Node) assetManager.loadModel(“Models/Oto/Oto.mesh.xml”);
Oto.move(new Vector3f(0, 2, 5));
CollisionShape shape = CollisionShapeFactory.createDynamicMeshShape(Oto);
Oto.addControl(new RigidBodyControl(shape, 1));
bulletAppState.getPhysicsSpace().add(Oto);
[java]