public ConstraintDemoEnvironment[] generateRunnables(ParCollection params) {
ConstraintDemoEnvironment env = new ConstraintDemoEnvironment(0, params);
int idCounter = 0;
GroundAgent groundAgent = new GroundAgent(idCounter++, env);
////////////////////////////////
///// FEDER
///////////////////////////////
BoxShape armShape = new BoxShape(new Vector3f (5,0.5f,0.5f));
SphereShape gewichtShape = new SphereShape (1);
env.getCollisionShapes().add(armShape);
env.getCollisionShapes().add(gewichtShape);
ConstraintDemoAgent armAgent1 = new ConstraintDemoAgent(
idCounter++,
env,
env.getCollisionShapes().getQuick(0),
new Vector3f (5,1,0),
null,
0.1f);
ConstraintDemoAgent armAgent2 = new ConstraintDemoAgent(
idCounter++,
env,
env.getCollisionShapes().getQuick(0),
new Vector3f (5,3,0),
null,
0.1f);
ConstraintDemoAgent gewichtAgent = new ConstraintDemoAgent(
idCounter++,
env,
env.getCollisionShapes().getQuick(1),
new Vector3f (0,10,0),
null,
5f);
// (RigidBody rbA, RigidBody rbB,
// Vector3f pivotInA, Vector3f pivotInB,
// Vector3f axisInA, Vector3f axisInB)
HingeConstraint gelenk1 = new HingeConstraint(
groundAgent.getRigidBody(),
armAgent1.getRigidBody(),
new Vector3f (0,1,0),
new Vector3f (5,-.5f,0),
new Vector3f (0,0,1),
new Vector3f (0,0,1));
gelenk1.setLimit((float) Math.toRadians(20), (float) Math.toRadians(80));
HingeConstraint gelenk2 = new HingeConstraint(
armAgent1.getRigidBody(),
armAgent2.getRigidBody(),
new Vector3f (-5,0.55f,0),
new Vector3f (-5,-0.55f,0),
new Vector3f (0,0,1),
new Vector3f (0,0,1));
gelenk2.setLimit((float) Math.toRadians(-140), (float) Math.toRadians(-50));
Point2PointConstraint gewichtBefestigung = new Point2PointConstraint(
armAgent2.getRigidBody(),
gewichtAgent.getRigidBody(),
new Vector3f (5,0,0),
new Vector3f (0,0,0));
Transform localA = new Transform();
localA.setIdentity();
Transform localB = new Transform();
localB.setIdentity();
localA.origin.set(new Vector3f (0,0,0));
localB.origin.set(new Vector3f (0,0,0));
Generic6DofConstraint senkrecht = new Generic6DofConstraint(
groundAgent.getRigidBody(),
gewichtAgent.getRigidBody(),
localA,
localB,
true);
senkrecht.setLimit(0, -.9f, .9f);
senkrecht.setLimit(1, 7, 100);
senkrecht.setLimit(2, -.9f, .9f);
env.getDynamicsWorld().addConstraint(gelenk1, true);
env.getDynamicsWorld().addConstraint(gelenk2, true);
env.getDynamicsWorld().addConstraint(gewichtBefestigung, true);
env.getDynamicsWorld().addConstraint(senkrecht, true);
env.addAgent(groundAgent);
env.addAgent(armAgent1);
env.addAgent(armAgent2);
env.addAgent(gewichtAgent);
///////////////////////////////////////
////////////PENDEL
///////////////////////////////////////
BoxShape pendelShape = new BoxShape (new Vector3f (.5f,10,.5f));
env.getCollisionShapes().add(pendelShape);
ConstraintDemoAgent pendelAgent = new ConstraintDemoAgent(
idCounter++,
env,
env.getCollisionShapes().getQuick(2),
new Vector3f (10,25,10),
null,
.5f);
ConstraintDemoAgent pendelKugelAgent = new ConstraintDemoAgent(
idCounter++,
env,
env.getCollisionShapes().getQuick(1),
new Vector3f (10,5,10),
null,
5f);
Point2PointConstraint pendelAufhaengung = new Point2PointConstraint(
pendelAgent.getRigidBody(),
new Vector3f (0,11,0));
Point2PointConstraint pendelKugelBefestigung = new Point2PointConstraint(
pendelAgent.getRigidBody(),
pendelKugelAgent.getRigidBody(),
new Vector3f (0,-10,0),
new Vector3f (0,0,0));
pendelKugelAgent.getRigidBody().setActivationState(CollisionObject.DISABLE_DEACTIVATION);
pendelAgent.getRigidBody().setActivationState(CollisionObject.DISABLE_DEACTIVATION);
env.addAgent(pendelAgent);
env.addAgent(pendelKugelAgent);
env.getDynamicsWorld().addConstraint(pendelAufhaengung, true);
env.getDynamicsWorld().addConstraint(pendelKugelBefestigung, true);
//////////////////////////////////
////////////// DOPSBALL
//////////////////////////////////
ConstraintDemoAgent dopsBall = new ConstraintDemoAgent(
idCounter++,
env,
env.getCollisionShapes().getQuick(1),
new Vector3f (-20,40,20),
null,
1);
dopsBall.getRigidBody().setActivationState(CollisionObject.DISABLE_DEACTIVATION);
dopsBall.getRigidBody().setRestitution(.8f);
groundAgent.getRigidBody().setRestitution(.8f);
localA.setIdentity();
localB.setIdentity();
localA.origin.set (new Vector3f (-20,0,20));
localB.origin.set (new Vector3f (0,0,0));
Generic6DofConstraint dopsBallConstraint = new Generic6DofConstraint(
groundAgent.getRigidBody(),
dopsBall.getRigidBody(),
localA,
localB,
true);
dopsBallConstraint.setLimit(1, 1, 100);
env.addAgent(dopsBall);
env.getDynamicsWorld().addConstraint(dopsBallConstraint, false);
////////////////////////////////////
///// SCHWEBENDER BALL
////////////////////////////////
ConstraintDemoAgent schwebenderBallAgent = new ConstraintDemoAgent(
idCounter++,
env,
env.getCollisionShapes().getQuick(1),
new Vector3f (0,10,30),
null,
1);
schwebenderBallAgent.getRigidBody().setActivationState(CollisionObject.DISABLE_DEACTIVATION);
schwebenderBallAgent.getRigidBody().setRestitution(1);
schwebenderBallAgent.getRigidBody().setFriction(0);
schwebenderBallAgent.getRigidBody().setGravity(new Vector3f(0,0,0));
localA.setIdentity();
localB.setIdentity();
localA.origin.set(new Vector3f (0,10,30));
localB.origin.set(new Vector3f (0,0,0));
Generic6DofConstraint schwebenderBallAgentConstraint = new Generic6DofConstraint(
groundAgent.getRigidBody(),
schwebenderBallAgent.getRigidBody(),
localA,
localB,
true);