Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
Efron Ho
Efron Ho's Profile
1
Posts
0
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
Array[][] causes NullPointerException,help!
[1 Reply]
09-Jul-2013 05:50 AM
Forum:
Programming Questions
there is three tabs Toximesh ,Grid, Pt
Toximesh
import toxi.math.conversion.*;
import toxi.geom.*;
import toxi.math.*;
import toxi.geom.mesh2d.*;
import toxi.util.datatypes.*;
import toxi.util.events.*;
import toxi.geom.mesh.subdiv.*;
import toxi.geom.mesh.*;
import toxi.math.waves.*;
import toxi.util.*;
import toxi.math.noise.*;
import controlP5.*;
import peasy.test.*;
import peasy.org.apache.commons.math.*;
import peasy.*;
import peasy.org.apache.commons.math.geometry.*;
PeasyCam cam;
Grid mygrid;
void setup() {
size(600, 600, P3D);
cam = new PeasyCam(this, 1000);
mygrid = new Grid(this, 201, 61,5, 5);
}
void draw() {
background(255,0,0);
stroke(255);
strokeWeight(1);
smooth();
noFill();
rect(0, 0, 1000, 300);
mygrid.run();
}
Grid
class Grid {
Toximesh p5;
int cols;
int rows;
Pt[][] allPts;
float scaleX;
float scaleY;
Grid(Toximesh _p5, int cols, int rows, float scaleX, float scaleY) {
this.p5=p5;
this.cols=cols;
this.rows =rows;
this.scaleX =scaleX;
this.scaleY = scaleY;
for (int i =0;i<cols;i++) {
for (int j=0;j<rows;j++) {
Vec3D v = new Vec3D(i*scaleX, j*scaleY, 0);
allPts[i][j] = new Pt(p5, v);
//this is the highlight
}
}
}
void run() {
runPoints();
}
void runPoints() {
for (int i =0;i<cols;i++) {
for (int j=0;j<rows;j++) {
allPts[i][j].run();
}
}
}
}
Pt
class Pt {
Toximesh p5;
Vec3D loc;
Pt(Toximesh p5, Vec3D loc) {
this.loc = loc;
this.p5=p5;
}
void run() {
display();
}
void display() {
p5.stroke(0, 255, 0);
p5.strokeWeight(2);
p5.point(loc.x, loc.y, loc.z);
}
}
error logs
PeasyCam v200
Exception in thread "Animation Thread" java.lang.NullPointerException
at Toximesh$Grid.<init>(Toximesh.java:95)
at Toximesh.setup(Toximesh.java:60)
at processing.core.PApplet.handleDraw(PApplet.java:2117)
at processing.opengl.PGL$PGLListener.display(PGL.java:2472)
at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:548)
at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:533)
at jogamp.opengl.GLAutoDrawableBase$2.run(GLAutoDrawableBase.java:280)
at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:904)
at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:822)
at com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:543)
at processing.opengl.PGL.requestDraw(PGL.java:814)
at processing.opengl.PGraphicsOpenGL.requestDraw(PGraphicsOpenGL.java:1566)
at processing.core.PApplet.run(PApplet.java:2020)
at java.lang.Thread.run(Thread.java:662)
Already called beginDraw()
«Prev
Next »
Moderate user : Efron Ho
Forum