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

Perspective and Ortho Projections. Use them together?

Last post 5/22/2009 2:57 PM by Kamilyon. 3 replies.
  • 5/21/2009 11:53 PM

    Perspective and Ortho Projections. Use them together?


    I have a scene being rendered in using a Perspective Projection transformation (along with the usual View and World matrices)
    I have a special 'gizmo' type model  that I want to render at a specific world position but scaled such that it maintains the same apparent size no matter where in the world it is.
    (basicaly its a 3D HUD element that I need to appear on another model at a specifc portion of that model for the user to interact with)

    What I am thinking about is having its Position/Rotation using a Perspective Projection Matrix, but it's Scale transformed using an Orthographic Projection Matrix.

    Has anyone done something like this? Is there a better approach?

    Thanks.
    :)
    code with pride, not ego!
  • 5/22/2009 12:35 AM In reply to

    Re: Perspective and Ortho Projections. Use them together?

    Why don't you just make two "view" matrices. one that is used for objects which you want to have perspective, and one for objects which you don't want to have perspective (orthographic).

    IOW you render your "hud" elements with the orthographic view matrix.

    EDIT: I am wrong

    Orthographic projection won't work like this or how you outlined above. What you'll probably want to do is use a projection matrix to figure out where the 3d object shows up on the screen, and then use that coordinate to position either a 2D element OR render a 3d element on top of the world rendering at some fixed distance from the camera.
  • 5/22/2009 4:35 AM In reply to

    Re: Perspective and Ortho Projections. Use them together?

    It's easier to just add an additional scale to the transform for the gizmo, where that scale is proportional to the distance from the camera.

    ScaleFactor = Vector3.Dot((GizmoCenter - CameraCenter), CameraForward) * Q;

    "Q" determines how big the gizmo actually becomes on the screen.
    Jon Watte, Direct3D MVP
    Tweets, occasionally
    kW X-port 3ds Max .X exporter
    kW Animation source code
  • 5/22/2009 2:57 PM In reply to

    Re: Perspective and Ortho Projections. Use them together?

    jwatte:
    It's easier to just add an additional scale to the transform for the gizmo, where that scale is proportional to the distance from the camera.

    ScaleFactor = Vector3.Dot((GizmoCenter - CameraCenter), CameraForward) * Q;

    "Q" determines how big the gizmo actually becomes on the screen.


    This is similar to what I initially thought of and I have done in my 2D only environment(using a 'Zoom' Factor instead of distance from camera), but then started thinking there might be a way to do it with the Matrix Transforms.

    Thanks for both of your responses.

    cheers,
    :)
    code with pride, not ego!
Page 1 of 1 (4 items) Previous Next