Hello guys,
DOES ANYBODY KNOW HOW TO USE PVECTOR IN ECLIPSE IN A CLASS?
I just try to build an app with some strings but i dont have any look creating it in eclipse using pvector, here is the code:
the main mathod:
////////////////////
import processing.core.*;
public class main extends PApplet{
public static void main(String args[]) {
PApplet.main(new String[] { "main" });
}
PSpring spring;
PVector startpos = new PVector(0,0);
public void setup(){
spring = new PSpring(startpos, 700.0f, 10.0f, 0.7f, 0.7f, this);
//println(pp);
}
public void draw(){
spring.update(mouseX, mouseY);
}
}
//////////////
the spring class :
import processing.core.PApplet;
import processing.core.PVector;
public class PSpring{
//Vars
PVector velocity;
PVector position;
float mass;
float radii;
float stiffness;
float damping;
PApplet p;
public PSpring(PVector position_, float mass_, float radii_, float stiffness_, float damping_,PApplet pp) {
// TODO Auto-generated constructor stub
position = position_;
mass = mass_;
radii = radii_;
stiffness = stiffness_;
damping = damping_;
p = pp;
}
public void update(float tx,float ty){
//update pos
PVector target = new PVector(tx,ty);
PVector force = (PVector.sub(target, position));
force = PVector.mult(force, stiffness);
PVector acceleration = PVector.div(force, mass);
velocity = PVector.add(velocity, acceleration);
velocity.mult(damping);
position = PVector.add(position,velocity);
}
}
this doesnt work.. and what i get is:
Exception in thread "Animation Thread" java.lang.NullPointerException
at processing.core.PVector.add(Unknown Source)
at processing.core.PVector.add(Unknown Source)
at PSpring.update(PSpring.java:32)
at main.draw(main.java:20)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:662)
hope anybody has an idea
DOES ANYBODY KNOW HOW TO USE PVECTOR IN ECLIPSE IN A CLASS?
I just try to build an app with some strings but i dont have any look creating it in eclipse using pvector, here is the code:
the main mathod:
////////////////////
import processing.core.*;
public class main extends PApplet{
public static void main(String args[]) {
PApplet.main(new String[] { "main" });
}
PSpring spring;
PVector startpos = new PVector(0,0);
public void setup(){
spring = new PSpring(startpos, 700.0f, 10.0f, 0.7f, 0.7f, this);
//println(pp);
}
public void draw(){
spring.update(mouseX, mouseY);
}
}
//////////////
the spring class :
import processing.core.PApplet;
import processing.core.PVector;
public class PSpring{
//Vars
PVector velocity;
PVector position;
float mass;
float radii;
float stiffness;
float damping;
PApplet p;
public PSpring(PVector position_, float mass_, float radii_, float stiffness_, float damping_,PApplet pp) {
// TODO Auto-generated constructor stub
position = position_;
mass = mass_;
radii = radii_;
stiffness = stiffness_;
damping = damping_;
p = pp;
}
public void update(float tx,float ty){
//update pos
PVector target = new PVector(tx,ty);
PVector force = (PVector.sub(target, position));
force = PVector.mult(force, stiffness);
PVector acceleration = PVector.div(force, mass);
velocity = PVector.add(velocity, acceleration);
velocity.mult(damping);
position = PVector.add(position,velocity);
}
}
this doesnt work.. and what i get is:
Exception in thread "Animation Thread" java.lang.NullPointerException
at processing.core.PVector.add(Unknown Source)
at processing.core.PVector.add(Unknown Source)
at PSpring.update(PSpring.java:32)
at main.draw(main.java:20)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:662)
hope anybody has an idea
1