Rotating camera

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
fakin
Posts: 14
Joined: Wed Jan 24, 2007 9:02 pm
Location: zagreb, croatia

Rotating camera

Post 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.
HondaDarrell
Posts: 20
Joined: Sun Aug 27, 2006 9:10 pm
Location: U.S.A.
Contact:

Post 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.
Ninja Star - 1% Complete | Ninja Assault - 3% Complete | Space Pirate - 10% Complete
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

A camera uses setTarget(...) not setRotation(...) !!!
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
fakin
Posts: 14
Joined: Wed Jan 24, 2007 9:02 pm
Location: zagreb, croatia

Post 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());
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Post Reply