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.

Newcomers DBPro Corner / FPS camera for object moving relative to another object

Author
Message
Davey B
20
Years of Service
User Offline
Joined: 22nd Aug 2004
Location:
Posted: 27th Aug 2010 20:38
Okay this is a bit weird but I'm trying to make the player walk around the inside of a starship. I have the ability to move the ship in x y and z and its working nicely. The difficulty is implementing a camera which will move relative to the starship and allow the player a first person view whilst the ship is moving. So far I have positioned a sphere relative to my ship just to simulate the player and now Im trying to create a free-looking camera using the code below:



Object is the sphere and rotateobj is the starship. I have removed the mmove variables for now as I'm struggling to get them to work as i want. I find that the camera begins spinning when these are used. At the moment the function above works fine but the camera is fixed looking straight ahead. Any ideas how to implement a mouse look FPS camera using relative positioning?

Cheers.
BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 28th Aug 2010 04:27 Edited at: 28th Aug 2010 04:28
Your rotation shouldn't be affected at all by the fact that the starship is moving. Usually I'll use something like this for mouselook:




Latest progress: Fog of War implemented
Davey B
20
Years of Service
User Offline
Joined: 22nd Aug 2004
Location:
Posted: 28th Aug 2010 13:00
Hmmm thanks BMac but thats still not right. Thats fine for simulating standing on the global ZX plane which most FPS will do. But mine needs to account for someone standing on an object undergoing yaw pitch and roll and make it seem like they are still standing up. Hence there is no fixed plane. Thats why I was trying to rotate the camera relative to the starship since in reality the ship wouldn't turn around someone standing inside, the person would turn with the ship...

Its a bit of a head scratcher.
BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 28th Aug 2010 18:05
Ah, I see.

What about creating a hidden object somewhere that rotates with the above code as though it were just walking on level ground, and then adding the angle of this object to the angle of the ship to get the final angle of the camera/player?


Latest progress: Fog of War implemented
Davey B
20
Years of Service
User Offline
Joined: 22nd Aug 2004
Location:
Posted: 28th Aug 2010 19:16
Yeah thats what I'm trying, using a sphere to simulate the player object in relation the the ship. the sphere mimics the ship orientation and will be used for collision later on. The trouble is implementing this mouse look code. I've tried loads of different coding attempts to get this working and so far no joy.
BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 28th Aug 2010 20:19
What I'm suggesting is instead of just using the player object, you have another object somewhere that does not follow the ship's orientation at all. This object only reacts to the mouse movement code, acting as though it were the player on flat ground.

To get the final angles for the actual player collision object/camera on board the ship, you add the angles of this object to the angles of the ship.


Latest progress: Fog of War implemented
Davey B
20
Years of Service
User Offline
Joined: 22nd Aug 2004
Location:
Posted: 29th Aug 2010 01:05
ah i see what your saying. well i tried a different tack and developed this cheap way round the problem. its certainly not elegant, but all it does is translate the ship movement into movement of the camera and finally adds additional camera rotation to allow the mouse look to occur.



the next step is adding movement around the ship but i think im one step closer!
Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 29th Aug 2010 01:08
Quote: "To get the final angles for the actual player collision object/camera on board the ship, you add the angles of this object to the angles of the ship."

the pain in the butt about euler angles is that they don't work like that. Adding or interpolating two euler angles gives very weird looking results.


Is't life, I ask, is't even prudence, to bore thyself and bore thy students?
Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 29th Aug 2010 01:24
voila

press qwe/asd to change the angle of the plane, mouse to look around, and the up and down arrowkeys to move. You'll notice absolutely nothing special, but press the spacekey to view yourself standing on a plane, rotating around.


Is't life, I ask, is't even prudence, to bore thyself and bore thy students?
Davey B
20
Years of Service
User Offline
Joined: 22nd Aug 2004
Location:
Posted: 29th Aug 2010 14:00
Thats awesome! thanks Neuro! I've just gotta integrate that into my game now, but at least I know its possible now
Davey B
20
Years of Service
User Offline
Joined: 22nd Aug 2004
Location:
Posted: 29th Aug 2010 14:31 Edited at: 29th Aug 2010 14:49
Right the code is in and works like a charm! Thanks Neuro.

My only problem is when im moving the player they dont move forward, as you look around they move in a direction other than the one I am facing! Your demo seems to do the same thing, have I missed something there? Cheers.

EDIT: scrub that, just switched sin and cos and everything is working great
Davey B
20
Years of Service
User Offline
Joined: 22nd Aug 2004
Location:
Posted: 29th Aug 2010 19:42
Okay, so trying to implement sparkys collision now, but struggling to put that into the supplied commands. I have tried:


Putting this into my main loop doesn't work, I think this is because the positional calcs are handled within the function used for positioning. Trouble is I'm unsure how to effectively manipulate Neuro's code.... Any ideas? Cheers.
Davey B
20
Years of Service
User Offline
Joined: 22nd Aug 2004
Location:
Posted: 30th Aug 2010 22:34
Any ideas on the collision front anyone?

I'm trying to use the following code, but its just not working for me.



Cheers in advance!
Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 1st Sep 2010 02:08
bleh, sorry, but I can't quite get this to work.

Euler Angles are pretty messy, and dbpro rotation math commands are pretty bad, so one solution would be to get a nice plugin to handle all the dirty stuff for you (EZRotate). The other solution would be to learn all about rotation matrices, like here: http://www.cprogramming.com/tutorial/3d/rotationMatrices.html

You aren't going to be doing many calculations by hand like that, but it's kinda important to understand all what's going on.

Davey B
20
Years of Service
User Offline
Joined: 22nd Aug 2004
Location:
Posted: 1st Sep 2010 23:40
Thanks for trying Neuro. I decided on a different approach in the end. I modeled a static interior of my ship and positioned a plane projecting the camera view of the ship outside onto a texture, locked to the players vision. It gives the illusion of being on a fully rotating ship without the headaches.

Your code will definately be useful though so thanks for helping me out with that.

Login to post a reply

Server time is: 2024-11-24 11:45:12
Your offset time is: 2024-11-24 11:45:12