bool LandscapeEditorBase::Input(DAVA::UIEvent *touch) { Vector2 point; bool isIntersect = GetLandscapePoint(touch->point, point); point.x = (float32)((int32)point.x); point.y = (float32)((int32)point.y); landscapePoint = point; UpdateCursor(); if(INVALID_TOUCH_ID == touchID || touchID == touch->tid) { if(UIEvent::BUTTON_1 == touch->tid) { inverseDrawingEnabled = IsKeyModificatorPressed(DVKEY_ALT); if(UIEvent::PHASE_BEGAN == touch->phase) { touchID = touch->tid; if(isIntersect) { prevDrawPos = Vector2(-100, -100); InputAction(touch->phase, isIntersect); } return true; } else if(UIEvent::PHASE_DRAG == touch->phase) { InputAction(touch->phase, isIntersect); if(!isIntersect) { prevDrawPos = Vector2(-100, -100); } return true; } else if(UIEvent::PHASE_ENDED == touch->phase || UIEvent::PHASE_CANCELLED == touch->phase) { touchID = INVALID_TOUCH_ID; if(isIntersect) { InputAction(touch->phase, isIntersect); prevDrawPos = Vector2(-100, -100); } return true; } } } return false; }
void TutorialScene::Initialize(const GameContext& gameContext) { UNREFERENCED_PARAMETER(gameContext); // Create PhysX ground plane auto physX = PhysxManager::GetInstance()->GetPhysics(); GetPhysxProxy()->EnablePhysxDebugRendering(true); auto bouncyMaterial = physX->createMaterial(0, 0, 1); auto ground = new GameObject(); ground->AddComponent(new RigidBodyComponent(true)); std::shared_ptr<PxGeometry> geom(new PxPlaneGeometry()); ground->AddComponent(new ColliderComponent(geom,*bouncyMaterial,PxTransform(PxQuat(XM_PIDIV2,PxVec3(0,0,1))))); AddChild(ground); // ADD SPHERE m_pSphere = new SpherePrefab(); m_pSphere->GetTransform()->Translate(0,5,0); // Sphere PhysX auto rigidbody = new RigidBodyComponent(); m_pSphere->AddComponent(rigidbody); std::shared_ptr<PxGeometry> spheregeom(new PxSphereGeometry(1)); m_pSphere->AddComponent(new ColliderComponent(spheregeom,*bouncyMaterial, PxTransform(PxQuat(XM_PIDIV2,PxVec3(0,0,1))))); AddChild(m_pSphere); auto inputAction = InputAction(0, InputTriggerState::Down, 'M'); gameContext.pInput->AddInputAction(inputAction); }
bool LandscapeEditorBase::Input(DAVA::UIEvent *touch) { Vector2 point; bool isIntersect = GetLandscapePoint(touch->point, point); point.x = (int32)point.x; point.y = (int32)point.y; landscapePoint = point; UpdateCursor(); if(INVALID_TOUCH_ID == touchID || touchID == touch->tid) { if(UIEvent::BUTTON_1 == touch->tid) { inverseDrawingEnabled = InputSystem::Instance()->GetKeyboard()->IsKeyPressed(DVKEY_ALT); if(UIEvent::PHASE_BEGAN == touch->phase) { touchID = touch->tid; if(isIntersect) { prevDrawPos = Vector2(-100, -100); InputAction(touch->phase, isIntersect); } return true; } else if(UIEvent::PHASE_DRAG == touch->phase) { InputAction(touch->phase, isIntersect); if(!isIntersect) { prevDrawPos = Vector2(-100, -100); } return true; } else if(UIEvent::PHASE_ENDED == touch->phase || UIEvent::PHASE_CANCELLED == touch->phase) { touchID = INVALID_TOUCH_ID; if(isIntersect) { InputAction(touch->phase, isIntersect); prevDrawPos = Vector2(-100, -100); } return true; } } } if(UIEvent::PHASE_KEYCHAR == touch->phase) { if(DVKEY_Z == touch->tid && InputSystem::Instance()->GetKeyboard()->IsKeyPressed(DVKEY_CTRL)) { UndoAction(); return true; } if(DVKEY_Z == touch->tid && InputSystem::Instance()->GetKeyboard()->IsKeyPressed(DVKEY_SHIFT)) { RedoAction(); return true; } } return false; }