Camera Black & White style?

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!
Post Reply
Sergio Cossa
Posts: 22
Joined: Fri Jun 03, 2005 2:00 pm
Location: Argentina

Camera Black & White style?

Post by Sergio Cossa »

Hi!

Can somebody indicate me a link to code sample of how to create a camera to the style of Black & White?

I am new in Irrlicht and I have test some tutorials, but I don't achieve the same functionality :(

Thank you in advance!!
Sergio Cossa
Argentina
Sergio Cossa
Posts: 22
Joined: Fri Jun 03, 2005 2:00 pm
Location: Argentina

Post by Sergio Cossa »

I will be more exact, to see if I get a help:

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)

Any help please?
Sergio Cossa
Argentina
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

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.
Image
Sergio Cossa
Posts: 22
Joined: Fri Jun 03, 2005 2:00 pm
Location: Argentina

Post by Sergio Cossa »

Thank you Spintz!

I will try to implement your suggestion.

All the best!
Sergio Cossa
Argentina
Sergio Cossa
Posts: 22
Joined: Fri Jun 03, 2005 2:00 pm
Location: Argentina

Post by Sergio Cossa »

Spintz,

If I implemented it correctly, with that process my camera is fixed in the center and tour on its own axis.

I need the inverse process, that is to say that an object is fixed in the center of the screen and my camera rotates around...

Perhaps be this a basic concept, but I cannot solve it. :(

All the best.
Sergio Cossa
Argentina
Xico
Posts: 30
Joined: Sun Jun 05, 2005 5:08 pm
Location: Buenos Aires, Argentina
Contact:

Post by Xico »

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)

------------------------
translation:
hi sergio, maybe this help: a thread about a related problem: nodes orbiting and facing other nodes:
http://irrlicht.sourceforge.net/phpBB2/ ... php?t=7617
Nova
Competition winner
Posts: 99
Joined: Mon May 09, 2005 10:32 am

Post by Nova »

i'd try some mathematics for your camera position...
something like this (not sure if it'll work, just a shot...)

Code: Select all

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*

hope this helps anyway
Sergio Cossa
Posts: 22
Joined: Fri Jun 03, 2005 2:00 pm
Location: Argentina

Post by Sergio Cossa »

Hi!

Thank you to all.

I was reading all the suggestions and trying to adapt them to my code.

I also found an old one post on the topic:

http://irrlicht.sourceforge.net/phpBB2/ ... php?t=3245

Working is already almost, although they lack adjustments. When it is finished I will show in a post for people that uses Irrlicht with C#

Thanks again. All the best!
Sergio Cossa
Argentina
Guest

Post by Guest »

you could use the built in animator:

Code: Select all

scene::ISceneNodeAnimator* anim = smgr->createFlyCircleAnimator core::vector3df(0,0,30), 20.0f);
where vector3df is the position of your node and 20.0f is how far away the camera is.

hope this helps
evo
Posts: 96
Joined: Mon Jun 27, 2005 6:46 pm
Location: The Netherlands

Post by evo »

Isn't this the same type of problem:

http://irrlicht.sourceforge.net/phpBB2/ ... php?t=8360

Maybe it helps you.
Post Reply