Hi all,
does anyone have experience with setting up an FGearJoint in Fisica properly?
I have attached a little study in which I try to connect two FRevoluteJoints by an FGearJoint. Unfortunately, the Constructor of the FGearJoint keeps producing a Null Pointer Exception, although, according to the Fisica documentation, everything should be fine.
Could anyone tell me how to modify my code in order to get the FGearJoint going? I’ve been searching around the internet for a working example but couldn’t find anything.
Many thanks in advance & all the best to everybody,
ilinx
import fisica.*;
FBox wheelA, wheelB;
FCircle hubA, hubB;
FRevoluteJoint revJointA, revJointB;
FGearJoint gearJoint;
FWorld world;
void setup() {
size(400, 400);
Fisica.init(this);
world = new FWorld();
// Wheel A /////////////////////////////////////
wheelA = new FBox(80,80);
wheelA.setPosition(100,200);
world.add(wheelA);
hubA = new FCircle(10);
hubA.setPosition(100,200);
hubA.setStatic(true);
world.add(hubA);
revJointA = new FRevoluteJoint(wheelA,hubA);
world.add(revJointA);
////////////////////////////////////////////////
// Wheel B /////////////////////////////////////
wheelB = new FBox(100,100);
wheelB.setPosition(300,200);
world.add(wheelB);
hubB = new FCircle(10);
hubB.setPosition(300,200);
hubB.setStatic(true);
world.add(hubB);
revJointB = new FRevoluteJoint(wheelB,hubB);
world.add(revJointB);
////////////////////////////////////////////////
// Connecting the two Joints ... ///////////////
gearJoint = new FGearJoint(revJointA,revJointB);
gearJoint.setRatio(2.0);
world.add(gearJoint);
////////////////////////////////////////////////
}
void draw() {
background(255);
world.step();
world.draw();
}