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 & HelpOpenGL and 3D Libraries › modify vertices in the box() method
Page Index Toggle Pages: 1
modify vertices in the box() method (Read 667 times)
modify vertices in the box() method
Jun 9th, 2008, 3:52pm
 
is it possible to change the X/Y/Z position of some vertices of a drawn box? i want to change the position according to the incoming audio-volume to generate a distortion-effect.

right now, i have my own shape class that looks something like this:
(the points are saved in a Point3D array, another class of my own)

beginShape(QUADS);

     // TOP
     vertex(pts[4].getX(), pts[4].getY(), pts[4].getZ());
     vertex(pts[5].getX(), pts[5].getY(), pts[5].getZ());
     vertex(pts[6].getX(), pts[6].getY(), pts[6].getZ());
     vertex(pts[7].getX(), pts[7].getY(), pts[7].getZ());

     // BOTTOM
     vertex(pts[0].getX(), pts[0].getY(), pts[0].getZ());
     vertex(pts[1].getX(), pts[1].getY(), pts[1].getZ());
     vertex(pts[2].getX(), pts[2].getY(), pts[2].getZ());
     vertex(pts[3].getX(), pts[3].getY(), pts[3].getZ());

     // FRONT
     vertex(pts[2].getX(), pts[2].getY(), pts[2].getZ());
     vertex(pts[3].getX(), pts[3].getY(), pts[3].getZ());
     vertex(pts[7].getX(), pts[7].getY(), pts[7].getZ());
     vertex(pts[6].getX(), pts[6].getY(), pts[6].getZ());

     // BACK
     vertex(pts[0].getX(), pts[0].getY(), pts[0].getZ());
     vertex(pts[1].getX(), pts[1].getY(), pts[1].getZ());
     vertex(pts[5].getX(), pts[5].getY(), pts[5].getZ());
     vertex(pts[4].getX(), pts[4].getY(), pts[4].getZ());

     // LEFT
     vertex(pts[0].getX(), pts[0].getY(), pts[0].getZ());
     vertex(pts[3].getX(), pts[3].getY(), pts[3].getZ());
     vertex(pts[7].getX(), pts[7].getY(), pts[7].getZ());
     vertex(pts[4].getX(), pts[4].getY(), pts[4].getZ());

     // RIGHT
     vertex(pts[1].getX(), pts[1].getY(), pts[1].getZ());
     vertex(pts[2].getX(), pts[2].getY(), pts[2].getZ());
     vertex(pts[6].getX(), pts[6].getY(), pts[6].getZ());
     vertex(pts[5].getX(), pts[5].getY(), pts[5].getZ());

     endShape();

it works - somehow. the floor-rectangle always shines through too bright. is there any way to change this effect? or does anyone know how the box method works inside? because that's exactly what i need.
Re: modify vertices in the box() method
Reply #1 - Jun 10th, 2008, 8:25am
 
you can used the gl object by,

// first getting the gl object, do this in setup.
gl = ((PGraphicsOpenGL)g).gl;

// then disable depth test, this should hopefully do it.
gl.glDisable( GL.GL_DEPTH_TEST );

// and play around with blend modes.
// differnt combinations which will give you
// different effects.
gl.glEnable( GL.GL_BLEND );
gl.glBlendFunc( GL.GL_SRC_ALPHA, GL.GL_ONE );
Re: modify vertices in the box() method
Reply #2 - Jun 10th, 2008, 9:02am
 
NEONLIGHT wrote on Jun 9th, 2008, 3:52pm:
or does anyone know how the box method works inside because that's exactly what i need.


have a look at the source :
http://dev.processing.org/source/index.cgi/trunk/processing/core/src/processing/core/PGraphics3D.java?view=markup

maybe you need to define the normal before each face of your cube.
Re: modify vertices in the box() method
Reply #3 - Jun 12th, 2008, 3:45pm
 
thank you for your replies!

i encountered new problems:
1) when i set the render mode to OPENGL, all i get is blank screen.
2) i included the normals, but how can i include the backface culling in my program? calling the lights() method makes it look bad rendered... any advices?

Re: modify vertices in the box() method
Reply #4 - Jun 12th, 2008, 4:12pm
 
UPDATE.

i just thought it would be easier for you to see some screenshots to understand what i mean in my previous posts.

i found out when calling the lights method i get some different results when calling the box() method or creating my own box-like shape (see my first post)

1. calling box() method:
http://img71.imageshack.us/img71/5187/200861215593830290hf8.png

2. calling myShape():
http://img71.imageshack.us/img71/123/200861215594234308lb2.png

here is the issue: I want to make it LOOK like the first picture (although this rendering is also imperfect, look at the white area in the image), BUT i need my own box-like shape to transform the vertices within it. transparency doesn't work either when i use the beginShape() and endShape() methods.

thanks in advance! i really need to get this going.



Page Index Toggle Pages: 1