How do you rotate a vector to face a clicked point. Like in many RPG's when you click on a spot on the ground and your character changes his/her facing toward to clicked spot as he/she moves towards it?
I hope I am making sense.
Rotating toward a clicked point
-
- Posts: 15
- Joined: Fri Oct 09, 2009 2:54 pm
Rotating toward a clicked point
"Mission failed: Your team was wiped out."
I see 2 ways
use virtual ISceneNode * getSceneNodeFromRayBB (const core::line3d< f32 > &ray, s32 idBitMask=0, bool bNoDebugObjects=false, ISceneNode *root=0)=0
PlayerNode->getPosition().rotationToDirection(TargetNode);
2ways is using
getSceneNodeFromScreenCoordinatesBB
then
getCollisionResultPosition
for example only
it`s complicated, but fewer errors
both function-describe you can find here:
http://irrlicht.sourceforge.net/docu/cl ... nager.html
use virtual ISceneNode * getSceneNodeFromRayBB (const core::line3d< f32 > &ray, s32 idBitMask=0, bool bNoDebugObjects=false, ISceneNode *root=0)=0
PlayerNode->getPosition().rotationToDirection(TargetNode);
2ways is using
getSceneNodeFromScreenCoordinatesBB
then
getCollisionResultPosition
for example only
Code: Select all
scene::ISceneManager* smgr = this->device->getSceneManager();
scene::ISceneCollisionManager * scm = smgr->getSceneCollisionManager();
core::line3df = scm->getRayFromScreenCoordinates( this->device->getCursorControl()->getPosition() );
core::vector3df target = scm->getCollisionResultPosition(selector, ...);
//then rotate yours model
PlayerNode->getPosition().rotationToDirection(TargetNode);
both function-describe you can find here:
http://irrlicht.sourceforge.net/docu/cl ... nager.html
from Russia with love )))