How to know if a triangle is facing the camera?

Blitz3D Forums/Blitz3D Programming/How to know if a triangle is facing the camera?

The Forum Archive is locked. These are the original blitzbasic.com forums, kept so their posts can still be read and searched. No new topics, replies or edits can be made here. To join the conversation, head over to the Blitz3D+ forums.

This should work ..

;get cameras direction normal
Tformnormal 0,0,1,Camera, 0
CamNx# = tformedx()
CamNy# = tformedy()
CamNz# = tformedz()

;compute dot product of camera normal and tri normal
CdotN# = CamNx*TriNx + CamNY * TriNy + CamNz * TriNz
If CdotN < 0 then
  {This tri is facing the camera}
Endif


I forget whether the CdotN should be < 0 or greater so bear that in mind if it doesn't work as is.

Stevie