The program reads data from a heightmap and colormap to make terrain for a game I'm making.
I get the exception at the starred line.
Code:/**Unnamed Game by Jonah
*/
import damkjer.ocd.*;
PImage[][] levels;
//Player player;
Terrain test;
Camera standard;
void setup() {
size(700,700,P3D);
levels=new PImage[1][3];
levels[0][0]=loadImage("testHeight.jpg");
levels[0][1]=loadImage("testColor.jpg");
levels[0][2]=loadImage("testCube.jpg");
standard=new Camera(this,50);
test=new Terrain(levels[0][0],levels[0][1],levels[0][2]);
noStroke();
}
void draw() {
background(0);
lights();
standard.feed();
test.disp();
}
class Terrain {
int[][] heightMap;
color[][] colorMap;
boolean[][] squareMap;
Terrain(PImage heightM,PImage colorM, PImage squaresM) {
heightMap=new int[600][600];
colorMap=new color[600][600];
squareMap=new boolean[600][600];
PGraphics maps=createGraphics(600,600,P3D);
maps.beginDraw();
image(heightM,0,0);
maps.loadPixels();
for(int q=0;q<600;q++) {
for(int w=0;w<600;w++) {
***** heightMap[q][w]=255-int(blue(pixels[600*q+w]));
}
}
image(colorM,0,0);
maps.loadPixels();
for(int q=0;q<600;q++) {
for(int w=0;w<600;w++) {
colorMap[q][w]=pixels[600*q+w];
}
}
image(squaresM,0,0);
maps.loadPixels();
for(int q=0;q<600;q++) {
for(int w=0;w<600;w++) {
if (blue(pixels[600*q+w])==0) {
squareMap[q][w]=true;
}
else {
squareMap[q][w]=false;
}
}
}
maps.endDraw();
}
void disp() {
for(int z=0;z<600;z++) {
for(int x=0;x<600;x++) {
fill(colorMap[z][x]);
translate(x,heightMap[z][x]/2,z);
box(1,heightMap[z][x],1);
translate(0,heightMap[z][x]/2,0);
if(!squareMap[z][x]) {
sphere(1);
}
translate(-1*x,-1*heightMap[z][x],-1*z);
}
}
}
}