ChrisN
YaBB Newbies
Offline
Posts: 3
P3D - lost texture and distortion of form
Jan 6th , 2008, 8:43am
I am trying to construct a rotatable tetrahedron with textured surfaces. I first successfully converted the RGB cube into a tetrahedron with filled surfaces. When I then applied textures only three of the four faces would complete and even they became fractured/distorted on rotation. The problem goes away completely in OpenGL but I prefer not to use that because the JOGL applet launcher often gets stuck. I've searched the site for clues but I'm uncertain how to accurately describe this phenomenon, so I'm not surprised to come up empty. Any suggestions are welcome. Here's the sketch: http://www.leadershipforcollaborationandinnovation.com/imagetestP3D/index.html Here's the code: PImage organization; PImage contribution; PImage collaboration; PImage visualization; float rotx = PI/4; float roty = PI/4; void setup() { size(450, 450, P3D); stroke(180, 180, 180); organization = loadImage("organizationlead.gif"); contribution = loadImage("contributionimplement.gif"); collaboration = loadImage("collaborationlead.gif"); visualization = loadImage("visualizationlead.gif"); } void draw() { background(252, 252, 229); translate(width/2, height/2, 0); rotateX(rotx); rotateY(roty); pushMatrix(); scale(50); textureMode(IMAGE); beginShape(TRIANGLES); texture(organization); vertex(0, 2, 3, 161, 0); /*purple apex*/ vertex(3, -2, -0, 323, 280); /*green apex?*/ vertex(0, 2, -3, 0, 280); /*blue apex*/ endShape(); beginShape(TRIANGLES); texture(contribution); vertex(3, -2, 0, 161, 0); /*green apex*/ vertex(-3, -2, 0, 323, 280); /*orange apex*/ vertex( 0, 2, -3, 0, 280); /*blue apex*/ endShape(); beginShape(TRIANGLES); texture(collaboration); vertex(0, 2, 3, 161, 0); /*purple apex*/ vertex(-3, -2, 0, 0, 280); /*orange apex*/ vertex( 0, 2, -3, 323, 280); /*blue apex*/ endShape(); beginShape(TRIANGLES); texture(visualization); vertex(0, 2, 3, 161, 0); /*purple apex*/ vertex(3, -2, 0, 0, 280); /*green apex?*/ vertex(-3, -2, 0, 323, 280); /* orange apex?*/ endShape(); popMatrix(); } void mouseDragged() { float rate = 0.01; rotx += (pmouseY-mouseY) * rate; roty += (mouseX-pmouseX) * rate; }