Wednesday, February 9, 2011

Direct3D Camera Problem

I'm using SlimDX/C# to write a Direct3D application. I configured the camera as per textbox way:

     private float cameraZ = 5.0f;


  camera = new Camera();
  camera.FieldOfView =(float)(Math.PI/2);
  camera.NearPlane = 0.5f;
  camera.FarPlane = 1000.0f;
  camera.Location = new Vector3(0.0f, 0.0f, cameraZ);
  camera.Target = Vector3.Zero;
  camera.AspectRatio = (float)InitialWidth / InitialHeight;

The drawing and rotational method are all decent Matrix.RotationYawPitchRoll and mesh.DrawSubset(0). Everything else appear normal

My Problem is that my 3d mesh (thin square box), when look from the side, and stand vertically, it appear thicker than when it's horizontal. I've tried to change the AspectRatio to 1, it's worse. So through trial and error, I found out that it's looks much normal when the AspectRatio is around 2.6. Why is that and what could be wrong?

  • I've figured out the problem and answer already.

    Apparently I did scale the mesh, and to match the aspect ratio, and I apply the Matrix.Scaling after Matrix.RotationYawPitchRoll. When I rotate the mesh facing forward only I realize that it looks the same no matter vertically or horizontally, the scaling is stretching it sideway no mather how I rotate. Swap the 2 matrix does fix my problem. Thanks anyway

    From faulty

0 comments:

Post a Comment