SRL Archive - Java Help and Tutorials

Java Help With Culling


Kasi

2012-09-25 15:02:01

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.

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

2012-09-25 15:07:58

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

2012-09-25 15:11:29

From: masterBB
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

2012-09-25 15:15:51

From: pur3b100d
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:


Kasi

2012-09-25 15:18:40

ahh Thanks :D

masterBB

2012-09-25 15:24:03

This is what you want:
http://en.wikipedia.org/wiki/Z-buffering#Z-culling