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.
Rotating camera
-
- Posts: 20
- Joined: Sun Aug 27, 2006 9:10 pm
- Location: U.S.A.
- Contact:
A camera uses setTarget(...) not setRotation(...) !!!
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
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...
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());