XNA Creators Club Online
Page 1 of 1 (5 items)
Sort Posts: Previous Next

Matrix.CreateShadow Bug?

Last post 10/10/2008 7:56 PM by Myth UK. 4 replies.
  • 10/8/2008 3:36 PM

    Matrix.CreateShadow Bug?

    Is there a bug in Matrix.CreateShadow, or am I doing something wrong?

    Vector3 shadowLightDir = new Vector3(0.0f, 1000.0f, 0.0f);
    Plane lightPlane = new Plane(Vector3.Up, -1);
    Matrix Shadow = Matrix.CreateShadow(shadowLightDir, lightPlane);

    I use the above code in my DrawModelShadows method, to draw Planar shadows for my models... And it works... but ...

    The problem is this... the shadow is directly below the model (which is what I want), but when I move the camera around, the shadow moves from directly under the model (just slightly) in favour of the camera position (towards the camera). The model is drawn in the correct position but its shadow will now be slightly offset. I don't understand why this happens or how to fix it.

    Any ideas?

     

  • 10/10/2008 1:57 PM In reply to

    Re: Matrix.CreateShadow Bug?

    Actually, there isn't a problem at all with the Matrix.CreateShadow.

    My problem is to do with the camera's field of view. I need to alter the camera somehow, to make the 3D game look like its a 2D game (from above). I need to make the camera's near plane, equal in size to the far plane (I think... ) to get a correct 2D view. Is this correct? and if so, how do I do it?

  • 10/10/2008 4:53 PM In reply to

    Re: Matrix.CreateShadow Bug?

    That sounds like you want an orthographic projection matrix, rather than a perspective one. Matrix.CreateOrthographic will do that for you.
    XNA Framework Developer - blog - homepage
  • 10/10/2008 6:44 PM In reply to

    Re: Matrix.CreateShadow Bug?

    I have never used the orthographic projection matrix before, so I will read up on it, then give it a try.

    Thanks Shawn.

  • 10/10/2008 7:56 PM In reply to

    Re: Matrix.CreateShadow Bug?

    I tried the orthographic matrix, and it fixed my problem... Thanks.
Page 1 of 1 (5 items) Previous Next