//Touch Input void UI::HandleTouchBegin(StringHash eventType, VariantMap& eventData) { if (inputDisabled_ || consoleVisible_) return; using namespace TouchBegin; int touchId = eventData[P_TOUCHID].GetInt(); int px = eventData[P_X].GetInt(); int py = eventData[P_Y].GetInt(); static double last_time = 0; static int counter = 1; Time* t = GetSubsystem<Time>(); double time = t->GetElapsedTime() * 1000; if (time < last_time + 600) counter++; else counter = 1; last_time = time; rootWidget_->InvokePointerDown(px, py, counter, TB_MODIFIER_NONE, true, touchId); }
void UI::HandleMouseButtonDown(StringHash eventType, VariantMap& eventData) { if (inputDisabled_ || consoleVisible_) return; using namespace MouseButtonDown; unsigned button = eventData[P_BUTTON].GetUInt(); IntVector2 pos; pos = GetSubsystem<Input>()->GetMousePosition(); Input* input = GetSubsystem<Input>(); int qualifiers = input->GetQualifiers(); #ifdef ATOMIC_PLATFORM_WINDOWS bool superdown = input->GetKeyDown(KEY_LCTRL) || input->GetKeyDown(KEY_RCTRL); #else bool superdown = input->GetKeyDown(KEY_LGUI) || input->GetKeyDown(KEY_RGUI); #endif MODIFIER_KEYS mod = GetModifierKeys(qualifiers, superdown); static double last_time = 0; static int counter = 1; Time* t = GetSubsystem<Time>(); double time = t->GetElapsedTime() * 1000; if (time < last_time + 600) counter++; else counter = 1; last_time = time; if (button == MOUSEB_RIGHT) rootWidget_->InvokeRightPointerDown(pos.x_, pos.y_, counter, mod); else rootWidget_->InvokePointerDown(pos.x_, pos.y_, counter, mod, false); }
void CustomLogic::FixedUpdate(float timeStep) { if (!mat) return; #define M_PI 3.14159265358979323846S float loopPlayTime = 4.0f; Time* time = GetSubsystem<Time>(); float elapsed = time->GetElapsedTime(); float r = sinf((elapsed / loopPlayTime) * (2 * M_PI)) * 0.5f + 0.25f; float g = sinf((elapsed / loopPlayTime + 0.33333333f) * 2 * M_PI) * 0.5f + 0.25f; float b = sinf((elapsed / loopPlayTime + 0.66666666f) * 2 * M_PI) * 0.5f + 0.25f; float invNorm = 1.0f / (r + g + b); //r *= invNorm; //g *= invNorm; //b *= invNorm; float d = sin(elapsed / (loopPlayTime / 4.0f)) * 4; Vector3 rgb(r, g, b); rgb.Normalize(); mat->SetShaderParameter("ChannelFactor", rgb); //mat->SetShaderParameter("Displacement", d); //mat->SetShaderParameter("Range", Vector2(0.0f, 1.0f)); // control ramp texture color //mat->SetShaderParameter("ClipRange", 1.0f); }