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.
CameroKid
Posts: 71 Joined: Tue Jul 11, 2006 8:54 pm
Post
by CameroKid » Tue Jun 19, 2007 9:02 pm
Here the code for my 3rd person camera:
Code: Select all
core::vector3df p = node->getPosition();
core::vector3df r = node->getRotation();
camx = r.Y + (MOUSE_X - PREV_MOUSE.X) ;
camy = camy + (MOUSE_Y - PREV_MOUSE.Y) ;
camera->setTarget( core::vector3df( node->getPosition() ) );
camera->setPosition(
core::vector3df(
( cZoom * sin( camx * 3.14/180 ) * cos( camy * 3.14/180 )) + p.X,
( cZoom * sin( camy * 3.14/180 )) + p.Y,
( cZoom * cos( camx * 3.14/180 ) * cos( camy * 3.14/180 )) + p.Z
));
node->setRotation( core::vector3df( 0 , camx, 0 ) );
It works just fine (on my comp anyway). My problem is this code treats the y axis as the floor to ceiling axis. I need the z axis to be the floor to ceiling axis. The code and my modeler program don't agree. Can someone help me out?
GuerillaSoftworks
Posts: 83 Joined: Wed May 23, 2007 6:11 pm
Post
by GuerillaSoftworks » Tue Jun 19, 2007 9:11 pm
Hi.
Try rearranging the calculations for your vector values. I'm thinking...
Code: Select all
camera->setPosition(
core::vector3df(
( cZoom * sin( camx * 3.14/180 ) * cos( camy * 3.14/180 )) + p.X,
( cZoom * sin( camy * 3.14/180 )) + p.Z,
( cZoom * cos( camx * 3.14/180 ) * cos( camy * 3.14/180 )) + p.Y
));
might work.
If not try something else along those lines.
oldskoolPunk
Posts: 199 Joined: Wed Nov 29, 2006 4:07 am
Post
by oldskoolPunk » Wed Jun 20, 2007 4:19 am
CameroKid
I use Blender, which (opposite of every other 3d app and API I have ever used) uses the Z coordinate for up/down instead of the Y coord.
I think most people just rotate everything 90 degrees on the X axis before exporting.
Signature? I ain't signin nuthin!