Page 1 of 1

Rotating camera

Posted: Sun Feb 18, 2007 9:31 pm
by fakin
hi.

i know there's a lot of post on this probably but i haven't been able to find it among all those, so if anyone can help on this particular problem...

i want to rotate the camera around a point [let's assume it's a box] but not by attaching point as the camera parent and then rotating the point.

thanks.

Posted: Sun Feb 18, 2007 11:49 pm
by HondaDarrell
I'm not sure what you mean.
Maybe something like maya camera scenenode could help.

I'm having a problem with the camera also. I'm trying to rotate the camera as if it were a space ship. But it always aims at world center and does'nt rotate with setRotation.

Posted: Mon Feb 19, 2007 12:27 am
by Acki
A camera uses setTarget(...) not setRotation(...) !!!

Posted: Mon Feb 19, 2007 12:35 am
by fakin
well i thought it's a simple question... anyway...

assume there's a box at the center of the screen.
also assume there's a camera looking at that box from some distance. now, what I want is when I press, for example 'KEY_KEY_N' that camera to rotate around the box at the same distance, which mean to rotate camera around Y axis, but not to rotate the box...
anyway, I got this solved.

there's another question...
now it's rotating at light speed, how to set it up so it rotates at some normal speed...
any help would be appreciated....

thanks...

and yes, this is the code I use...

Code: Select all

      vector3df cpos = camera->getAbsolutePosition();
		vector3df npos = node->getAbsolutePosition();
		vector3df dist = cpos - npos;
		const float f = 275.0;  // this is just for the Y of the camera position
		//-----------------------------
		f32 dx = dist.X;
		f32 dy = 0.0f;
		f32 dz = dist.Z;
		//------------------------------
		f32 cx = cpos.X;
		f32 cy = cpos.Y;
		f32 cz = cpos.Z;
		//---------------
		f32 nx = cos(0.0002f *dx) + sin(0.0002f * cz);
		f32 ny = cy;
		f32 nz = -sin(0.0002f*dx) + cos(0.0002f * cz);
		//------------------------------------------
		vector3df newpos = vector3df(dx+nx, f, dz+nz);
		camera->setPosition(newpos);
		camera->updateAbsolutePosition();
		camera->setTarget(node->getAbsolutePosition());

Posted: Mon Feb 19, 2007 3:48 pm
by vitek