rotating camera help
-
- Posts: 8
- Joined: Wed Mar 19, 2008 12:03 pm
rotating camera help
Hi im new to IRRLICHT and im working on a rpg style game. So I need a camera that works like a rpg camera. I have read alot of stuff and searched the api (hard to read the api used to msdn) but just don't get it yet. I don't want someone to give me the code just point me in the right direction. How do i rotate the camera around a fixed point? I want something simular to the maya camera. Any help is appriciated THANKS!
-
- Posts: 1186
- Joined: Fri Dec 29, 2006 12:04 am
Re: rotating camera help
What's an rpg camera?chronos1981 wrote:...works like a rpg camera.
Using spherical coordinates should do the trick.chronos1981 wrote:How do i rotate the camera around a fixed point?
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=17033
Use the for.. er... the search button Luke.
-
- Posts: 8
- Joined: Wed Mar 19, 2008 12:03 pm
Thanks for the quick replys JP and randomMesh
I could simplify the code I know the if statements up, down, lt and rt all do the same thing just had it like this for debugging.
To any one reading this post who is new to c++ when using sin or cos you have to convert you angle in degrees to radians, just multiply degrees by (pi/180), this annoyed me for hours. Hope this helps anyone else.
JP I enjoyed your Avatar Pinhead playing with a rubik's cube, woot.
That's what I thought. I was just hoping for an already existing command, but I figured it out today.Using spherical coordinates should do the trick.
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=17033
Code: Select all
while(device->run())
{
if (fw) //forward
{
hero->setPosition(hero->getPosition()-vector3df(sin(h*(pi/180))*10,0,cos(h*(pi/180))*10));
camera->setPosition(hero->getPosition()+ vector3df( sin(h*(pi/180))*cos(v*(pi/180))*d,sin(v*(pi/180))*d,cos(h*(pi/180))*cos(v*(pi/180))*d ));
camera->setTarget(hero->getPosition());
}
if (lt) //left
{
camera->setPosition(hero->getPosition()+ vector3df( sin(h*(pi/180))*cos(v*(pi/180))*d,sin(v*(pi/180))*d,cos(h*(pi/180))*cos(v*(pi/180))*d ));
camera->setTarget(hero->getPosition());
}
if (rt) //right
{
camera->setPosition(hero->getPosition()+ vector3df( sin(h*(pi/180))*cos(v*(pi/180))*d,sin(v*(pi/180))*d,cos(h*(pi/180))*cos(v*(pi/180))*d ));
camera->setTarget(hero->getPosition());
}
if (down)
{
camera->setPosition(hero->getPosition()+ vector3df( sin(h*(pi/180))*cos(v*(pi/180))*d,sin(v*(pi/180))*d,cos(h*(pi/180))*cos(v*(pi/180))*d ));
camera->setTarget(hero->getPosition());
}
if (up)
{
camera->setPosition(hero->getPosition()+ vector3df( sin(h*(pi/180))*cos(v*(pi/180))*d,sin(v*(pi/180))*d,cos(h*(pi/180))*cos(v*(pi/180))*d ));
camera->setTarget(hero->getPosition());
}
To any one reading this post who is new to c++ when using sin or cos you have to convert you angle in degrees to radians, just multiply degrees by (pi/180), this annoyed me for hours. Hope this helps anyone else.
JP I enjoyed your Avatar Pinhead playing with a rubik's cube, woot.