void add(HUDStandardItem element, LayoutOptions options) { if (element.IsVisible == false) { element.IsVisible = true; } IBoxModelElement elemBoxModel = element as IBoxModelElement; childSet.Add(element); Func <Vector2f> pinSourceF = options.PinSourcePoint2D; if (pinSourceF == null) { pinSourceF = LayoutUtil.BoxPointF(elemBoxModel, BoxPosition.Center); } Func <Vector2f> pinTargetF = options.PinTargetPoint2D; if (pinTargetF == null) { pinTargetF = LayoutUtil.BoxPointF(Solver.Container, BoxPosition.Center); } Solver.AddLayoutItem(element, pinSourceF, pinTargetF, this.StandardDepth + options.DepthShift); }
public void Play(HUDStandardItem item, float showDuration = 3.0f, float fadeDuration = 0.5f) { HUDItem = item; ShowDuration = showDuration; FadeDuration = fadeDuration; Play(); }
/// <summary> /// This is very hacky. /// </summary> public static void AddDropShadow(HUDStandardItem item, Colorf color, float falloffWidth, Vector2f offset, float fZShift) { if (item is IBoxModelElement == false) { throw new Exception("HUDUtil.AddDropShadow: can only add drop shadow to IBoxModelElement"); } // [TODO] need interface that provides a HUDShape? var shape = item as IBoxModelElement; float w = shape.Size2D.x + falloffWidth; float h = shape.Size2D.y + falloffWidth; fRectangleGameObject meshGO = GameObjectFactory.CreateRectangleGO("shadow", w, h, color, false); meshGO.RotateD(Vector3f.AxisX, -90.0f); fMaterial dropMat = MaterialUtil.CreateDropShadowMaterial(color, w, h, falloffWidth); meshGO.SetMaterial(dropMat); item.AppendNewGO(meshGO, item.RootGameObject, false); BoxModel.Translate(meshGO, offset, fZShift); Vector3 posW = item.RootGameObject.PointToWorld(meshGO.GetLocalPosition()); ((Material)dropMat).SetVector("_Center", new Vector4(posW.x, posW.y, posW.z, 0)); }
public static void PlaceInSphereWithNormal(HUDStandardItem hudItem, float fHUDRadius, float fAngleHorz, float fAngleVert, Vector3f vPointDir) { Frame3f initFrame = hudItem.GetObjectFrame(); Frame3f hudFrame = GetSphereFrame(fHUDRadius, fAngleHorz, fAngleVert); hudItem.SetObjectFrame( initFrame.Translated(hudFrame.Origin) .Rotated(Quaternionf.FromTo(initFrame.Z, vPointDir))); }
public static void PlaceInSphere(HUDStandardItem hudItem, float fHUDRadius, Vector3f vHUDCenter, Vector3f vPlaceAt) { Frame3f initFrame = hudItem.GetObjectFrame(); Frame3f hudFrame = GetSphereFrame(fHUDRadius, vHUDCenter, vPlaceAt); hudItem.SetObjectFrame( initFrame.Translated(hudFrame.Origin) .Rotated(Quaternionf.FromTo(initFrame.Z, hudFrame.Z))); }
public static void PlaceInSphere(HUDStandardItem hudItem, float fHUDRadius, float fAngleHorz, float fAngleVert) { Frame3f initFrame = hudItem.GetObjectFrame(); Frame3f hudFrame = GetSphereFrame(fHUDRadius, fAngleHorz, fAngleVert); hudItem.SetObjectFrame( initFrame.Translated(hudFrame.Origin) .Rotated(Quaternion.FromToRotation(initFrame.Z, hudFrame.Z))); }
public void Place(HUDStandardItem hudItem, float dx, float dy) { Frame3f initFrame = hudItem.GetObjectFrame(); Frame3f hudFrame = HUDUtil.GetSphereFrame(Radius, dx, dy); hudItem.SetObjectFrame( initFrame.Translated(hudFrame.Origin) .Rotated(Quaternionf.FromTo(initFrame.Z, hudFrame.Z))); }
public static void AnimatedDimiss_Scene(HUDStandardItem hudItem, FScene scene, bool bDestroy, float fDuration = 0.25f) { AnimatedDismissHUDItem anim = hudItem.RootGameObject.AddComponent <AnimatedDismissHUDItem>(); anim.CompleteCallback += () => { anim.HUDItem.ClearGameObjects(false); scene.RemoveUIElement(anim.HUDItem, bDestroy); }; anim.Play(hudItem, fDuration); }
public static void PlaceInScene(HUDStandardItem hudItem, Vector3f vHUDCenter, Vector3f vPlaceAt) { Frame3f initFrame = hudItem.GetObjectFrame(); Vector3f n = (vPlaceAt - vHUDCenter).Normalized; Frame3f frame = new Frame3f(vPlaceAt, n); hudItem.SetObjectFrame( initFrame.Translated(frame.Origin) .Rotated(Quaternionf.FromTo(initFrame.Z, frame.Z))); }
public static void AnimatedShowHide_Cockpit(HUDStandardItem hudItem, Cockpit cockpit, float fShowDuration = 3.0f, float fFadeDuration = 0.25f) { AnimatedShowHideHUDItem anim = hudItem.RootGameObject.AddComponent <AnimatedShowHideHUDItem>(); anim.CompleteCallback += () => { anim.HUDItem.ClearGameObjects(false); cockpit.RemoveUIElement(anim.HUDItem, true); }; anim.Play(hudItem, fShowDuration, fFadeDuration); }
public void Place(HUDStandardItem hudItem, float dx, float dy) { Frame3f initFrame = hudItem.GetObjectFrame(); Frame3f hudFrame = VerticalCoordIsAngle ? HUDUtil.GetCylinderFrameFromAngles(Radius, dx, dy) : HUDUtil.GetCylinderFrameFromAngleHeight(Radius, dx, dy); hudItem.SetObjectFrame( initFrame.Translated(hudFrame.Origin) .Rotated(Quaternionf.FromTo(initFrame.Z, hudFrame.Z))); }
/// <summary> /// Replace the material on the background GO of item. /// Assumes that the background GO has the name "background"... /// </summary> public static void SetBackgroundMaterial(HUDStandardItem item, fMaterial material, bool bShared = false) { var go = item.FindGOByName("background"); if (go == null) { DebugUtil.Log(2, "HUDUtil.SetBackgroundImage: item {0} does not have go named 'background'", item.Name); return; } go.SetMaterial(material, bShared); }
public static void AnimatedShow(HUDStandardItem hudItem, float fDuration = 0.25f, Action OnCompleted = null) { AnimatedDisplayHUDItem anim = hudItem.RootGameObject.AddComponent <AnimatedDisplayHUDItem>(); if (OnCompleted != null) { anim.CompleteCallback += () => { OnCompleted(); }; } anim.Play(hudItem, fDuration); }
void add(HUDStandardItem element, LayoutOptions options) { if (element.IsVisible == false) { element.IsVisible = true; } IBoxModelElement elemBoxModel = element as IBoxModelElement; // for 2D view (but doesn't matter if we are doing a layout anyway!) Frame3f viewFrame = Cockpit.GetViewFrame2D(); // with 3D view we should use this... //Frame3f viewFrame = Frame3f.Identity; element.SetObjectFrame(Frame3f.Identity); HUDUtil.PlaceInViewPlane(element, viewFrame); Cockpit.AddUIElement(element); Func <Vector2f> pinSourceF = options.PinSourcePoint2D; if (pinSourceF == null) { pinSourceF = LayoutUtil.BoxPointF(elemBoxModel, BoxPosition.Center); } Func <Vector2f> pinTargetF = options.PinTargetPoint2D; if (pinTargetF == null) { pinTargetF = LayoutUtil.BoxPointF(Solver.Container, BoxPosition.Center); } Solver.AddLayoutItem(element, pinSourceF, pinTargetF, this.StandardDepth + options.DepthShift); // if we want to shift result in its layout frame, do that via a post-transform if (options.FrameAxesShift != Vector3f.Zero) { Solver.AddPostTransform(element, (e) => { Frame3f f = (e as IElementFrame).GetObjectFrame(); f.Translate(options.FrameAxesShift.x * f.X + options.FrameAxesShift.y * f.Y + options.FrameAxesShift.z * f.Z); (e as IElementFrame).SetObjectFrame(f); }); } // auto-show if ((options.Flags & LayoutFlags.AnimatedShow) != 0) { HUDUtil.AnimatedShow(element); } }
// kind of feeling like this should maybe go somewhere else... public static void SetObjectPosition(IBoxModelElement element, BoxPosition objectPos, Vector2f pos, float z = 0) { // [RMS] this is true for now...need to rethink though HUDStandardItem item = element as HUDStandardItem; Vector2f corner_offset = GetBoxOffset(element, objectPos); Vector2f new_pos = pos - corner_offset; Frame3f f = new Frame3f(new Vector3f(new_pos.x, new_pos.y, z)); item.SetObjectFrame(f); }
// kind of feeling like this should maybe go somewhere else... public static void SetObjectPosition(IBoxModelElement element, Vector2f vObjectPoint, Vector2f vTargetPoint, float z = 0) { // [RMS] this is true for now...need to rethink though HUDStandardItem item = element as HUDStandardItem; Vector2f vOffset = GetRelativeOffset(element, vObjectPoint); Vector2f vNewPos = vTargetPoint - vOffset; Frame3f f = new Frame3f(new Vector3f(vNewPos.x, vNewPos.y, z)); item.SetObjectFrame(f); }
public static void AnimatedDimiss_Cockpit(HUDStandardItem hudItem, Cockpit cockpit, bool bDestroy, float fDuration = 0.25f) { AnimatedDismissHUDItem anim = hudItem.RootGameObject.AddComponent <AnimatedDismissHUDItem>(); anim.CompleteCallback += () => { if (bDestroy) { anim.HUDItem.ClearGameObjects(false); // what is this line for?? } cockpit.RemoveUIElement(anim.HUDItem, bDestroy); if (bDestroy == false) { anim.HUDItem.IsVisible = false; } }; anim.Play(hudItem, fDuration); }
/// <summary> /// This is very hacky. /// </summary> public static void AddDropShadow(HUDStandardItem item, Cockpit cockpit, Colorf color, float falloffWidthPx, Vector2f offset, float fZShift, bool bTrackCockpitScaling = true) { if (item is IBoxModelElement == false) { throw new Exception("HUDUtil.AddDropShadow: can only add drop shadow to IBoxModelElement"); } float falloffWidth = falloffWidthPx * cockpit.GetPixelScale(); // [TODO] need interface that provides a HUDShape? var shape = item as IBoxModelElement; float w = shape.Size2D.x + falloffWidth; float h = shape.Size2D.y + falloffWidth; fRectangleGameObject meshGO = GameObjectFactory.CreateRectangleGO("shadow", w, h, color, false); meshGO.RotateD(Vector3f.AxisX, -90.0f); fMaterial dropMat = MaterialUtil.CreateDropShadowMaterial(color, w, h, falloffWidth); meshGO.SetMaterial(dropMat); item.AppendNewGO(meshGO, item.RootGameObject, false); BoxModel.Translate(meshGO, offset, fZShift); if (bTrackCockpitScaling) { PreRenderBehavior pb = meshGO.AddComponent <PreRenderBehavior>(); pb.ParentFGO = meshGO; pb.AddAction(() => { Vector3f posW = item.RootGameObject.PointToWorld(meshGO.GetLocalPosition()); ((Material)dropMat).SetVector("_Center", new Vector4(posW.x, posW.y, posW.z, 0)); float curWidth = falloffWidthPx * cockpit.GetPixelScale(); Vector2f origSize = shape.Size2D + falloffWidth * Vector2f.One; Vector2f size = cockpit.GetScaledDimensions(origSize); float ww = size.x; float hh = size.y; ((Material)dropMat).SetVector("_Extents", new Vector4(ww / 2, hh / 2, 0, 0)); float newWidth = falloffWidthPx * cockpit.GetPixelScale(); ((Material)dropMat).SetFloat("_FalloffWidth", newWidth); }); } }
void add(HUDStandardItem element, LayoutOptions options) { if (element.IsVisible == false) { element.IsVisible = true; } IBoxModelElement elemBoxModel = element as IBoxModelElement; // for 2D view (but doesn't matter if we are doing a layout anyway!) Frame3f viewFrame = Cockpit.GetViewFrame2D(); // with 3D view we should use this... //Frame3f viewFrame = Frame3f.Identity; element.SetObjectFrame(Frame3f.Identity); HUDUtil.PlaceInViewPlane(element, viewFrame); Cockpit.AddUIElement(element); Func <Vector2f> pinSourceF = options.PinSourcePoint2D; if (pinSourceF == null) { pinSourceF = LayoutUtil.BoxPointF(elemBoxModel, BoxPosition.Center); } Func <Vector2f> pinTargetF = options.PinTargetPoint2D; if (pinTargetF == null) { pinTargetF = LayoutUtil.BoxPointF(Solver.Container, BoxPosition.Center); } Solver.AddLayoutItem(element, pinSourceF, pinTargetF, this.StandardDepth + options.DepthShift); // auto-show if ((options.Flags & LayoutFlags.AnimatedShow) != 0) { HUDUtil.AnimatedShow(element); } }
HUDElementList make_horz_labeled_param(string textLabel, HUDStandardItem item) { HUDElementList container = new HUDElementList() { Direction = ListDirection.Horizontal, Width = this.Width, Height = this.RowHeight, Spacing = this.Padding }; HUDLabel label = new HUDLabel() { Shape = new HUDShape(HUDShapeType.Rectangle, HorzParamLabelWidth, LabelTextHeight), TextHeight = LabelTextHeight, Text = textLabel }; label.Create(); container.AddListItem(label); container.AddListItem(item); container.Create(); return(container); }
public void Begin(HUDStandardItem item, float duration = 1.0f) { this.HUDItem = item; this.Duration = duration; StartCoroutine(Animate()); }
public static void PlaceInViewPlane(HUDStandardItem hudItem, Frame3f viewFrame) { PlaceInViewPlane(hudItem, Vector3f.Zero, viewFrame); }
public static void PlaceInViewPlane(HUDStandardItem hudItem, Vector3f vPosition, Frame3f viewFrame) { Frame3f objFrame = hudItem.GetObjectFrame().Translated(vPosition); hudItem.SetObjectFrame(viewFrame.FromFrame(objFrame)); }
public void Play(HUDStandardItem item, float duration = 0.5f) { HUDItem = item; Duration = duration; Play(); }