Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
timonmattelaer
timonmattelaer's Profile
1
Posts
2
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
Image extrusion, problem with code
[3 Replies]
26-May-2011 02:46 AM
Forum:
Programming Questions
Hello, Got problems with a code i've copied (
http://www.formandcode.com/code-examples/transform-landscape
)
I want to experiment with image extrusion, but can't seem to get it working.
-->problem:
arrayindexoutofboundexception: 1024
. So there is something wrong with my values...
But what? Can someone help me please?
import
processing.opengl.*;
PImage
img;
int
[][] values;
float
angle;
void
setup
() {
size
(1024, 768,
OPENGL
);
noFill
(); values =
new
int
[
width
][
height
];
// Extract the brightness of each pixel in the image
// and store in the "values" array
img =
loadImage
(
"nasa-iceberg.jpg"
); img.
loadPixels
();
for
(
int
i = 0; i < img.
height
; i++) {
for
(
int
j = 0; j < img.
width
; j++) {
color
pixel = img.
pixels
[i*img.
width
+ j]; values[j][i] =
int
(
brightness
(pixel)); } } }
void
draw
() {
background
(0);
// Set black background
translate
(
width
/2,
height
/2, 0);
// Move to the center
scale
(4.0);
// Scale to 400%
// Update the angle
angle += 0.005;
rotateY
(angle);
// Display the image mass
for
(
int
i = 0; i < img.
height
; i += 2) {
for
(
int
j = 0; j < img.
width
; j += 2) {
stroke
(values[j][i], 153);
float
x1 = j-img.
width
/2;
float
y1 = i-img.
height
/2;
float
z1 = -values[j][i]/2;
float
x2 = j-img.
width
/2;
float
y2 = i-img.
height
/2;
float
z2 = -values[j][i]/2-4;
line
(x1, y1, z1, x2, y2, z2); } } }
«Prev
Next »
Moderate user : timonmattelaer
Forum