Jump to content
Sign in to follow this  
Morbid Jester

Getting the position (X/Y/Z) of the place a camera is looking at

Recommended Posts

Hi, there. I am tinkereing around with the camera in ARMA and I want to obtain the exact coordinates the camera is pointed at. (basically the coordinates of the point where the "gaze direction" of the camera intersects with the "floor".

Here is what I want to do:

Compare the coordiantes from the camera viewpoint to the position of a unit (which is supposed to be within a certain range around the position. If it is, I want to trigger another event.

Here is what i did so far to get there:

I have created a camera at a fixed position, the camera can be panned around and zoomed using a Joystick. Works a treat.

Somehow I fail in getting the the map position of the place the camera is looking at at a specific time (defined by a keypress). I use the information from "camPrepareTarget" to get the info using the following line of code:

_target setPosASL [_camx + (cos _direction) * (cos _dive) * 100000, _camy + (sin _direction) * (cos _dive) * 100000, _camz + (sin _dive) * 100000]

_camera CamSetTarget _target

where

_camx=x-coordinate of Camera Position

_camy=y-coordinate of Camera Position

_camz=z-coordinate of Camera Position

_direction="gaze direction" of the camera right/left (0-360°)

_dive=camera inclination (-90° -bis +90°)

Example:

For a certain camera Position and gaze direction, I SHOULD be getting this output (and I do so using camera.sqs):

;=== 12:26:02

_camera camPrepareTarget [14312.83,12475.29,-0.00]

_camera camPreparePos [14190.81,11883.26,106.64]

_camera camPrepareFOV 0.029

_camera camCommitPrepared 0

@camCommitted _camera

However, I DO get the following:

;=== 12:25:59

_camera camPrepareTarget [33980.69,107899.38,-19571.55]

_camera camPreparePos [14190.81,11883.24,106.64]

_camera camPrepareFOV 0.029

_camera camCommitPrepared 0

@camCommitted _camera

Since I do not want to use the camera.sqs (which would mean a detour via a text-file I'd like to avoid) I am looking for a way to obtain the correct data directly. There is a way to do it within Arma, because the camera.sqs delivers.

Anyone out there have any idea?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×