   Camera clipping problem
   Hello, I have a problem with my camera class.Whenever I get close to an object it is  clipped by the camera.I tried setting the near clipping plane to 0.0f and turning clipping off when rendering , but it does not work.Here is the the code that I use for the camera and projection matrix (it's from the directx 7.0 sdk):void __fastcall TCamera::SetCamera(void){ D3DMATRIX CameraMatrix; D3DVECTOR View=Substract(LookAtPoint,EyePoint),Up,Right,DefaultYUp,DefaultZUp; float Length,dot_product; DefaultYUp.x=0.0f;DefaultZUp.x=0.0f; DefaultYUp.y=1.0f;DefaultZUp.y=0.0f; DefaultYUp.z=0.0f;DefaultZUp.z=1.0f; Length=Magnitude(View); if(Length <1e-6f) return; View=Normalize(View,Length); dot_product=DotProduct(UpVector,View); Up=Substract(UpVector,Scale(View,dot_product)); if(1e-6f>(Length=Magnitude(Up))) {  Up=Substract(DefaultYUp,Scale(View,View.y));  if(1e-6f>(Length=Magnitude(Up)));  {   Up=Substract(DefaultZUp,Scale(View,View.z));   if(1e-6f>(Length=Magnitude(Up))) return;  } } Up=Normalize(Up,Length); Right=CrossProduct(Up,View); CameraMatrix._11=Right.x; CameraMatrix._12=Up.x; CameraMatrix._13=View.x; CameraMatrix._21=Right.y; CameraMatrix._22=Up.y; CameraMatrix._23=View.y; CameraMatrix._31=Right.z; CameraMatrix._32=Up.z; CameraMatrix._33=View.z; CameraMatrix._41=-DotProduct(EyePoint,Right); CameraMatrix._42=-DotProduct(EyePoint,Up); CameraMatrix._43=-DotProduct(EyePoint,View); CameraMatrix._14=0; CameraMatrix._24=0; CameraMatrix._34=0; CameraMatrix._44=1; D3DDevice->SetTransform(D3DTS_VIEW,&CameraMatrix);}; void __fastcall TCamera::SetProjectionMatrix(void){ D3DMATRIX ProjectionMatrix; float H,W,Q; W=(float)(1/tan(HFOV*0.5)); H=(float)(1/tan(VFOV*0.5)); Q=FarPlane/(FarPlane - NearPlane); ProjectionMatrix._12=ProjectionMatrix._13=ProjectionMatrix._14=0; ProjectionMatrix._21=ProjectionMatrix._23=ProjectionMatrix._24=0; ProjectionMatrix._31=ProjectionMatrix._32=ProjectionMatrix._34=0; ProjectionMatrix._41=ProjectionMatrix._42=ProjectionMatrix._43=0; ProjectionMatrix._11=W; ProjectionMatrix._22=H; ProjectionMatrix._33=Q; ProjectionMatrix._43=-Q*NearPlane; ProjectionMatrix._34=1; D3DDevice->SetTransform(D3DTS_PROJECTION,&ProjectionMatrix);};[Edited by - Muhammad Haggag on December 12, 2005 3:16:05 PM]
  Turning the near-plane to 0.0f won't help. Turning clipping of should do the trick then, but you said it doesn't. This might be because you are in the object.To test this, try to render that object with the following State:lpDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE)If you are able to see the object then, then the situation was what I described above.Xeile   ; Hmm, it seems you're right.What can i do to stop this?I've seen in 3d shooter that the player can get really close to wall without it being clipped by the camera.Should i change the horizontal and vertical fields of view to be larger(i'm curently using 45/45 degrees)?   ;  You can move your near clip plane closer. Just don't use 0.You prevent objects and walls from being clipped by making sure the front clip plane is inside the player's collision volume.   ;  Is there a way i can turn off the near plane clipping?I tried all kind of values near 0 (like 0.00001f) for the near plane but i still get the objects clipped. I also tried user defined planes, but the camera's planes are also taken in consideration, so the result is the same.  ;  Please use source tags. Forum FAQ.   ;  The problem was that when I calculate the projection matrix , i only modify some of the elements in the matrix, assuming that the others are zero, which they aren't.Solved by initializing the projection matrix with 0.I also changed the near plane to 0.001f and it works fine.   