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: Nick Lockwood <nick at charcoaldesign dot co dot uk>
Date: Mon, 28 Jun 2004 22:15:21 +0100
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: <F3AAD046-C7C9-11D8-BDDE-000A95DB6C90 at fireyesoftware dot com> <BCA5D6CA-C8EC-11D8-9DB0-000A95CDD7B0 at charcoaldesign dot co dot uk> <A28C1264-C932-11D8-9621-000A95DB6C90 at fireyesoftware dot com>
Surely it would be ""if view.camera.orientation.transform(theVector).z < 0 " since the camera is located at 0,0,0 in camera coordinates.

I don't think that would work either, but I will give it a try (along with Jeff's). The problem that I think I see with your code is that quaterion.transform is not camera.objectToWorldTransform. The camera's orientation doesn't know about the camera's position, so that would just test if theVector was behind the camera if the camera was at (0, 0, 0).

Soryy, yes I wasn't really paying attention to your code. This will only work if the camera is located at 0,0,0 in world corrdinates.

What I originally suggested was that you use OpenGL's glProject function which handles both the rotation and translation. If you wish to do this using your own engine's methods then you will have to do this a different way. I think all that is required is to first translate the object coordinates by subtracting the camera's coordinates from them, and then perform the rotation (incidentally I think the rotation needs to be the inverse of the camera's own orientation also). Basically you just want to do whatever it is you do to the object to draw it on screen .Conceptually it's very simple - you want to know if the object is behind the screen therefor you want to know if its z is negative when converted to screen coordinates.

I don't really know how to make this any clearer, sorry.

Nick

_______________________________________________
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>