Implementing scroll in 3d engine
Implementing scroll in 3d engine
I want to simulate isometric engines in 3d. I know how to rotate the map by using trigonometric functions. Now I want to know how to determine the correct axis to modify to simulate map scroll up/down/left/right, like the UFO Alien Invasion engine. Can somebody give me an idea?
ru guo ni yao ai, ni jiang bu hui shi qu
Obviously. Try to do it when you are rotating the map at the same time and see what you get: possibly you will scroll up when should be scrolling left.
What I want to know is how to calculate the correct movement for the camera, supposing I have rotated the map.
What I want to know is how to calculate the correct movement for the camera, supposing I have rotated the map.
ru guo ni yao ai, ni jiang bu hui shi qu
This is what I got in another forum:
You'll need a vector that points straight into the scene (direction vector) to move forwards and backwards, and you'll need either a vector that points left or right (a leftVector or a rightVector). A leftVector is not a vector in the negative x direction, a rightVector is not a vector pointing in the positive direction and a direction vector is not one that points down the z axis.
To calculate the direction vector you'll need a point that the map is at (the currentPosition of the map), and any point that is straight down the scene (this will be your lookAt point), then subtract lookAt from currentPosition and you'll have your direction vector which you then should normalize.
To get the right vector, you take the cross product between the up vector and the direction vector and then you'll have the right vector.
now to move left (using the right vector) you set an amountToMove variable that will say how much to move right. You then
// CurrentPos is the position of the map.
currentPosition.x += mvXZAxis.x * amountToMove;
currentPosition.z += mvXZAxis.z * amountToMove;
If you want to move left you just negate the amountToMove variable.
Can somebody help me to translate this to Irrlicht?
You'll need a vector that points straight into the scene (direction vector) to move forwards and backwards, and you'll need either a vector that points left or right (a leftVector or a rightVector). A leftVector is not a vector in the negative x direction, a rightVector is not a vector pointing in the positive direction and a direction vector is not one that points down the z axis.
To calculate the direction vector you'll need a point that the map is at (the currentPosition of the map), and any point that is straight down the scene (this will be your lookAt point), then subtract lookAt from currentPosition and you'll have your direction vector which you then should normalize.
To get the right vector, you take the cross product between the up vector and the direction vector and then you'll have the right vector.
now to move left (using the right vector) you set an amountToMove variable that will say how much to move right. You then
// CurrentPos is the position of the map.
currentPosition.x += mvXZAxis.x * amountToMove;
currentPosition.z += mvXZAxis.z * amountToMove;
If you want to move left you just negate the amountToMove variable.
Can somebody help me to translate this to Irrlicht?
ru guo ni yao ai, ni jiang bu hui shi qu