We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › P3D - lost texture and distortion of form
Page Index Toggle Pages: 1
P3D - lost texture and distortion of form (Read 577 times)
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;
}
Re: P3D - lost texture and distortion of form
Reply #1 - Jan 6th, 2008, 11:42am
 
i guess you are just too close so the triangle get's clipped .. try:

translate( width/2, height/2, -10 );

F
Re: P3D - lost texture and distortion of form
Reply #2 - Jan 6th, 2008, 5:51pm
 
fjen.

I tried your suggestion and the same phenomenon occurred.

Whatever the z distance and depending on the rotation, two or three of the four triangular faces are complete and in appropriate positions. Then, at another rotation, an interior view of one triangle strangely intersects an exterior view of another.

There is always one face missing and it is always the same one. I've checked the dimensions of the missing image and it is the same as the others. I've altered the sequence of Shapes in the Matrix and still the same face is missing! But . . . .  all faces appear at all rotations when I use fill rather than texture or when I use OpenGL !



Re: P3D - lost texture and distortion of form
Reply #3 - Jan 9th, 2008, 4:59am
 
I hope you've tried...
Code:

hint(ENABLE_ACCURATE_TEXTURES)


If not, try zooming out: often I've gotten weird results only to realize my camera was too close for the shader to handle.
Re: P3D - lost texture and distortion of form
Reply #4 - Jan 9th, 2008, 1:56pm
 
No, I hadn't tried this and I was unaware of the hint() function in general. As it turned out it was hint(ENABLE_DEPTH_SORT) which solved the problem! Thanks for pointing me in that direction.
Page Index Toggle Pages: 1