I have written some code that has two circles each jointed to a center point (centered circle with density = 0), and a rectangle that is on the floor. I wrote code so that onKeyPress a force would be applied to the rectangle at its center of mass. I can see that clicking the key takes the rectangle out of equilibrium momentarily, but it does not move it, which was my intent. I have tried setting physics.setFriction(0.0); but this has not changed the issue. Can anyone please advise me on what my mistake is? BTW the keys the apply force are 'a' and 'd' every other key resets the sketch.
import org.jbox2d.util.nonconvex.*;
import org.jbox2d.dynamics.contacts.*;
import org.jbox2d.testbed.*;
import org.jbox2d.collision.*;
import org.jbox2d.common.*;
import org.jbox2d.dynamics.joints.*;
import org.jbox2d.p5.*;
import org.jbox2d.dynamics.*;
Physics physics;
Body crazyMan;
Vec2 force;
Vec2 pointLeft = new Vec2(width, height/2.0);
Vec2 pointRight = new Vec2(0, height/2.0);
float crazyMass;
void setup() {
size(300, 200);
frameRate(60);
smooth();
InitScene();
createObjects();
}
void draw() {
background(255);
}
void mousePressed()
{
// Do something interactive, like creating new objects
I was working with some particles and springs based on Daniel Shiffman's work and wanted to allow two of the particles to collide, and cause force on each other. Is there any existing collision detection in the toxiclibs package? Is my only option to get the velocity and mass of objects, keep track of their positions and then create an applied force on each upon collision?
I am trying to code some cellular automata and I have a container class named LifeMatrix. I want the draw thread to repeatedly call LifeMatrix's drawMatrix and updateMatrix methods. I thought that I needed to declare variable LifeMatrix Life as a global var and then initialize it during void setup() and then make the draw and update calls in void draw(), however this only draws the matrix once and then freezes. Putting the initialization of Life inside void draw() and then having drawMatrix and updateMatrix inside a for loop works perfectly though, it is not ideal. Sorry if this is confusing, see below for the code
I am new to processing and wrote some code that instantiates a class (class A) that in turn instantiates an array of another type of class (class B). This occurs on every instance of void draw, so I wanted to make sure I didn't have a memory leak, my first instinct would be to say that since a new version of class A is being instantiated there should be no pointer to the old version (since they are under the same name), since the class B array is an inner class of A I would think that A would be garbage collected, getting rid of the class array and then freeing any B objects, but I wanted to be sure, is this correct? Also is there a heap profiler for processing?