本文整理汇总了C++中EventType::getType方法的典型用法代码示例。如果您正苦于以下问题:C++ EventType::getType方法的具体用法?C++ EventType::getType怎么用?C++ EventType::getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventType
的用法示例。
在下文中一共展示了EventType::getType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: perform
void MoveCameraCallback::perform(EventType& event) {
if (event.getType() == eEventType::eKey) {
KeyboardEventData e = KeyboardEvent::getData(event);
ICamera* camera = mEngine->getCurrentScene()->getCamera();
switch (e.key) {
case GLFW_KEY_W:
camera->moveInDirection(glm::vec3(0.0, 0.0, -mSpeed));
break;
case GLFW_KEY_S:
camera->moveInDirection(glm::vec3(0.0, 0.0, mSpeed));
break;
case GLFW_KEY_D:
if (e.action == GLFW_RELEASE) {
mEngine->configureDebugger(eDebuggerState::eToggleState);
}
break;
}
} else if (event.getType() == eEventType::eMouseButton) {
MouseButtonEventData e = MouseButtonEvent::getData(event);
if (e.mButton == GLFW_MOUSE_BUTTON_LEFT) {
}
if (e.mButton == GLFW_MOUSE_BUTTON_MIDDLE) {
}
if (e.mButton == GLFW_MOUSE_BUTTON_RIGHT) {
}
} else if (event.getType() == eEventType::eScroll) {
ScrollEventData e = ScrollEvent::getData(event);
if (e.mOffsetY < 0.0) { // scroll down
mEngine->getCurrentScene()->getCamera()->moveBy(glm::vec3(0.0, 0.0, mSpeed));
} else if (e.mOffsetY > 0.0) { // scroll up
mEngine->getCurrentScene()->getCamera()->moveBy(glm::vec3(0.0, 0.0, -mSpeed));
}
return;
} else if (event.getType() == eEventType::eCursorPosition) {
static bool init = false;
static int a = 0;
auto d = [](double value) {
return static_cast<float>(value);
};
CursorPositionEventData e = CursorPositionEvent::getData(event);
ICamera* camera = mEngine->getCurrentScene()->getCamera();
glm::ivec2 screenSize = mEngine->getScreenSize();
double dx = e.xPosition - screenSize[0] / 2;
double dy = screenSize[1] / 2 - e.yPosition;
if (init) { /* debounce */
camera->rotateBy(glm::vec3(0.0f, 1.0f, 0.0f), -mSpeed * d(glm::radians(dx)));
camera->rotateBy(glm::vec3(1.0f, 0.0f, 0.0f), mSpeed * d(glm::radians(dy)));
camera->update();
} else {
init = true;
}
if (mWindow) {
if (a++ > 2) {
glfwSetCursorPos(mWindow, mEngine->getScreenSize()[0] / 2,
mEngine->getScreenSize()[1] / 2);
a = 0;
}
}
}
}