olekristensen
|
newbie problem with textures...
« on: Oct 26th, 2004, 5:55pm » |
|
i am doing some little 3-d maps for the documentation of the spatial configuration of scene elements in a theatrelab here in copenhagen. wanting to learn processing i am using this task as a way to get started... but i cannot make texturing compute in my code. i.e. in other code, such as the examples in posted online elswhere on this site texturing works, even if i use my own .jpg that i cannot see in my own code. so i hope that some of you guys can lead me on the way by looking through my code below as i figure i must have done _something_ wrong: BImage a; float xmag, ymag = 0; float newXmag, newYmag = 0; void setup() { size(400, 300); noStroke(); colorMode(RGB, 1); //skal være 200*200 jpg a = loadImage("gulv.jpg"); } void loop() { background(1,1,1); push(); translate(width/2, (height/2)+40, -50); newXmag = mouseX/float(width) * TWO_PI; newYmag = mouseY/float(height) * TWO_PI; float diff = xmag-newXmag; if (abs(diff) > 0.01) { xmag -= diff/4.0; } diff = ymag-newYmag; if (abs(diff) > 0.01) { ymag -= diff/4.0; } //rotateX(-ymag); rotateY(-xmag); //scale(ymag); scale(4); //GULV beginShape(QUADS); texture(a); vertex(30,0,-30, 0,0); vertex(30,0,30, 0,200); vertex(-30,0,30, 200,0); vertex(-30,0,-30, 200,200); endShape(); //RAMME push(); scale(1.5); rotateY(0.5); beginShape(QUADS); fill(0.1, 0.1, 0.1); //front vertex(0, 0, 0); vertex(1.5, 0, 0); vertex(1.5, -10, 0); vertex(0, -10, 0); vertex(1.5, -8.5, 0); vertex(8.5, -8.5, 0); vertex(8.5, -10, 0); vertex(1.5, -10, 0); vertex(8.5, 0, 0); vertex(10, 0, 0); vertex(10, -10, 0); vertex(8.5, -10, 0); vertex(1.5, -1.5, 0); vertex(8.5, -1.5, 0); vertex(8.5, 0, 0); vertex(1.5, 0, 0); //bagside vertex(0, 0, -1.5); vertex(1.5, 0, -1.5); vertex(1.5, -10, -1.5); vertex(0, -10, -1.5); vertex(1.5, -8.5, -1.5); vertex(8.5, -8.5, -1.5); vertex(8.5, -10, -1.5); vertex(1.5, -10, -1.5); vertex(8.5, 0, -1.5); vertex(10, 0, -1.5); vertex(10, -10, -1.5); vertex(8.5, -10, -1.5); vertex(1.5, -1.5, -1.5); vertex(8.5, -1.5, -1.5); vertex(8.5, 0, -1.5); vertex(1.5, 0, -1.5); //inderside vertex(1.5, -1.5, -1.5); vertex(1.5, -8.5, -1.5); vertex(1.5, -8.5, 0); vertex(1.5, -1.5, 0); vertex(1.5, -1.5, -1.5); vertex(8.5, -1.5, -1.5); vertex(8.5, -1.5, 0); vertex(1.5, -1.5, 0); vertex(8.5, -1.5, -1.5); vertex(8.5, -8.5, -1.5); vertex(8.5, -8.5, 0); vertex(8.5, -1.5, 0); vertex(1.5, -8.5, -1.5); vertex(8.5, -8.5, -1.5); vertex(8.5, -8.5, 0); vertex(1.5, -8.5, 0); endShape(); pop(); pop(); }
|