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

Noob question about 3D ViewingFrustum

Last post 11/11/2009 1:37 PM by Toine db. 2 replies.
  • 11/11/2009 9:12 AM

    Noob question about 3D ViewingFrustum

    I’m an experienced c#/WPF programmer but totally new with XNA.

    I started with the beginners guides, that was easy to do and good to understand. Now I
    want to go and build something by adding some stuff to the 3D tutorial game/code
    http://creators.xna.com/en-US/education/gettingstarted/bg3d/chapter10 .

    I noticed that the viewing looks like you are watching trough a big hallway, without the walls. Because you don’t see any 3d objects running/starting at the far sides of the screen. I want to create a world that looks like Space, and not that only 3d objects (in this case ships) will appear from the center. Like the image on http://msdn.microsoft.com/en-us/library/bb975157(XNAGameStudio.30).aspx I can adjust the dept (Z) easily, but not the width and height of the “Viewing Frustum”.

    So I just want to make the Space as wide and high as possible.

    I test with setting the ship startpositions wider as normal:
            Vector3 shipMinPosition = new Vector3(-2000.0f, 300.0f, -6000.0f);

            Vector3 shipMaxPosition = new Vector3(2000.0f, 800.0f, -4000.0f);

    Changed to:

            Vector3 shipMinPosition = new Vector3(-9000.0f, 300.0f, -6000.0f);

            Vector3 shipMaxPosition = new Vector3(9000.0f, 800.0f, -4000.0f);

    Then the most ships are NOT visible on the screen.

    I tried to modify the following with much different values, but without success.

    cameraViewMatrix = Matrix.CreateLookAt(

                    cameraPosition,

                    cameraLookAt,

                    Vector3.Up);

     

    cameraProjectionMatrix = Matrix.CreatePerspectiveFieldOfView(

                    MathHelper.ToRadians(45.0f),

                    graphics.GraphicsDevice.Viewport.AspectRatio,

                    1.0f,

                    10000.0f);

     

    Does anybody know what to change or to look to get a wider space.

     

    PS: it is easier to test without drawing the terrain and to center the camera:
            Vector3 cameraPosition = new Vector3(0.0f, 0.0f, 160.0f);
            Vector3 cameraLookAt = new Vector3(0.0f, 0.0f, 0.0f);


    I Hope someone can help me.

    Consultant at Logica Netherlands
  • 11/11/2009 12:25 PM In reply to

    Re: Noob question about 3D ViewingFrustum

    Answer
    Reply Quote

    cameraProjectionMatrix = Matrix.CreatePerspectiveFieldOfView(

                    MathHelper.ToRadians(45.0f),

                    graphics.GraphicsDevice.Viewport.AspectRatio,

                    1.0f,

                    10000.0f);

    Changing the value in red will make the field of view wider or narrower. You tried this and it is not what you wanted?

    Whether you are indoors or outdoors, on earth or in space, your field of view is generally the same, I'm not sure why you would want to change it. Unless you want to create some kind of warped perspective scanner display or something.

    Game hobbyist hell-bent on coding a diabolical Matrix
  • 11/11/2009 1:37 PM In reply to

    Re: Noob question about 3D ViewingFrustum

    OK, i have played a litle more with the numbers, is it normal that all other perspectives (like Z ax) changes when you change the view angle? (the MathHelper.ToRadians(45.0f) to 90.0f)

    And is there a way/formula how i can calculated what objects are shown AND what the area/matrix bounds are for the viewfield?
    Consultant at Logica Netherlands
Page 1 of 1 (3 items) Previous Next