Toxi.physics Circular/ParticleConstraint
in
Contributed Library Questions
•
2 years ago
Hi,
I'm trying to get a better understanding of the toxilibs and physics in particular but it's not really working out. Taking small steps so i started with 2d first. After modifying the attract2d-example i'm trying to add a barrier when they fall down so i need to implement a (circular) particleconstraint on the particles and this is where things go wrong. I've tried (the commented lines) but i'ts saying it cannot find the class? So my guess is i'm totally wrong here and before i lose all hope i turn to you...
And some small things-
This "for"-structure, is this processing-native or only available in toxi? I assume it says increase verletparticle p untill it is equal to physics.particles?
for (VerletParticle2D p : physics.particles) {
ellipse(p.x, p.y, 5, 5);
point(p.x,p.y);
And from the boxfluiddemo: What is AABB?
physics.setWorldBounds(new AABB(new Vec3D(),new Vec3D(DIM,DIM,DIM)));
Anyway sorry for the long post but i'd like to understand this (amazing) library so i really appreciate all the help and i hope i've been clear enough in explaining the issues. Thanks
FRid
And on a sidenote: are there any good tutorials regarding the toxilibs (physics in particular)? The javadocs are not really working for me, i see all the very nice features available but i have no knowledge of how to implement them.
I'm trying to get a better understanding of the toxilibs and physics in particular but it's not really working out. Taking small steps so i started with 2d first. After modifying the attract2d-example i'm trying to add a barrier when they fall down so i need to implement a (circular) particleconstraint on the particles and this is where things go wrong. I've tried (the commented lines) but i'ts saying it cannot find the class? So my guess is i'm totally wrong here and before i lose all hope i turn to you...
And some small things-
This "for"-structure, is this processing-native or only available in toxi? I assume it says increase verletparticle p untill it is equal to physics.particles?
for (VerletParticle2D p : physics.particles) {
ellipse(p.x, p.y, 5, 5);
point(p.x,p.y);
And from the boxfluiddemo: What is AABB?
physics.setWorldBounds(new AABB(new Vec3D(),new Vec3D(DIM,DIM,DIM)));
Anyway sorry for the long post but i'd like to understand this (amazing) library so i really appreciate all the help and i hope i've been clear enough in explaining the issues. Thanks
FRid
And on a sidenote: are there any good tutorials regarding the toxilibs (physics in particular)? The javadocs are not really working for me, i see all the very nice features available but i have no knowledge of how to implement them.
- import toxi.geom.*;
import toxi.physics2d.*;
import toxi.physics2d.behaviors.*;
int NUM_PARTICLES = 100;
VerletPhysics2D physics;
//CirculrConstraint myConstraint; // This gives me "cannot find class or type named "CircularConstraint""
//ParticleConstraint2d myConstraint; // This gives me "cannot find class or type named "ParticleConstraint2d""
void setup() {
size(400,400,P2D);
physics = new VerletPhysics2D();
physics.setDrag(0.05f);
physics.setWorldBounds(new Rect(0, 0, width, 300));
physics.addBehavior(new GravityBehavior(new Vec2D(0, 0.15f)));
//myConstraint = new CircularConstraint(200,200,300);
//Physics.addConstraintToAll(myConstraint,p);
}
void addParticle() {
VerletParticle2D p = new VerletParticle2D(Vec2D.randomVector().scale(5).addSelf(width / 2, 0));
physics.addParticle(p);
physics.addBehavior(new AttractionBehavior(p, 5, -1.2f, 0.01f)); //(Vec2,radius,strength,jitter)
}
void draw() {
background(255,0,0);
if (physics.particles.size() < NUM_PARTICLES) {
addParticle();
}
physics.update();
for (VerletParticle2D p : physics.particles) {
ellipse(p.x, p.y, 5, 5);
point(p.x,p.y);
}
}
1