about fps camera
about fps camera
hi. i have noticed that in the fpscamerascenenode, it's plane is always horizontal. is there any way to change this ? I want this because im trying to "walk" on a "planet" but if i go below the equator, i can't rotate the camera down, because it's already more than 90 degrees. In other words, what i want is having the plane of the camera, always perpendicular to the vector camera->getPosition(). can i make this with the fpscamera or i must code a custom one ?
-
- Posts: 1638
- Joined: Mon Apr 30, 2007 3:24 am
- Location: Montreal, CANADA
- Contact:
If you want to do this, you will have to create your own camera controller.
All camera can use a UPvector. So you define the angle and put the UPvector and the camera will be aligned to it. It will be relatively easy to make that. But the mouse movement are not following the upvector.
A better alternative (as Shogun talked about)would be create a empty node then use it as a parent for the whole scene and rotate it on the direction needed. The camera and player would need NOT be parented to this empty node for this to work.
All camera can use a UPvector. So you define the angle and put the UPvector and the camera will be aligned to it. It will be relatively easy to make that. But the mouse movement are not following the upvector.
A better alternative (as Shogun talked about)would be create a empty node then use it as a parent for the whole scene and rotate it on the direction needed. The camera and player would need NOT be parented to this empty node for this to work.
wouldn't this approach be very expensive ? imagine thousands of objects needed to be rotated. plus, that if i need a multiplayer game, this is not a good solution i think.christianclavet wrote:If you want to do this, you will have to create your own camera controller.
All camera can use a UPvector. So you define the angle and put the UPvector and the camera will be aligned to it. It will be relatively easy to make that. But the mouse movement are not following the upvector.
A better alternative (as Shogun talked about)would be create a empty node then use it as a parent for the whole scene and rotate it on the direction needed. The camera and player would need NOT be parented to this empty node for this to work.
p.s. where can i look about the upvector ? the irrlicht help file doesnt seem to have a reference on this.
-
- Posts: 1638
- Joined: Mon Apr 30, 2007 3:24 am
- Location: Montreal, CANADA
- Contact:
All the items will rotate anyway in the camera. So I think it would be about the same. (It would be calculated for change only on the parent and not the childrens (that have their own local coordinate system). It shoulnt be calculated twice.
Unless there some culling algorithm in there that does this (frustum culling).
Unless there some culling algorithm in there that does this (frustum culling).
Last edited by christianclavet on Thu Dec 20, 2007 5:41 am, edited 1 time in total.
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
If you're actually writing a game rather than a simple disposable demo, do yourself a favour and forget about the built in cameras, and for that matter the Irrlicht event system. They're only really suitable for demos, and you'll spend more time trying to work around them than you will writing something that's actually suitable for your requirements. IMO.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
I think this has already been covered but I just wanted to clarify that the up-vector is not handled by the fpscamera to suit your needs.
I played around with it a bit and it looks like moving your mouse up rotates the camera in the original "up" direction (what would now be "left" or something).
You might just copy the CCameraFPSSceneNode class and change the Animate function to factor the up-vector into the calculations. I'm not really sure how to do it but I'm pretty sure that's where you start.
I played around with it a bit and it looks like moving your mouse up rotates the camera in the original "up" direction (what would now be "left" or something).
You might just copy the CCameraFPSSceneNode class and change the Animate function to factor the up-vector into the calculations. I'm not really sure how to do it but I'm pretty sure that's where you start.
-
- Posts: 1638
- Joined: Mon Apr 30, 2007 3:24 am
- Location: Montreal, CANADA
- Contact:
mqrk You are talking about the source of the FPS camera. And it surely cannot be used like that (I know. I had to retake and adapt the code so it can work.) For the UPVector, you are wrong. This is a feature on all cameras (Normal since it was created for the standard camera and that the other camera inherit the STD Camera class.
For example, to reverse the camera view upside down:
This should take your camera view and have it upside down (For Any camera definition you have (FPSCamera, MayaCamera, or STD camera)
You should move the right way, but the mouse rotation will be inverted.
What he has to do is to take the CCamera source as a reference point(or download my current code for the FIRST KING), and do some math so that mouse movements will rotate the camera the right way.
The moving part is accounted for, in the source, it's using the UpVector of the camera for the calcultation (Strafing), it should "strafe" the right way. It's only have to do some calculations of the mouse move increment of the relative rotation of the camera relative to the UPvector. So the relative movement is going the right way.
So you could take my current code for FIRST KING project and take the part of the camera and implement this (Align the upvector of the camera with the relative rotation based on the mouse movement). Or do what we suggested previously. If you are very strong in math, physic and expert at programming, I would recommend the same thing that proposed RogerBorg.
But starting up with IRRlicht could also be good, if you need a prototype fast for a "proof of concept".
For example, to reverse the camera view upside down:
Code: Select all
camera->setUpVector(vector3DF(0,-1,0));
You should move the right way, but the mouse rotation will be inverted.
What he has to do is to take the CCamera source as a reference point(or download my current code for the FIRST KING), and do some math so that mouse movements will rotate the camera the right way.
The moving part is accounted for, in the source, it's using the UpVector of the camera for the calcultation (Strafing), it should "strafe" the right way. It's only have to do some calculations of the mouse move increment of the relative rotation of the camera relative to the UPvector. So the relative movement is going the right way.
So you could take my current code for FIRST KING project and take the part of the camera and implement this (Align the upvector of the camera with the relative rotation based on the mouse movement). Or do what we suggested previously. If you are very strong in math, physic and expert at programming, I would recommend the same thing that proposed RogerBorg.
But starting up with IRRlicht could also be good, if you need a prototype fast for a "proof of concept".
thanks for your reply christian and mqrk.
my first step was using
this assuming that the center is (0,0,0) updates the upvector to be perpendicular to the plane that is tangent with the planet in the intersection point of the line (0,0,0-x,y,z) with the planet.
( or simply put, aligns the upvector with the (0,0,0-x,y,z) vector ).
but as you previously also said i have to tweak the fpscamera code for the mouse movement ( it doesn't work correctly, doesn't update ). i will look also your code ( the first king ) and post in this topic any good results.
@roger, im still on my initial steps though but yes you are right.
i hope my studying maths will help me on this
my first step was using
Code: Select all
camera->setUpVector(core::vector3df(loc.X, loc.Y, loc.Z));
( or simply put, aligns the upvector with the (0,0,0-x,y,z) vector ).
but as you previously also said i have to tweak the fpscamera code for the mouse movement ( it doesn't work correctly, doesn't update ). i will look also your code ( the first king ) and post in this topic any good results.
@roger, im still on my initial steps though but yes you are right.
i hope my studying maths will help me on this
i think i have found a workaround about this issue.
from CCameraFPSSceneNode.cpp :
if that is changed to some huge value like 3600000.0f then it will solve the problem.
( needs recompile i think )
from CCameraFPSSceneNode.cpp :
Code: Select all
const f32 MAX_VERTICAL_ANGLE = 88.0f;
( needs recompile i think )