You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers. No questions about C++ programming or topics which are answered in the tutorials!
I adapted several tutorials to make camera movements. A common camera, non FPS.
For example, I can make that the camera rotates around my in center, move, ascend, lower, bring near or move away.
But, how can I make that the camera rotates around an object that is located in the center of the screen?
For example, if I have a person in the center of the screen... how can I manage the camera so that it rotates around to its?
It would be as if I walked in circles around this person, I would observe it from all the angles, and of course, I would also see how goes rotating the background (skybox)
Rotate the vector with the camera's position around the nodes position. What you do, is subtract the position of the target from the position of the camera, do get the position of the camera relative to the target in world space. Then rotate the camera however you want, and when you're done, add the position of the target back to the cameras new rotated position.
Hola Sergio, no tengo una solución concreta al problema, pero tal vez esto te ayude, es un thread que inicié hace un tiempo hablando de un problema similar: nodos que orbitan a otros, y se orientan de determinada forma: http://irrlicht.sourceforge.net/phpBB2/ ... php?t=7617
espero ayude en algo
saludos
Xico (Francisco Lemos)
f32 distance = 30.0f; //Distance from the camera to the target
f32 height = 10.0f; //Height of the camera
f32 angle = 0.0f; //The angle from which the camera looks onto the target
//Ok now some explanation of my idea
//A distance between two points in 3d space is calculated as follows
//x²+y²+z²=distance²
//we have y - which is the height - and we have the distance - which is set by us
//because we have the height and we don't care if it is in our distance calculation or not (which makes this a whole lot easier), we only use the distance for the 2d offset of the camera in the X-Z Plane (see the ascii drawing for explanation)
//this reduces our formula to good ol' pythagoras:
//x²+z²=distance²
//This is some crappy ascii drawing
// (camera)
// o
// /|
// / |
// / | sin(angle) [newX in our example]
// / |
// / |
//(target) o------
// cos(angle) [newZ in our example]
//now we want to rotate the camera around the target, therefore we calculate the relative x and z values by using sine and cosine and add them, along with the height, to the target position
f32 newX = sin(angle)*distance;
f32 newZ = cos(angle)*distance;
core::vector3df camerapos = core::vector3df(newX,height,newZ);
target = <some core::vector3df>;
camera->setPosition(camerapos+target);
that should do the trick, but I am not quite sure if this works the way it should
I havn't tested it and it's darn late over here in germany and i don't want to come up for any miscalculations *g*