How to get camera plane ?
game_maker{ Camera Object } Collision To do collision (Box or Shpere) I nead to got the plane from the view port => how can I get the Camera Plane ?
Eric ColemanAssuming you know the camera's position, then you can easily find the camera's plane. use the vector v.x = ViewMatrix.m13 v.y = ViewMatrix.m23 v.z = ViewMatrix.m33 and then calculate p.x = ViewMatrix.m11 + CameraLocation.x p.y = ViewMatrix.m21 + CameraLocation.y p.z = ViewMatrix.m31 + CameraLocation.z And finally use the function D3DXPlaneFromPointNormal in the D3DX library were the vector v is your plane's normal and p is a point in the plane.
game_makervery nice ^^ but this gives me equation of plane - infnite plane ? what I need is finite plane [:)]
VBBRWouldn't it be more easy just checking with a bounding box/sphere for the camera?
Eric ColemanThe camera isn't in a finite plane, so I'm not sure what you're looking for.
game_makerTo do collision I must first compute the camera boundary right? I can't compute the boundary from equation of plane with no limit's right? So I think what I need is to find the borders in camera's plane.... The view port is a rectangular rotated in xyz ... right? See I am totally with you with math stuff: Equation of Plane: ax + by + cz + d = 0 We can find the equation (i.e. finding a,b,c,d) if we have the normal vector to the plane and any point in the plane as you said N: is the normal vector to the plane <a1,a2,a3> P: is general point in the plane <x,y,z> P1 : is a known point in the plane <x1,y1,z1> Ok if we find P1P vector = <x-x1,y-y1,z-z1> Notice that P1P is normal to N so the dot product is equal to zero N . P1P = <a1,a2,a3> . <x-x1,y-y1,z-z1> = 0 a1(x-x1) + a2(y-y1) + a3(z-z1) = 0 a1x - a1x1 + a2y - a2y1 + a3z - a3z1 = 0 a1x + a2y + a3z -( a1x1 + a2y1 + a3z1) = 0 Finally: a = a1 b = a2 c = a3 d = -(a1x1 + a2y1 + a3z1) Ok if we take camera's position + rotation it will be the center of our boundary.... I need one corner point [:)] Am I doing this wrong ? [8)]
Eric ColemanAre you trying make the viewing frustum not collide with anything? I think you should probably do what VBBR suggests, use either a bounding box or sphere around the camera's position and test to see if that collides with anything.