////////////////////////////////
///// 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,