morten
morten
This is the error I'm getting.
Throwable caught in MainThread - exiting
java.lang.IllegalStateException: DefaultScene: external delta
velocities containes NaN
at jinngine.physics.DefaultScene.step(DefaultScene.java:323)
at jinngine.physics.DefaultScene.tick(DefaultScene.java:370)
at com.complexsive.hovercraft.test.TransformationTestExample.updateExample(TransformationTestExample.java:67)
at com.ardor3d.example.ExampleBase.update(ExampleBase.java:242)
at com.ardor3d.framework.FrameHandler.updateFrame(FrameHandler.java:68)
at com.ardor3d.example.ExampleBase.run(ExampleBase.java:145)
at java.lang.Thread.run(Unknown Source)
Any advice is greatly appreciated.
Jeff
Does that happen even if you apply a constant force?
To start with, put some asserts around the places in you code where
you compute the force to be applied. Make sure its never NaN or Inf.
Do you manually set the inertia of the space craft body?
public class InteractiveDesactivationPolicy extends DefaultDeactivationPolicy { final private Set<Body> allwaysActive = new HashSet<Body>(); public void setAllwaysActive(Body b) { allwaysActive.add(b); } @Override public boolean shouldBeActivated(Body b, double dt) { if (allwaysActive.contains(b)) {return true;} return super.shouldBeActivated(b, dt); } @Override public boolean shouldBeDeactivated(Body b, double dt) { if (allwaysActive.contains(b)) { return false; } return super.shouldBeDeactivated(b, dt); } } public void main(){ final InteractiveDesactivationPolicy deactivationPolicy = new InteractiveDesactivationPolicy(); final Scene scene = new DefaultScene(new SAP2(), new NonsmoothNonlinearConjugateGradient(45), deactivationPolicy); Body body = new Body("moveyourbody"); scene.addBody(body); final Vector3 force = new Vector3(); final Vector3 torque = new Vector3(); scene.addTrigger(body, new Trigger() { public void start(Body body) {} public boolean update(Body body, double dt) { body.applyGeneralizedForce(force, torque, dt); return true; } public void stop(Body body) {} public void bodyAttached(Body body) {} public void bodyDetached(Body body) {} public void constraintAttached(Body body, Constraint c) {} public void constraintDetached(Body body, Constraint c) {} });
force.assign(10.,0.,0.);
scene.tick();
}
You project is interesting. I will following it's progress. After
looking at your code I decided to use Body.applyForce(point, f, dt)
instead.
This is what I do. In the constructor of the hovercraft, I calculate
the points where I want the force to be applied to the hovercraft.
The hovercraft model was not designed with physics in mind so I use
Box geometry for the body.
Then before each time step, I multiply those force points with the
rotation calculated from the the Geometry.getWorldTransform() and add
it to the position calculated from Geometry.getWorldTransform() to get
the new point to apply the force. Then I apply the force at that new
point. When the hovercraft is at its initial position, the force
vector would be going in the Vector3.j() direction.
Instead of hovering the hovercraft collides into the ground.
Should I multiply the force by the rotation as well?
Jeff
cool you have something working. However, the right way to do this
would be using the generalized force constraint. It might have a bug
in it somewhere. I'll look into that soon. Until then just use the way
you have found to work :)
morten
Is it possible that you can create an example using GeneralizedForce
in the geometry_rework branch? That would help me understand things a
lot. In the meantime I can look into using Pierre's approach to get
me further along.
Thanks to both of you,
Jeff
morten
Just seeing if you had a chance to work on this. Hope all is well with you.
Jeff
Thanks again for the help. I should have something to show you very
soon. I saw another model on turbo squid that I want to use in the
demo.
Jeff