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 › face culling with transformation/rotation matrices
Page Index Toggle Pages: 1
face culling with transformation/rotation matrices (Read 750 times)
face culling with transformation/rotation matrices
Feb 7th, 2010, 9:45pm
 
i want to do backface culling like this

http://processing.org/hacks/hacks:backface_culling

but without using processings camera calls and positions.

how can i do backface culling using rotation and translation matrice calls and positions as opposed to the cameras?

for example if i want to do something like

Code:

float rotationX = 0, rotationY = 0;

void setup() {
 size(300, 300, P3D);
}

void draw() {
 background(0);

 lights();

 translate(width/2,height/2);
 rotateX(rotationX);
 rotateY(rotationY);
 box(150);
}

void mouseDragged() {
 rotationX += (mouseX - pmouseX) * 0.01;
 rotationY -= (mouseY - pmouseY) * 0.01;
}


how can i know which face is facing the "camera"... assuming the box being drawn from a custom box class which has a method which takes a position (pvector) and calculates which face is facing a position using the faces objects centroid and normal... as was done in the hack.
Re: face culling with transformation/rotation matrices
Reply #1 - Feb 7th, 2010, 10:16pm
 
thanks 4 that
Smiley
Re: face culling with transformation/rotation matrices
Reply #2 - Feb 8th, 2010, 1:25pm
 
The first trick is you have to know where the face actually is. After transforms and rotations the world space co-ordinate could be anywhere. A simple method is to use modelX() modelY() and modelZ() to get the actual location. From there you just check the dot product of the camera normal to the face normal and that'll give you your answer.
Page Index Toggle Pages: 1