need Fast function -> Point behind the camera
Blitz3D Forums/Blitz3D Programming/need Fast function -> Point behind the camera
| ||
A fast function to see if a point at X,Y,Z is behind the camera? (outside 180 degree of view) I was thinking about using vectors, but it could be too slow... |
| ||
may I ask why you need this? |
| ||
How can..TformPoint x,y,z,0,camera If TformedZ()<0.0 ;then point is behind camera ;do stuff EndIf..be too slow? |
| ||
I need to know if many objects will be inview before placing them on the map (plants) for each frame. I have my placepoints, and have to decide in wich of them to make the plants appear. I test the distance from the camera to each placepoint and if the placepoint is behind the camera or not. Am I wrong? :) p.s.does tformpoint check takes camera orientation into count? |
| ||
Calculate a normal for the camera using tformnormal, and then do a dot product between this and each point in the scene you want to check, after subtracting the camera's position from that point. A dot product is this: D# = Nx#*Px# + Ny#*Py# + Nz#*Pz# Then if the result, D#, is positive (I think) the point is in front of the camera. You may have to normalize the point as well after subtracting the camera position from it. That requires a square root. So hopefully you don't need to do that. |
| ||
Tformpoint will do it just fine, tformnormal and a dot product could also be done but if you just want to know if it is behind the camera tformpoint will work fine, no need to do a dot product. |
| ||
Same as Matty said, do a tformpoint with your X,Y,Z TFormPoint X,Y,Z,0,camera and then check the TFormedZ() value, if it is less than cero, then it means the point is behing the camera. Paolo. |
| ||
Thanks to everybody :) |