can someone help me alter my camera code?

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
CameroKid
Posts: 71
Joined: Tue Jul 11, 2006 8:54 pm

can someone help me alter my camera code?

Post by CameroKid »

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 »

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.
Guerilla Softworks

New Guerilla Softworks website under construction - http://guerillasoftworks.awardspace.com
oldskoolPunk
Posts: 199
Joined: Wed Nov 29, 2006 4:07 am

Post by oldskoolPunk »

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!
CameroKid
Posts: 71
Joined: Tue Jul 11, 2006 8:54 pm

Post by CameroKid »

I fixed it. Thanks
GuerillaSoftworks
Posts: 83
Joined: Wed May 23, 2007 6:11 pm

Post by GuerillaSoftworks »

What did you do to fix it then?
Guerilla Softworks

New Guerilla Softworks website under construction - http://guerillasoftworks.awardspace.com
Post Reply