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 / Camera

Author
Message
Jna99
18
Years of Service
User Offline
Joined: 3rd Nov 2005
Location: Portugal
Posted: 10th Nov 2005 19:27
Hi people I'm doing a 3d space simulator, so I've manage to put the camera behind the ship independant of where she moves, but my function only works perfectly if the camera if centered with the ship. So I started by making the camera look a little up or moved the ship further down, but when I do a looping (move on the YZ plane) the ship goes up and down instead of being always down, see the pics if you don't understand!

For the second Image I altered camera position to:
dbPositionCamera(x+dbObjectPositionX(1),y+dbObjectPositionY(1)+.5,z+dbObjectPositionZ(1));

Attachments

Login to view attachments
Jna99
18
Years of Service
User Offline
Joined: 3rd Nov 2005
Location: Portugal
Posted: 11th Nov 2005 00:50
Sorry people I didn't post the code, my fault!

Miguel Melo
18
Years of Service
User Offline
Joined: 8th Aug 2005
Location:
Posted: 11th Nov 2005 10:48
As a quick guess, I suspect that you need to add to the camera position not a fixed Y value, but a multiple of the current ship UP vector. This, however is not something you can obtain directy in dgskd (because it works with euler angles and not matrices).

I'd say work out the fwd vector from the euler, then cross product with the fake up (0,1,0) to find the right vector, then cross product right x fwd to find the real up vector. Then change the cam position to



Com que então Portugal, eh? Aonde é que estás Jna99?
Jna99
18
Years of Service
User Offline
Joined: 3rd Nov 2005
Location: Portugal
Posted: 11th Nov 2005 12:16
Hmmm can you give me an example it's a bit confusing without examples, expecially when I not using vectors directly, only 3d coords like in the posted code.

Lisboa tb
Miguel Melo
18
Years of Service
User Offline
Joined: 8th Aug 2005
Location:
Posted: 11th Nov 2005 16:45 Edited at: 11th Nov 2005 16:46
Use the functions dbObjectAngleX(), dbObjectAngleY() and dbObjectAngleZ() and do a similar math to what you have in moveCamera() - you'll get the forward vector. I just realised that the fake up on my procedure needs to be EITHER (0,1,0) or (0,-1,0) depending on the "top part" of the ship being facing up or down (in a loop). These cross product maths I suggested will also break if your ship is ever pointing straight up or down... hmm...

One way around this is to ignore all that I suggested (the vector maths approach) and maintain an up vector that also gets rotated when you move the joystick, much like you do for the camera angles. you would start with something like



rotate these values as you do the camAngle* values and in movecamera, do a similar calculation you do for x,y & z for this new vector and then add these x', y' and z' in the dbPositionCamera() call too.

I'm typing this from the top of my head, so standard disclaimers apply...
Jna99
18
Years of Service
User Offline
Joined: 3rd Nov 2005
Location: Portugal
Posted: 14th Nov 2005 00:49
Ok Miguel I'll try that thanks

Login to post a reply

Server time is: 2024-03-29 15:09:48
Your offset time is: 2024-03-29 15:09:48