Hi everybody, new to the board and hoping someone can help! lol
Since i finished my computer games degree, i've been working on creating a simple 3d engine in Flash of all things. So far everything is going ok, it will render polygons, perform backface culling, has a cutoff point for rendering (to prevent showing objects behind the camera) and has basic first person camera controls.
At current, the camera's movement is faked somewhat. When the user "moves" the coordinates of each vertices are updated with the amount of movement in each direction.
The camera so far will move forwards backwards, strafe and let the user turn left and right. The issue i'm having is with looking up and down.
When I rotate the current map (although map is a very loose term!) along the X axis to simulate up and down viewing, it does not rotate correctly when pressing left and right. I've uploaded the applet to a web address
Theres a debug menu on the top left of the applet but it's pretty irellevant lol. The controls are pretty normal, wasd for movement and arrows for looking. Try looking up or down then left or right and you'll see my problem.
Here's a snippet of code i'm using to deal with point rotation
var angleY:Number = spinVelX * .001;
var cosY:Number = Math.cos(angleY);
var sinY:Number = Math.sin(angleY);
var angleX:Number = spinVelY * .001;
var cosX:Number = Math.cos(angleX);
var sinX:Number = Math.sin(angleX);
var z1:Number = point.z * cosY + point.x * sinY;
var y1:Number = point.y * cosX - z1 * sinX;
var x1:Number = point.x * cosY - point.z * sinY;
var z2:Number = z1 * cosX + point.y * sinX;
If anybody has got any ideas i'd be incredibly grateful to hear them, this has been bugging me for quite some time now and it's driving me mad!