PDA

View Full Version : Java Help With Culling



Kasi
09-25-2012, 07:02 PM
Can't get culling working, it seems to recognize that some faces aren't supposed to be drawn, but some aspects are still being shown even though they are completely blocked off.
http://i.imgur.com/enhaN.png

Anyone any idea's to fix this? current algo for culling is..



public boolean Cull(Triangle3D Triangle) {
return (Dot(
Cross(Sub(Triangle.a, Triangle.b),
Sub(Triangle.a, Triangle.c)),
CamPos) <= 0);

}

CamPos is a vector (0, 0, -20)
Edit : Triangle3D is just a triangle with 3 vectors. (X1, Y1, Z1), (X2, Y2, Z2), (X3, Y3, Z3)

masterBB
09-25-2012, 07:07 PM
It seems to work on the teapot though. Culling is just not drawing triangles that are faced backwards, not the removal of triangles that aren't visible.

Kasi
09-25-2012, 07:11 PM
It seems to work on the teapot though. Culling is just not drawing triangles that are faced backwards, not the removal of triangles that aren't visible.

i don't understand, are you saying i have to add another feature to remove triangles that are deeper in / overlapping?

masterBB
09-25-2012, 07:15 PM
i don't understand, are you saying i have to add another feature to remove triangles that are deeper in / overlapping?

yes, this is what culling is checking for:

http://blog.norbz.net/wp-content/uploads/2012/03/triangle_culling.jpg

Kasi
09-25-2012, 07:18 PM
ahh Thanks :D

masterBB
09-25-2012, 07:24 PM
This is what you want:
http://en.wikipedia.org/wiki/Z-buffering#Z-culling