相当自我解释。我希望能够在Irrlicht中更改FPS相机的键绑定。我知道如何在创建相机时更改键绑定,但在此之后我无法找到方法。谁知道怎么做?
答案 0 :(得分:1)
一种可能性是从普通的相机节点开始,然后附加一个SceneNodeAnimatorCameraFPS
irr::scene::ICameraSceneNode* camera;
irr::scene::ISceneNodeAnimatorCameraFPS* ca;
camera = _smngr->addCameraSceneNode();
irr::core::array<irr::SKeyMap> keyMap;
keyMap[0].Action = EKA_MOVE_FORWARD;
keyMap[0].KeyCode = KEY_UP;
keyMap[1].Action = EKA_MOVE_FORWARD;
keyMap[1].KeyCode = KEY_KEY_W;
keyMap[2].Action = EKA_MOVE_BACKWARD;
keyMap[2].KeyCode = KEY_DOWN;
keyMap[3].Action = EKA_MOVE_BACKWARD;
keyMap[3].KeyCode = KEY_KEY_S;
keyMap[4].Action = EKA_STRAFE_LEFT;
keyMap[4].KeyCode = KEY_LEFT;
keyMap[5].Action = EKA_STRAFE_LEFT;
keyMap[5].KeyCode = KEY_KEY_A;
keyMap[6].Action = EKA_STRAFE_RIGHT;
keyMap[6].KeyCode = KEY_RIGHT;
keyMap[7].Action = EKA_STRAFE_RIGHT;
keyMap[7].KeyCode = KEY_KEY_D;
ca->setKeyMap(keyMap);
camera->addAnimator(ca);
如果您想稍后更改键绑定,那么只需更改正确的键码并使用
ca->setKeyMap(keyMap);
试。
:)
编辑: 您还可以访问场景管理器附加的Animator
camera = _smngr->addCameraSceneNodeFPS();
irr::core::list<irr::scene::ISceneNodeAnimator*>::ConstIterator al = camera->getAnimators().begin();
irr::scene::ISceneNodeAnimatorCameraFPS *a = (irr::scene::ISceneNodeAnimatorCameraFPS*)*al;
irr::core::array<irr::SKeyMap> keyMap;
keyMap[0].Action = EKA_MOVE_FORWARD;
keyMap[0].KeyCode = KEY_UP;
keyMap[1].Action = EKA_MOVE_FORWARD;
keyMap[1].KeyCode = KEY_KEY_W;
keyMap[2].Action = EKA_MOVE_BACKWARD;
keyMap[2].KeyCode = KEY_DOWN;
keyMap[3].Action = EKA_MOVE_BACKWARD;
keyMap[3].KeyCode = KEY_KEY_S;
keyMap[4].Action = EKA_STRAFE_LEFT;
keyMap[4].KeyCode = KEY_LEFT;
keyMap[5].Action = EKA_STRAFE_LEFT;
keyMap[5].KeyCode = KEY_KEY_A;
keyMap[6].Action = EKA_STRAFE_RIGHT;
keyMap[6].KeyCode = KEY_RIGHT;
keyMap[7].Action = EKA_STRAFE_RIGHT;
keyMap[7].KeyCode = KEY_KEY_D;
a->setKeyMap(keyMap);