Implementing scroll in 3d engine

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
rogerdv
Posts: 93
Joined: Wed Aug 27, 2003 4:20 pm

Implementing scroll in 3d engine

Post by rogerdv »

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
disanti
Posts: 367
Joined: Sat Jan 17, 2004 1:36 am
Location: California, US
Contact:

Post by disanti »

You have to move the camera and the target of the camera to scroll.
________
BABIMAC
Last edited by disanti on Tue Feb 22, 2011 8:08 am, edited 1 time in total.
rogerdv
Posts: 93
Joined: Wed Aug 27, 2003 4:20 pm

Post by rogerdv »

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.
ru guo ni yao ai, ni jiang bu hui shi qu
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Post by Tyn »

You move diagonally of cause :) Why do you need to rotate the map using trig? I'd just do it by 45 degrees.
rogerdv
Posts: 93
Joined: Wed Aug 27, 2003 4:20 pm

Post by rogerdv »

Interesting idea. I just wanted to achieve a Neverwitner Nights like engine, so you can rotate (move the camera in a circular trajectory around a fixed target) and view the map from any point of view. I think that rotation+map scroll makes the best for RPG.
ru guo ni yao ai, ni jiang bu hui shi qu
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Post by Tyn »

You would need some clever math in there to handle which way to move in accordance to the rotation.
rogerdv
Posts: 93
Joined: Wed Aug 27, 2003 4:20 pm

Post by rogerdv »

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?
ru guo ni yao ai, ni jiang bu hui shi qu
Post Reply