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.

Dark GDK / LookAt Vector

Author
Message
aersixb9
16
Years of Service
User Offline
Joined: 29th Nov 2007
Location:
Posted: 10th Dec 2007 00:28
How do I get a lookAt vector from a camera? I can get the camera's 3 angles (in degrees)...how do I convert this into a (unit) vector pointed in the right direction? Do I need EZRotate to do this? Will EZRotate do this? Or is there a way to do this for free?
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 10th Dec 2007 01:05
vec.x = dbSin( ang.y ) * dbCos( ang.x );
vec.y = - dbCos( ang.x );
vec.z = dbCos( ang.y ) * dbCos( ang.x );

"It's like floating a boat on a liquid that I don't know, but I'm quite happy to drink it if I'm thirsty enough" - Me being a good programmer but sucking at computers
aersixb9
16
Years of Service
User Offline
Joined: 29th Nov 2007
Location:
Posted: 10th Dec 2007 01:44
It doesn't work...here's the code...the ship still doesn't accelerate right...did I type something in wrong?

Morcilla
21
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 10th Dec 2007 11:36
I think you should use the 'dbPickScreen' function... It generates that vector.
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 10th Dec 2007 16:14
Oops, the Y vector should be -sbSin( ang.x ), my bad

"It's like floating a boat on a liquid that I don't know, but I'm quite happy to drink it if I'm thirsty enough" - Me being a good programmer but sucking at computers
aersixb9
16
Years of Service
User Offline
Joined: 29th Nov 2007
Location:
Posted: 10th Dec 2007 16:49
Well, I tried replacing the Y vector with -dbSin(xang), but that didn't work either...so I tried using dbPickScreen and dbGetPickVectorX-Z, and it works like a charm! I love you both. Here's a haiku dedicated to spatial gaming in dark GDK:

Flying between the
Planets earth and Moon for fun
you forum guys are great!

Anyways, here's the final, working code, if it's of use to anyone!



You can use this code for a newtonian physics based solar system simulator! Just load up models for earth, sun, and moon, initialize x,y,z,xvel,yvel,zvel, and acceleration to reasonable values, and start playing!
The Mayflower
16
Years of Service
User Offline
Joined: 17th Dec 2007
Location: Plymouth, Massachusetts
Posted: 18th Dec 2007 00:54
Erm....

dbPointCamera()

DOH!

Login to post a reply

Server time is: 2024-11-19 20:40:27
Your offset time is: 2024-11-19 20:40:27