
I'm trying to create a first person camera and find out that I don't understand the Pivot Point in Balder. It's supposed to be the rotation center, isn't it ? The fact is whenever I assign a pivot point to my object, that object translates in a...uh....reverse
direction (example: I have an object at (0,0,0), then I set its pivot to (a,b,c) and the object automatically moves to (a,b,c) , that doesn't make any sense)
Can anyone help me on this ?



Anyone? Now I have to fake the 1st person camera by holding the camera in the origin and rotating the scene around it



Hi,
sorry for the delayed answer on this  busy days.
I'm not quite sure if I understand what you're asking.
The pivot point represents the center point of the object. That means, moving the center point around will have the effect you're saying. Lets say you have a box that is 5,5,5 in size. The default pivot point is 0,0,0  dead center of the box. If we move the
pivot point to 5,5,5  the center point will be the inner top right point, so that object will rotate around that point.
The part of your question I didn't quite get, is that you're subject is firstperson camera, I don't see how the two things are related. Please enlighten me.. :)



Oh, sorry for the ambiguity, my objective is to create a first person camera. The camera class has no Rotation property so at first I thought I couldn't rotate the camera and I had to fake the camera rotation by rotating the scene around it. Then the subobjective
is how to rotate the scene around a specific axis, this is surely related to Pivot Point and as I said I don't fully understand the Pivot Point (why changing the Pivot also change the object Position ???).
Fortunately, I finally figure out a way to rotate the camera that doesn't concern with the Pivot: rotate the Forward vector then update the new Camera Target.



Great to hear you figured it out.
Maybe I should create a sample for this case, I'd think its a rather common question.



Riaria,
I’d be interested in seeing how you pulled off a first person camera. I’ve done this too but I’m not very happy with my solution. As the user looks around I modify the cameras target, and if they move, say forward, I modify the camera position
and target. This does work, but it seems the position of the camera and the target could get out of sync when I start putting in collision detection.
Far better would be to have the camera position and a matrix, and be able to derive the target at any time. Any thoughts?



Unfortunately, my method is the same as yours, xersoft, calculate the new position and target when moving, rotate the forward/up vector for looking around.


Nov 23, 2010 at 3:04 AM
Edited Nov 23, 2010 at 3:07 AM

Here is something I've been toying around with, though it does not work very well yet. This is based on the Quaternion work posted in this fourm.
Keep track of AngleX and AngleY outside of the mouse move event. Then use this code for the mouse move. Anythoughts on how I'm using these magical Quaternions incorrectly? :) Honestly they are magic, I'm sure of it.
Being able to find the target with just the angles and the current camera position would be great, but perhaps I'm looking at this all wrong? How is this sort of mouse look normally handled in 3d games?
double AngleX = 0;
double AngleY = 0;
void Game_MouseMove(object sender, MouseEventArgs e)
{
var Cam = Game.Camera;
var NewMousePostion = e.GetPosition(Game);
AngleY += (LastMousePosition.Y  NewMousePostion.Y) * .01;
AngleX += (LastMousePosition.X  NewMousePostion.X) * .01;
var xQuaternion = new Quaternion(new Balder.Math.Vector(1, 0, 0), AngleX);
var YQuaternion = new Quaternion(new Balder.Math.Vector(0, 1, 0), AngleY);
var fMatrix = (YQuaternion * xQuaternion).ToMatrix();
var Look = new Balder.Math.Vector(0, 0, 1);
Cam.Target = (Cam.Position.ToVector() * fMatrix) + Look;
LastMousePosition = NewMousePostion;
}



Here is my latest that seems to be working... except the up/down looking is rough. It's odd that one axis would be smooth and the other rough.
var Cam = Game.Camera;
var NewMousePostion = e.GetPosition(Game);
AngleY += (LastMousePosition.Y  NewMousePostion.Y) * .05;
AngleX += (LastMousePosition.X  NewMousePostion.X) * .05;
var xQuaternion = new Quaternion(new Balder.Math.Vector(1, 0, 0), AngleY);
var YQuaternion = new Quaternion(new Balder.Math.Vector(0, 1, 0), AngleX);
// I needed to apply the Quaternion to the unit vector!
var fMatrix = (xQuaternion * YQuaternion).ToMatrix();
var Look = new Balder.Math.Vector(0, 0, 1);
Cam.Target = (Look * fMatrix) + Cam.Position.ToVector();



I was able to make the above code usable by doing this:
var Look = new Balder.Math.Vector(0, 0, 100);
But it is still not perfect... When moving and turning, say if you want to orbit something the camera is jittery. Perhaps I should try 1000?

