realbasic-games
[Top] [All Lists]

Re: Vector behind camera?

To: REALbasic Games <realbasic-games at lists dot realsoftware dot com>
Subject: Re: Vector behind camera?
From: Asher Dunn <asher at fireyesoftware dot com>
Date: Fri, 11 Jun 2004 18:34:43 -0400
Delivered-to: realbasic-games at lists dot realsoftware dot com
List-help: <mailto:realbasic-games-request@lists.realsoftware.com?subject=help>
List-id: REALbasic Games <realbasic-games.lists.realsoftware.com>
List-post: <mailto:realbasic-games@lists.realsoftware.com>
References: <7437FB9A-BAEB-11D8-85EB-000A95DB6C90 at fireyesoftware dot com> <0A9DD2A0-BAF1-11D8-9DC1-000A95CDD7B0 at charcoaldesign dot co dot uk>

On Jun 10, 2004, at 11:15 AM, Nick Lockwood wrote:

You have to transform the vector to the camera coordinates, then compare the z axis as you would if the camera wasn't turned. It's the same transformation you would do if you wanted to render the vector to the screen, except you needn't bother with the perspective transform bit, since the z coordinates are not affected by perspective.

I tried that but it didn't seem to work. I'll try again though.

I'm afraid I can't help you much further than that because vector math makes my head hurt, but I expect you'll figure it out.

Alternatively you can use gluProject to do the transform using the OpenGL matrix. Basically you just pass gluProject a some matrices and some coordinates. The matrices are the same ones you are using to draw your scene, which you can get by using glGet with the parameters of GL_MODELVIEW_MATRIX and GL_PROJECTION_MATRIX respectively. The coordinates are the world coordinates of your vector. What you get back will be the screen coordinates of your vector, and from the z value you'll be able to tell if the object is in front or behind.

That's major overkill I think.
Thank you.

Asher Dunn
--------------------------------------------------------
President and Head Developer of Fireye Software <http://www.fireyesoftware.com/>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>