//==================================================================================== // visibility test code by Gilles Tran, derived from work by // John Van Sickle and Christoph Hormann // --------------------------------------------------------- #declare CamD=vnormalize(CamLookAt-CamLoc); // direction of camera view #declare CamR=vnormalize(vcross(CamSky,CamD)); // to the right #declare CamU=vnormalize(vcross(CamD,CamR)); // camera up #declare Screen= // pseudo screen to test the visibility of an object mesh{ triangle {0, x, x+y} triangle {0, y, x+y} translate -0.5*(x+y) scale translate CamZoom*z matrix < CamR.x, CamR.y, CamR.z, CamU.x, CamU.y, CamU.z, CamD.x, CamD.y, CamD.z, CamLoc.x,CamLoc.y,CamLoc.z > } //Set SeeScreen on to test the pseudo screen #if (SeeScreen) object{Screen pigment{color rgbf<1, 0, 0, 0.9>} } #end #macro IsObjectVisible(PosObject) // this macro tests the position of the object against the pseudo screen // note: it also returns false when the position is higher than y=10 #local Norm1 = <0, 0, 0>; #local PosTemp= trace (Screen, PosObject, -PosObject+CamLoc, Norm1); #if (vlength(Norm1)!=0 )//& PosObject.y > 10) true; #else false; #end #end //====================================================================================