// override and return true to get hover events public virtual bool FindHoverRayIntersection(Ray3f ray, out UIRayHit hit) { hit = null; if (Enabled == false) { return(false); } if (EnableHover == false) { return(false); } GameObjectRayHit hitg = null; if (FindGORayIntersection(ray, out hitg)) { if (hitg.hitGO != null) { hit = new UIRayHit(hitg, this); return(true); } } return(false); }
public override bool BeginCapture(ITransformable target, Ray3f worldRay, UIRayHit hit) { // save local and world frames rotateFrameL = target.GetLocalFrame(CoordSpace.ObjectCoords); rotateFrameW = target.GetLocalFrame(CoordSpace.WorldCoords); rotateAxisW = rotateFrameW.GetAxis(nRotationAxis); // save angle of hitpos in 2D plane perp to rotateAxis, so we can find delta-angle later Vector3f vWorldHitPos = hit.hitPos; Vector3f dv = vWorldHitPos - rotateFrameW.Origin; int iX = (nRotationAxis + 1) % 3; int iY = (nRotationAxis + 2) % 3; float fX = Vector3f.Dot(dv, rotateFrameW.GetAxis(iX)); float fY = Vector3f.Dot(dv, rotateFrameW.GetAxis(iY)); fRotateStartAngle = (float)Math.Atan2(fY, fX); // construct plane we will ray-intersect with in UpdateCapture() raycastFrame = new Frame3f(vWorldHitPos, rotateAxisW); if (EnableSnapping) { enable_circle_indicator(true); } return(true); }
public AnyRayHit(UIRayHit init) { hitPos = init.hitPos; fHitDist = init.fHitDist; hitGO = init.hitGO; eType = HitType.SceneUIElementHit; hitUI = init.hitUI; }
public bool FindHoverRayIntersection(Ray3f ray, out UIRayHit hit) { if (is_interactive == false) { hit = null; return(false); } return(HUDUtil.FindNearestHoverRayIntersection(Children, ray, out hit)); }
Vector3f vInitialHitPos; // initial hit position in frame public override bool BeginCapture(ITransformable target, Ray3f worldRay, UIRayHit hit) { // save local and world frames translateFrameL = target.GetLocalFrame(CoordSpace.ObjectCoords); translateFrameW = target.GetLocalFrame(CoordSpace.WorldCoords); // save initial hitpos in translation plane vInitialHitPos = translateFrameW.RayPlaneIntersection(worldRay.Origin, worldRay.Direction, nTranslationPlaneNormal); return(true); }
public bool FindAnyRayIntersection(Ray3f ray, out AnyRayHit hit) { hit = null; UIRayHit bestUIHit = null; if (FindUIRayIntersection(ray, out bestUIHit)) { hit = new AnyRayHit(bestUIHit); } return(hit != null); }
public override void UpdateHover(Ray3f ray, UIRayHit hit) { if (Enabled && HasGO(hit.hitGO)) { buttonMesh.SetMaterial(HoverMaterial, true); } else { buttonMesh.SetMaterial(StandardMaterial, true); } }
public virtual void UpdateHover(Ray3f ray, UIRayHit hit) { if (hoverWidget != null) { EndHover(ray); } if (Widgets.ContainsKey(hit.hitGO)) { hoverWidget = Widgets[hit.hitGO]; MaterialUtil.SetMaterial(hoverWidget.RootGameObject, hoverWidget.HoverMaterial); } }
// does not test bounds! // [TODO] this is going to be weird... need to test bounds, I think public bool FindAnyRayIntersection(Ray3f ray, out AnyRayHit hit) { hit = null; UIRayHit bestUIHit = null; SORayHit bestSOHit = null; foreach (var ui in vUIElements) { UIRayHit uiHit; if (ui.FindRayIntersection(ray, out uiHit)) { if (bestUIHit == null || uiHit.fHitDist < bestUIHit.fHitDist) { bestUIHit = uiHit; } } } foreach (var so in VisibleSceneObjects) { if (!is_selectable(so)) { continue; } SORayHit objHit; if (so.FindRayIntersection(ray, out objHit)) { if (bestSOHit == null || objHit.fHitDist < bestSOHit.fHitDist) { bestSOHit = objHit; } } } if (bestUIHit != null) { if (bestSOHit == null || bestSOHit.fHitDist > bestUIHit.fHitDist) { hit = new AnyRayHit(bestUIHit); } else { hit = new AnyRayHit(bestSOHit); } } else if (bestSOHit != null) { hit = new AnyRayHit(bestSOHit); } return(hit != null); }
// see comment above public bool Find2DCockpitUIHoverHit(Ray3f orthoEyeRay, out UIRayHit bestHit) { if (Use2DCockpit == false) { throw new Exception("FContext.Find2DUIHit: 2D UI layer is not enabled!"); } bestHit = null; if (options.EnableCockpit) { return(activeCockpit.FindUIHoverRayIntersection(orthoEyeRay, out bestHit)); } return(false); }
public virtual bool FindRayIntersection(UnityEngine.Ray ray, out UIRayHit hit) { hit = null; GameObjectRayHit hitg = null; if (FindGORayIntersection(ray, out hitg)) { if (hitg.hitGO != null) { hit = new UIRayHit(hitg, this); return(true); } } return(false); }
virtual public bool FindRayIntersection(Ray3f ray, out UIRayHit hit) { hit = null; GameObjectRayHit hitg = null; if (is_interactive && FindGORayIntersection(ray, out hitg)) { if (hitg.hitGO != null) { hit = new UIRayHit(hitg, this); return(true); } } return(false); }
public bool FindUIRayIntersection(Ray ray, out UIRayHit hit) { hit = null; foreach (var ui in vUIElements) { UIRayHit uiHit; if (ui.FindRayIntersection(ray, out uiHit)) { if (hit == null || uiHit.fHitDist < hit.fHitDist) { hit = uiHit; } } } return(hit != null); }
Vector3f vInitialHitPos; // initial hit position in frame public override bool BeginCapture(ITransformable target, Ray3f worldRay, UIRayHit hit) { if (target.SupportsScaling == false) { return(false); } // save local and world frames scaleFrameW = target.GetLocalFrame(CoordSpace.WorldCoords); cameraFrameW = new Frame3f(scaleFrameW.Origin, activeCamera.transform.rotation); startScale = target.GetLocalScale(); // save initial hitpos in plane vInitialHitPos = cameraFrameW.RayPlaneIntersection(worldRay.Origin, worldRay.Direction, 2); return(true); }
public bool BeginCapture(Ray ray, UIRayHit hit) { activeWidget = null; // if the hit gameobject has a widget attached to it, begin capture & transformation // TODO maybe wrapper class should have Begin/Update/End capture functions, then we do not need BeginTransformation/EndTransformation ? if (Widgets.ContainsKey(hit.hitGO)) { Widget w = Widgets [hit.hitGO]; if (w.BeginCapture(targetWrapper, ray, hit)) { targetWrapper.BeginTransformation(); activeWidget = w; return(true); } } return(false); }
} // end Update public bool FindUIHit(Ray eyeRay, out UIRayHit bestHit) { bestHit = new UIRayHit(); UIRayHit sceneHit = null, cockpitHit = null; if (scene.FindUIRayIntersection(eyeRay, out sceneHit)) { bestHit = sceneHit; } if (cockpit.FindUIRayIntersection(eyeRay, out cockpitHit)) { if (cockpitHit.fHitDist < bestHit.fHitDist) { bestHit = cockpitHit; } } return(bestHit.IsValid); }
public bool FindAnyRayIntersection(Ray eyeRay, out AnyRayHit anyHit) { anyHit = new AnyRayHit(); AnyRayHit sceneHit = null; UIRayHit cockpitHit = null; if (scene.FindAnyRayIntersection(eyeRay, out sceneHit)) { anyHit = sceneHit; } if (cockpit.FindUIRayIntersection(eyeRay, out cockpitHit)) { if (cockpitHit.fHitDist < anyHit.fHitDist) { anyHit = new AnyRayHit(cockpitHit); } } return(anyHit.IsValid); }
float fTranslateStartT; // start T-value along translateAxisW public bool BeginCapture(ITransformable target, Ray worldRay, UIRayHit hit) { // save local and world frames translateFrameL = target.GetLocalFrame(CoordSpace.ObjectCoords); translateFrameW = target.GetLocalFrame(CoordSpace.WorldCoords); translateAxisW = translateFrameW.GetAxis(nTranslationAxis); // save t-value of closest point on translation axis, so we can find delta-t Vector3 vWorldHitPos = hit.hitPos; fTranslateStartT = MathUtil.ClosestPointOnLineT( translateFrameW.Origin, translateAxisW, vWorldHitPos); // construct plane we will ray-intersect with in UpdateCapture() Vector3 vForward = Vector3.Cross(Camera.main.transform.up, translateAxisW); raycastFrame = new Frame3(vWorldHitPos, vForward); return(true); }
// see comment as above public bool FindUIHoverHit(Ray eyeRay, out UIRayHit bestHit) { bestHit = new UIRayHit(); UIRayHit sceneHit = null, cockpitHit = null; bool bCockpitOnly = (options.EnableCockpit && activeCockpit.GrabFocus); if (bCockpitOnly == false && scene.FindUIHoverRayIntersection(eyeRay, out sceneHit)) { bestHit = sceneHit; } if (Use2DCockpit == false && options.EnableCockpit && activeCockpit.FindUIHoverRayIntersection(eyeRay, out cockpitHit)) { if (cockpitHit.fHitDist < bestHit.fHitDist) { bestHit = cockpitHit; } } return(bestHit.IsValid); }
float fTranslateStartT; // start T-value along translateAxisW public override bool BeginCapture(ITransformable target, Ray3f worldRay, UIRayHit hit) { // save local and world frames translateFrameL = target.GetLocalFrame(CoordSpace.ObjectCoords); translateFrameW = target.GetLocalFrame(CoordSpace.WorldCoords); translateAxisW = translateFrameW.GetAxis(nTranslationAxis); // save t-value of closest point on translation axis, so we can find delta-t Vector3f vWorldHitPos = hit.hitPos; fTranslateStartT = Distance.ClosestPointOnLineT( translateFrameW.Origin, translateAxisW, vWorldHitPos); // construct plane we will ray-intersect with in UpdateCapture() Vector3f makeUp = Vector3f.Cross(Camera.main.transform.forward, translateAxisW).Normalized; Vector3f vPlaneNormal = Vector3f.Cross(makeUp, translateAxisW).Normalized; raycastFrame = new Frame3f(vWorldHitPos, vPlaneNormal); return(true); }
// currently used to change cursor highlight in VR views. Perhaps the VR input Controllers // should do this themselves! public bool FindAnyRayIntersection(Ray eyeRay, out AnyRayHit anyHit) { anyHit = new AnyRayHit(); AnyRayHit sceneHit = null; UIRayHit cockpitHit = null; bool bCockpitOnly = (options.EnableCockpit && activeCockpit.GrabFocus); if (bCockpitOnly == false && scene.FindAnyRayIntersection(eyeRay, out sceneHit)) { anyHit = sceneHit; } if (Use2DCockpit == false && options.EnableCockpit && activeCockpit.FindUIRayIntersection(eyeRay, out cockpitHit)) { if (cockpitHit.fHitDist < anyHit.fHitDist) { anyHit = new AnyRayHit(cockpitHit); } } return(anyHit.IsValid); }
public bool FindHoverRayIntersection(Ray3f ray, out UIRayHit hit) { return(FindRayIntersection(ray, out hit)); }
public abstract bool BeginCapture(ITransformable target, Ray worldRay, UIRayHit hit);
public static bool FindNearestHoverRayIntersection(IEnumerable <SceneUIElement> vElements, Ray3f ray, out UIRayHit hit) { hit = null; foreach (var ui in vElements) { UIRayHit uiHit; if (ui.EnableHover && ui.FindHoverRayIntersection(ray, out uiHit)) { if (hit == null || uiHit.fHitDist < hit.fHitDist) { hit = uiHit; } } } return(hit != null); }
public virtual bool FindHoverRayIntersection(Ray3f ray, out UIRayHit hit) { hit = null; return(false); }
override public void UpdateHover(Ray3f ray, UIRayHit hit) { hovering = true; }
// [RMS] I don't think we ever actually call these functions, do we?? // hover is sent directly to child that is ray-hit via above, right? public void UpdateHover(Ray3f ray, UIRayHit hit) { throw new InvalidOperationException("HUDCollection.UpdateHover: how is this being called?"); }
public bool FindUIHoverRayIntersection(Ray3f ray, out UIRayHit hit) { return(HUDUtil.FindNearestHoverRayIntersection(vUIElements, ray, out hit)); }
public virtual void UpdateHover(Ray3f ray, UIRayHit hit) { }
public bool FindHoverRayIntersection(Ray3f ray, out UIRayHit hit) { return(HUDUtil.FindNearestHoverRayIntersection(Children, ray, out hit)); }