Need 2D "targeting overlay" suggestions

Started by
1 comment, last by HoozitWhatzit 21 years, 7 months ago
Just when I thought I'd finally mastered 2D in D3D 8... Here's what I'm trying to do: create a "targeting overlay" for a first-person 3D battle game. That is, I want to have a 2D targeting bitmap that is placed over enemy units. As the enemy units move about the screen, the bitmap follows them. The image below illustrates what I mean: Now, I understand how to do 2D in Direct3D. One can: (1) use textured quads with an orthogonal projection; (2) use textured quads with transformed vertices; (3) use billboarded textured quads with a standard perspective projection. None of these approaches seem to be what I'm looking for. Approaches (1) and (2) allow you to place quads using screen coordinates, but I need quads that correspond to 3D world coordinates (in order to move with the enemy units). Approach (3) solves that problem but introduces the problem of perspective--that is, billboards look smaller the further from the camera they get. I need 2D quads that will retain their dimensions without perspective adjustment. So here's what I'm thinking of doing: use billboarding for my quads but force all my billboards to lay within a plane a fixed distance from the camera (in order to avoid perspective shift). Determining the quads' locations in this plane would be easy; determining the optimal location of the plane in relation to the camera, however, might be difficult. OK, so with that long introduction, my question is this: am I on the right track with this strategy or is there a simpler, more elegant solution for this problem? Thank you in advance for any advice you can give. --Hoozit. (edit: grammar.) [edited by - HoozitWhatzit on September 8, 2002 3:31:54 PM]
----------------------Check out my game demo and resume at www.fivestory.com/projects/game.
Advertisement
The "billboards get smaller" feature of (3) might be a good thing.

Also, remember that you can find the screen position of the target with a few transformations. You can use the world, view, and projection matrices, along with the viewport specs, to figure out where the target is in screen space. When you get that, pick your 2D method of choice.
Author, "Real Time Rendering Tricks and Techniques in DirectX", "Focus on Curves and Surfaces", A third book on advanced lighting and materials
Thanks, I tried your suggested approach and it worked great!

--Hoozit.
----------------------Check out my game demo and resume at www.fivestory.com/projects/game.

This topic is closed to new replies.

Advertisement