I'm trying to port a simple example of Node+Spring from Generative Gestaltung to processing js with no luck.
I've got rid of libraries and stuff that could cause pbs, it runs in plain java so it should work but I get an :
Uncaught TypeError: Object #<Node> has no method 'get'
So it seems that the error comes from the class Node, and as a matter of fact the class extends PVector, so I guess the issue would come from there. It's a weird error and I really don't know were to start digging to resolve this.
I already used extended class in pjs and it didn't seem to cause trouble, does anybody have an idea how to solve this ?
Node nodeA, nodeB;
Spring spring;
void setup() {
size(600, 600);
smooth();
fill(0);
PVector vecA = new PVector( width/2+random(-50, 50), height/2+random(-50, 50));
PVector vecB = new PVector( width/2+random(-50, 50), height/2+random(-50, 50));
nodeA = new Node(vecA);
nodeB = new Node(vecB);
nodeA.setDamping(0.1);
nodeB.setDamping(0.1);
spring = new Spring(nodeA, nodeB);
spring.setLength(100);
spring.setStiffness(0.6);
spring.setDamping(0.3);
}
void draw() {
background(255);
if (mousePressed == true) {
nodeA.x = mouseX;
nodeA.y = mouseY;
}
// update spring
spring.update();
// update node positions
nodeA.update();
nodeB.update();
// draw spring
stroke(0, 130, 164);
strokeWeight(4);
line(nodeA.x, nodeA.y, nodeB.x, nodeB.y);
// draw nodes
noStroke();
fill(0);
ellipse(nodeA.x, nodeA.y, 20, 20);
ellipse(nodeB.x, nodeB.y, 20, 20);
}
// M_6_1_01.pde
// Node.pde
//
// Generative Gestaltung, ISBN: 978-3-87439-759-9
// First Edition, Hermann Schmidt, Mainz, 2009
// Hartmut Bohnacker, Benedikt Gross, Julia Laub, Claudius Lazzeroni
// Copyright 2009 Hartmut Bohnacker, Benedikt Gross, Julia Laub, Claudius Lazzeroni
ControlP5 speeds up the process of building a gui quite a lot, so I want to use it, but I would also need multi touch, does anyone has any idea how I could do that ?
I'm struggling with this code for quite some time so I need a little adivce on how to work this out.
I have a Hero class which is a an ellipse moving around following mouse clicks with physics. I have an arc class to create an arrayList of arcs which will create a maze.
I need to find the opening in my arc , and handle collisions beetween my hero and my arc. And of course the arc is rotating around the center.
So I guess what best is using polar coordinates but I'm having trouble using acos() and asin() functions and finding the angle of my hero in the (0,TWO_PI) range I want to compare it to my arc starting angle and stoping angle.
I tried to calculate a bunch of stuff converting polar to cartesian but I think I'm getting lost... So any pointers would be greatly appreciated on how to resolve that.
Here's my code to get a grasp of what's going on at the moment.
Hero hero;
ArrayList arcs;
// unlock :ending animation
boolean locked = true;
void setup() {
size(600, 600);
background(0);
strokeWeight(2);
stroke(180);
PVector a = new PVector(0.0, 0.125);
PVector v = new PVector(0.0, 0.0);
PVector l = new PVector(width/2, height/2);
hero = new Hero(a, v, l);
arcs = new ArrayList();
for (int i=1 ; i<7 ;i++) {
arcs.add(new Arc(width/2, height/2, i*100, i*100, random (PI/3, PI), random (TWO_PI, TWO_PI-PI/2)));
}
}
void draw() {
background(0);
float c = -0.23; // Drag coefficient
PVector heroVel = hero.getVel(); // Velocity of our thing
PVector force = PVector.mult(heroVel, c); // Following the formula
hero.applyForce(force); // Adding the force to our object, which will ultimately affect its acc
// Run the Thing object
hero.makeAppear();
hero.go();
// for (int i=0; i<arcs.size();i++){
// drawing only the third one for tests (uncomment the for loop to see the maze)
Arc a = (Arc) arcs.get(3);
a.display();
a.collide(hero);
// }
if (mousePressed) {
// Compute difference vector between mouse and object location
// 3 steps -- (1) Get Mouse Location, (2) Get Difference Vector, (3) Normalize difference vector
PVector m = new PVector(mouseX, mouseY);
PVector diff = PVector.sub(m, hero.getLoc());
diff.normalize();
float factor = 0.1; // Magnitude of Acceleration (not increasing it right now)
I'm developping some animated visualization from eeg data and I've got a flickering problem.
I work on a machine that is not mine (a desktop win 7 64 bits), and when I run some sketches I've built on my machine (again win 7 64 bits but laptop) some flickering appears although everything is fine on mine. I've tried using v1.5.1 and v2.03b and it's the same issue.
Basically I'm rotating a 2D shape that is being deformed en real time by eeg data without erasing the background. My shape is built with curveVertex with a fill() call with a high transparency level to get some nice texturing, nothing really fancy.
and will try something like this as soon as I can, but it deals with 3D, so I'm not sure it will affect my code.
Moreover I'm a little curious about why it works on my machine but not the other one, I may want to check some windows settings but what ? I'm also thinking about the refresing rate of the screen, it's designed to be projected so maybe hooking it up to a vp would supress the flickering on the projected image.
Please let me know if you have any thoughts on the subject, thanks for reading !
First post here, i'm just beginning to discover processing.
I wondered if there were any examples of peasycam being controlled using OSC . Peasycam does exactly what I want but using the mouse, I would like to be able to control the same movement using a message received via OSC. I know how to receive messages from OSC in processing, but I don't understand what I should do to make peasycam respond to them .
Basically I will receive X and Y values from Pure Data that will be used to look around, then when a condition is met it will be able to move in the 3D sketch using the same values
If someone could point me out to the right direction that would be great.