Transforming a 3D point to a 2D point

No, it wasn't, but it didn't mean to be one either. It was just a quadrilateral.Yes, that's it, setting alpha to 90 degree (ez=1.0) fixed the disortion. Thank you.Yes, currently i need square pixels, thanks for pointing out.

Currently i have but one last question about the camera's movement: how can it move "forward"? Moving it along the axes is obvious, but moving towards that way where it is pointing is not. How can i calculate the "next" coordinate out of the camera's position, angle and a step interval?
The camera is at point A and you want to move towards point B. You'll be moving along the line that connects these points. Can you write its equation? How about parametric form, so you can increment a single parameter for each step?
 
While i've never written Bresenham neither for 3D nor with floating point values, i think i could do that, if i would know where point B is; i need the target coordinates to do Bresenham. And with that, i'm at the beginning again: how can i choose any point of that particular imaginary line, having only the camera's position and angle?
 
While i've never written Bresenham neither for 3D nor with floating point values, i think i could do that, if i would know where point B is; i need the target coordinates to do Bresenham. And with that, i'm at the beginning again: how can i choose any point of that particular imaginary line, having only the camera's position and angle?
Camera angles determine the direction it's pointing at. This direction vector along with the camera location define the line along which you want to move.

Just make sure the vector and the point are in the same coordinates.
 
I did not understood much from this article. I cannot make up my forumula for the new camera coordinates out of these calculations.
However after some thinking and experimenting i managed to figure out the algorithm for coordinate Z: it's (cos(thy) - sin(thx)) * step Since theta Z is not affecting the moving direction, only the view; only theta X and Y can be used for any coordinate. Currently i have this function:
C:
void StepCamera(Camera *C, float step)
{
    C->x += (0) * step;
    C->y += (0) * step;
    C->z += (C->cy - C->sx) * step;
}
But i could not manage to find the formula for the new X and Y. Z works. Or at least i think so. It seems to.
 
To move the camera around in the direction you're looking, like you would in a flying game, then you need the inverse of that rotation matrix you've already coded. For a rotation matrix, the inverse is just the "transpose matrix".

This results in the following function that you can call...
C:
void CameraMove(Camera *C, float x, float y, float z) {
    C->x += x*(C->cy*C->cz) + y*(C->sx*C->sy*C->cz* - C->cx*C->sz) + z*(C->cx*C->sy*C->cz + C->sx*C->sz);
    C->y += x*(C->cy*C->sz) + y*(C->sx*C->sy*C->sz + C->cx*C->cz) + z*(C->cx*C->sy*C->sz - C->sx*C->cz);
    C->z += x*(-C->sy) + y*(C->sx*C->cy) + z*(C->cx*C->cy);
}

Calling like this will move the camera forward:- CameraMove(&C, 0, 0, 0.2);
Calling like this will strafe/ side-step left:- CameraMove(&C, -0.2, 0, 0);
I'm sure you can work out how to move up/down!

I anticipate that your next question will probably be how do I get the camera to rotate in a consistent way, so that the numpad '-+' controls always twist the camera even when the camera is pointing 90° left. This would be more complex to answer.
 
To move the camera around in the direction you're looking, like you would in a flying game, then you need the inverse of that rotation matrix you've already coded. For a rotation matrix, the inverse is just the "transpose matrix".

This results in the following function that you can call...
C:
void CameraMove(Camera *C, float x, float y, float z) {
    C->x += x*(C->cy*C->cz) + y*(C->sx*C->sy*C->cz* - C->cx*C->sz) + z*(C->cx*C->sy*C->cz + C->sx*C->sz);
    C->y += x*(C->cy*C->sz) + y*(C->sx*C->sy*C->sz + C->cx*C->cz) + z*(C->cx*C->sy*C->sz - C->sx*C->cz);
    C->z += x*(-C->sy) + y*(C->sx*C->cy) + z*(C->cx*C->cy);
}

Calling like this will move the camera forward:- CameraMove(&C, 0, 0, 0.2);
Calling like this will strafe/ side-step left:- CameraMove(&C, -0.2, 0, 0);
I'm sure you can work out how to move up/down!
Thank you, this is working perfectly.
I anticipate that your next question will probably be how do I get the camera to rotate in a consistent way, so that the numpad '-+' controls always twist the camera even when the camera is pointing 90° left. This would be more complex to answer.
No, i don't have any problems with the camera's angles, or at least i did not noticed any. Here is the current version: http://oscomp.hu/depot/dtest_1.zip
Can you please check, if this problem affects it?

Controls have been altered a bit:
- Cursor up: forward
- Cursor down: backward
- Cursor left: turn left
- Cursor right: turn right
- Alt + Cursor left: sidestep left
- Alt + Cursor right: sidestep right
- Numpad 8: Look down
- Numpad 2: Look up
- Numpad 4: Twist to the left
- Numpad 6: Twist to the right.
- Numpad -: Arise
- Numpad +: Sink
- Escape: Quit
 
Top