Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Best method to get camera look vector?

Author
Message
Broken_Code
14
Years of Service
User Offline
Joined: 20th Aug 2010
Location: Bremen, Germany
Posted: 14th Nov 2013 19:01
Title says it all! I've been using:



as a placeholder method but now I want something better! Any ideas?

Thanks,
Bruce
Broken_Code
14
Years of Service
User Offline
Joined: 20th Aug 2010
Location: Bremen, Germany
Posted: 14th Nov 2013 19:09


I have actually asked this question before and already got a good answer but I forgot (damn you Memory!), see this thread:

http://forum.thegamecreators.com/?m=forum_view&t=177803&b=1

Sorry!
Sasuke
19
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 15th Nov 2013 09:45 Edited at: 15th Nov 2013 09:46
The fastest I would imagine would be a DLL call to get the view matrix.

The inverse of the view matrix is just as fast a method (I think, it's pretty fast):

Quote: "view matrix4 view
null = inverse matrix4( view, view )

lookx = get matrix4 element(view, 8)
looky = get matrix4 element(view, 9)
lookz = get matrix4 element(view, 10)"


Trig is next (and handy cause you can find the look vector of anything just supplying an angle):

Quote: "look.x = sin(angle.z) * sin(angle.x) + cos(angle.z) * sin(angle.y) * cos(angle.x)
look.y = -cos(angle.z) * sin(angle.x) + sin(angle.z) * sin(angle.y) * cos(angle.x)
look.z = cos(angle.y) * cos(angle.x)"


And the method you posted above is 3 to 4 times slower than the fastest method

EDIT: Just saw the link... damn it!

"Get in the Van!" - Van B

Login to post a reply

Server time is: 2025-05-15 17:16:49
Your offset time is: 2025-05-15 17:16:49