// creates a button that is just the mesh public void Create(fMesh mesh, fMaterial meshMaterial, float fScale, Quaternionf transform) { button = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("HUDButton")); iconMesh = AppendMeshGO("shape", mesh, meshMaterial, button); iconMesh.SetLocalScale(new Vector3f(fScale, fScale, fScale)); iconMesh.SetLocalRotation(iconMesh.GetLocalRotation() * transform); MaterialUtil.DisableShadows(iconMesh); standard_mat = new fMaterial(meshMaterial); }
public void Create(fMaterial defaultMaterial) { button = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("HUDToggleButton")); buttonMesh = AppendMeshGO("disc", make_button_body_mesh(), defaultMaterial, button); buttonMesh.RotateD(Vector3f.AxisX, -90.0f); // ?? if (text.Length > 0) { UpdateText(); } }
public virtual DMeshSO Create(DMesh3 mesh, SOMaterial setMaterial) { AssignSOMaterial(setMaterial); // need to do this to setup BaseSO material stack parentGO = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("DMesh")); this.mesh = mesh; on_mesh_changed(); displayComponents = new List <DisplayMeshComponent>(); validate_decomp(); return(this); }
public void Create(fMaterial defaultMaterial) { button = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("HUDToggleButton")); buttonMesh = AppendMeshGO("shape", HUDUtil.MakeBackgroundMesh(this.Shape), defaultMaterial, button); buttonMesh.RotateD(Vector3f.AxisX, -90.0f); // ?? if (text.Length > 0) { UpdateText(); } }
public void AddComponent(MeshDecomposition.Component C) { fMesh submesh = new fMesh(C.triangles, mesh, C.source_vertices, true, true); fMeshGameObject submesh_go = GameObjectFactory.CreateMeshGO("component", submesh, false); submesh_go.SetMaterial(new fMaterial(CurrentMaterial)); displayComponents.Add(new DisplayMeshComponent() { go = submesh_go, source_vertices = C.source_vertices }); AppendNewGO(submesh_go, parentGO, false); }
public virtual DMeshSO Create(DMesh3 mesh, SOMaterial setMaterial) { AssignSOMaterial(setMaterial); // need to do this to setup BaseSO material stack parentGO = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("DMesh")); this.mesh = mesh; on_mesh_changed(); validate_view_meshes(); return(this); }
// actually create GO elements, etc public void Create() { entry = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("HUDPopupMessage")); bgMesh = AppendMeshGO("background", make_background_mesh(), MaterialUtil.CreateFlatMaterialF(BackgroundColor), entry); bgMesh.RotateD(Vector3f.AxisX, -90.0f); IBoxModelElement contentArea = BoxModel.PaddedBounds(this, Padding); BoxPosition titleBoxPos = BoxModel.ToPosition(TitleAlignment, VerticalAlignment.Top); titleTextMesh = (titleText == "") ? null : GameObjectFactory.CreateTextMeshGO( "title", TitleText, TextColor, TitleTextHeight, titleBoxPos, SceneGraphConfig.TextLabelZOffset); float fTitleHeight = 0; if (titleTextMesh != null) { Vector2f titleToPos = BoxModel.GetBoxPosition(contentArea, titleBoxPos); BoxModel.Translate(titleTextMesh, Vector2f.Zero, titleToPos); AppendNewGO(titleTextMesh, entry, false); fTitleHeight = TitleTextHeight; } IBoxModelElement messageArea = BoxModel.PaddedBounds(contentArea, 0, 0, 0, Padding + fTitleHeight); Vector2f textDims = messageArea.Size2D; BoxPosition textBoxPos = BoxModel.ToPosition(Alignment, VerticalAlignment.Top); textMesh = GameObjectFactory.CreateTextAreaGO( "message", Text, TextColor, TextHeight, textDims, Alignment, textBoxPos, SceneGraphConfig.TextLabelZOffset); Vector2f textToPos = BoxModel.GetBoxPosition(messageArea, textBoxPos); BoxModel.Translate(textMesh, Vector2f.Zero, textToPos); AppendNewGO(textMesh, entry, false); if (EnableClickToDismiss) { footerTextMesh = GameObjectFactory.CreateTextMeshGO( "footer", DismissText, DismissTextColor, TextHeight * 0.5f, BoxPosition.CenterBottom, SceneGraphConfig.TextLabelZOffset); BoxModel.Translate(footerTextMesh, Vector2f.Zero, BoxModel.GetBoxPosition(contentArea, BoxPosition.CenterBottom)); AppendNewGO(footerTextMesh, entry, false); } }
public virtual MeshSO Create(Mesh mesh, SOMaterial setMaterial) { AssignSOMaterial(setMaterial); // need to do this to setup BaseSO material stack parentGO = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("Mesh")); meshGO = new GameObject("mesh"); meshGO.AddComponent <MeshFilter>(); meshGO.SetMesh(mesh); meshGO.AddComponent <MeshCollider>().enabled = false; meshGO.AddComponent <MeshRenderer>().material = CurrentMaterial; AppendNewGO(meshGO, (GameObject)parentGO, true); return(this); }
public void RemoveAllUIElements(bool bDiscardTransientObjects = true) { while (vUIElements.Count > 0) { RemoveUIElement(vUIElements[0], true); } // discard any transient objects we have floating around if (bDiscardTransientObjects) { transient_objects.Destroy(); transient_objects = GameObjectFactory.CreateParentGO("transient"); sceneRoot.AddChild(transient_objects, false); } }
public virtual DMeshSO Create(DMesh3 mesh, SOMaterial setMaterial) { AssignSOMaterial(setMaterial); // need to do this to setup BaseSO material stack parentGO = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("DMesh")); this.mesh = mesh; //viewMeshes = new LinearDecompViewMeshManager(this); viewMeshes = new TrivialViewMeshManager(this); on_mesh_changed(); viewMeshes.ValidateViewMeshes(); return(this); }
protected void update_labels() { AxisAlignedBox2f localBounds = BoxModel.LocalBounds(this); foreach (var pair in Labels) { float t = (float)(pair.Key); PositionLabel labelinfo = pair.Value; if (labelinfo.go == null) { BoxPosition boxPos = BoxPosition.CenterTop; if (labelinfo.position == LabelPositionType.CenteredAbove) { boxPos = BoxPosition.CenterBottom; } else if (labelinfo.position == LabelPositionType.BelowLeftAligned) { boxPos = BoxPosition.TopLeft; } else if (labelinfo.position == LabelPositionType.BelowRightAligned) { boxPos = BoxPosition.TopRight; } labelinfo.go = GameObjectFactory.CreateTextMeshGO("sliderlabel_" + labelinfo.text, labelinfo.text, labelinfo.color, LabelTextHeight, boxPos); AppendNewGO(labelinfo.go, rootGO, false); } if (labelinfo.position == LabelPositionType.CenteredBelow || labelinfo.position == LabelPositionType.BelowLeftAligned || labelinfo.position == LabelPositionType.BelowRightAligned) { BoxModel.MoveTo(labelinfo.go, localBounds.BottomLeft, -Height * 0.01f); } else if (labelinfo.position == LabelPositionType.CenteredAbove) { BoxModel.MoveTo(labelinfo.go, localBounds.TopLeft, -Height * 0.01f); } else { throw new NotSupportedException("HUDSliderBase.update_labels : unhandled LabelPositionType"); } BoxModel.Translate(labelinfo.go, new Vector2f(t * Width, 0) + labelinfo.offset); } }
// creates a button in the desired geometry shape public void Create() { entry = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("HUDLabel")); bgMesh = AppendMeshGO("background", HUDUtil.MakeBackgroundMesh(Shape), MaterialUtil.CreateFlatMaterialF(BackgroundColor), entry); bgMesh.RotateD(Vector3f.AxisX, -90.0f); if (EnableBorder) { HUDShape borderShape = Shape; borderShape.Radius += BorderWidth; borderShape.Height += 2 * BorderWidth; borderShape.Width += 2 * BorderWidth; border = AppendMeshGO("border", HUDUtil.MakeBackgroundMesh(borderShape), MaterialUtil.CreateFlatMaterialF(BorderColor), entry); border.RotateD(Vector3f.AxisX, -90.0f); border.Translate(-0.001f * Vector3f.AxisY, true); } BoxPosition horzAlign = BoxPosition.CenterLeft; if (AlignmentHorz == HorizontalAlignment.Center) { horzAlign = BoxPosition.Center; } else if (AlignmentHorz == HorizontalAlignment.Right) { horzAlign = BoxPosition.CenterRight; } textMesh = GameObjectFactory.CreateTextMeshGO( "text", Text, TextColor, TextHeight, horzAlign, SceneGraphConfig.TextLabelZOffset); textMesh.TextObject.SetFixedWidth(Shape.Width); textMesh.TextObject.SetOverflowMode(TextOverflowMode.Ellipses); Vector2f toPos = BoxModel.GetBoxPosition(this, horzAlign); BoxModel.Translate(textMesh, Vector2f.Zero, toPos); AppendNewGO(textMesh, entry, false); MaterialUtil.DisableShadows(RootGameObject); }
// creates a button with a background shape and a foreground mesh public void Create(fMaterial bgMaterial, fMesh mesh, fMaterial meshMaterial, float fScale, Frame3f deltaF) { button = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("HUDButton")); buttonMesh = AppendMeshGO("shape", HUDUtil.MakeBackgroundMesh(this.Shape), bgMaterial, button); buttonMesh.RotateD(Vector3f.AxisX, -90.0f); // ?? MaterialUtil.DisableShadows(buttonMesh); iconMesh = AppendMeshGO("shape", mesh, meshMaterial, button); iconMesh.SetLocalScale(new Vector3f(fScale, fScale, fScale)); iconMesh.SetLocalPosition(deltaF.Origin); iconMesh.SetLocalRotation(deltaF.Rotation); MaterialUtil.DisableShadows(iconMesh); standard_mat = new fMaterial(bgMaterial); }
public void AddComponent(MeshDecomposition.Component C) { fMesh submesh = new fMesh(C.triangles, mesh, C.source_vertices, true, true, true); fMeshGameObject submesh_go = GameObjectFactory.CreateMeshGO("component", submesh, true); submesh_go.SetMaterial(SourceSO.CurrentMaterial, true); submesh_go.SetLayer(SourceSO.RootGameObject.GetLayer()); displayComponents.Add(new DisplayMeshComponent() { go = submesh_go, source_vertices = C.source_vertices }); if (SourceSO.ShadowsEnabled == false) { MaterialUtil.DisableShadows(submesh_go, true, true); } SourceSO.AppendNewGO(submesh_go, SourceSO.RootGameObject, false); }
void InitOnMainThread(fGameObject parentGO) { LineGO = GameObjectFactory.CreateLineGO(NameF(), ColorF(), LineWidthF(), LineWidthType.World); LineGO.SetStart(StartF()); LineGO.SetEnd(EndF()); if (parentGO != null) { parentGO.AddChild(LineGO, false); } LineGO.GetComponent <PreRenderBehavior>().AddAction(() => { Update(); }); if (OnCreateF != null) { OnCreateF(LineGO); } }
/// <summary> /// Utility to add SO geometry to a parent GO, which would then be passed to Create() /// </summary> public static void AppendSOGeometry(fGameObject parentGO, SceneObject so, bool bAddMeshColliders) { fGameObject copy = GameObjectFactory.Duplicate(so.RootGameObject); // if so is a DMeshSO, and it doesn't have a collider, add it if (so is DMeshSO && bAddMeshColliders) { foreach (var go in copy.Children()) { if (go.GetComponent <MeshFilter>() != null && go.GetComponent <MeshCollider>() == null) { go.AddComponent <MeshCollider>(); } } } parentGO.AddChild(copy, true); }
static public fGameObject EmitDebugMesh(string name, DMesh3 meshIn, Colorf color, GameObject parent = null, bool bIsInWorldPos = true) { DMesh3 mesh = new DMesh3(meshIn); if (FPlatform.InMainThread() == false) { ThreadMailbox.PostToMainThread(() => { DebugUtil.EmitDebugMesh(name, mesh, color, parent, bIsInWorldPos); }); return(null); } fMeshGameObject fMeshGO = GameObjectFactory.CreateMeshGO(name, new fMesh(mesh), false, true); fMeshGO.SetMaterial(MaterialUtil.CreateStandardMaterialF(color)); if (parent != null) { parent.AddChild(fMeshGO, bIsInWorldPos); } return(fMeshGO); }
// creates a button in the desired geometry shape public void Create(fMaterial defaultMaterial, fMaterial disabledMaterial = null, fMaterial hoverMaterial = null) { button = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("HUDButton")); buttonMesh = AppendMeshGO("shape", HUDUtil.MakeBackgroundMesh(this.Shape), defaultMaterial, button); buttonMesh.RotateD(Vector3f.AxisX, -90.0f); // ?? MaterialUtil.DisableShadows(buttonMesh); standard_mat = defaultMaterial; if (disabledMaterial != null) { disabled_mat = disabledMaterial; } if (hoverMaterial != null) { hover_mat = hoverMaterial; } }
// creates a button that is just the mesh, basically same as above but without the background disc public void Create(UnityEngine.PrimitiveType eType, fMaterial primMaterial, float fPrimScale = 1.0f) { button = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("HUDButton")); buttonMesh = AppendUnityPrimitiveGO(UniqueNames.GetNext("HUDButton"), eType, primMaterial, button); float primSize = Shape.EffectiveRadius() * fPrimScale; buttonMesh.SetLocalScale(new Vector3f(primSize, primSize, primSize)); buttonMesh.Translate(new Vector3f(0.0f, 0.0f, -primSize), false); Quaternionf rot = buttonMesh.GetLocalRotation(); rot = rot * Quaternionf.AxisAngleD(Vector3f.AxisY, 45.0f); rot = rot * Quaternionf.AxisAngleD(Vector3f.AxisX, -15.0f); buttonMesh.SetLocalRotation(rot); //buttonMesh.transform.Rotate(-15.0f, 45.0f, 0.0f, Space.Self); MaterialUtil.DisableShadows(buttonMesh); standard_mat = new fMaterial(primMaterial); }
/// <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); }); } }
public List <fGameObject> Generate() { fMesh mesh = FResources.LoadMesh(Path); fMeshGameObject fMeshGO = GameObjectFactory.CreateMeshGO("iconMesh", mesh, false, true); fMeshGO.SetMaterial(MaterialUtil.CreateStandardMaterial(this.Color), true); // apply orientation fMeshGO.SetLocalScale(new Vector3f(Scale, Scale, Scale)); fMeshGO.SetLocalPosition(fMeshGO.GetLocalPosition() + Translate); fMeshGO.SetLocalRotation(Rotate); // ignore material changes when we add to GameObjectSet fMeshGO.AddComponent <IgnoreMaterialChanges>(); return(new List <fGameObject>() { fMeshGO }); }
public virtual void ValidateViewMeshes() { if (decomp_valid) { return; } fMesh unityMesh = UnityUtil.DMeshToUnityMesh(mesh, false, true); viewMeshGO = GameObjectFactory.CreateMeshGO("component", unityMesh, false, true); viewMeshGO.SetMaterial(SourceSO.CurrentMaterial, true); viewMeshGO.SetLayer(SourceSO.RootGameObject.GetLayer()); if (SourceSO.ShadowsEnabled == false) { MaterialUtil.DisableShadows(viewMeshGO, true, true); } SourceSO.AppendNewGO(viewMeshGO, SourceSO.RootGameObject, false); decomp_valid = true; }
void UpdateText() { if (button == null) { return; } if (labelMesh == null && text.Length > 0) { labelMesh = GameObjectFactory.CreateTextMeshGO( "label", Text, TextColor, TextHeight, BoxPosition.Center, SceneGraphConfig.TextLabelZOffset); BoxModel.Translate(labelMesh, Vector2f.Zero, this.Bounds2D.Center); AppendNewGO(labelMesh, button, false); } if (labelMesh != null) { labelMesh.SetColor(TextColor); labelMesh.SetText(Text); } }
public void Create(SOMaterial useMaterial, fGameObject parent, int nLayer = -1) { if (curve == null) { curve = new DCurve3() { Closed = closed } } ; curveObject = GameObjectFactory.CreatePolylineGO("preview_curve", null, useMaterial.RGBColor, 0.05f, LineWidthType.World); if (nLayer >= 0) { curveObject.SetLayer(nLayer); } bUpdatePending = true; parent.AddChild(curveObject, false); }
// creates a button in the desired geometry shape public void Create() { entry = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("HUDShapeElement")); bgMesh = new fGameObject(AppendMeshGO("background", HUDUtil.MakeBackgroundMesh(Shape), MaterialUtil.CreateFlatMaterialF(Color), entry)); bgMesh.RotateD(Vector3f.AxisX, -90.0f); if (EnableBorder) { HUDShape borderShape = Shape; borderShape.Radius += BorderWidth; borderShape.Height += 2 * BorderWidth; borderShape.Width += 2 * BorderWidth; border = new fGameObject(AppendMeshGO("border", HUDUtil.MakeBackgroundMesh(borderShape), MaterialUtil.CreateFlatMaterialF(BorderColor), entry)); border.RotateD(Vector3f.AxisX, -90.0f); border.Translate(-0.001f * Vector3f.AxisY, true); } }
public override void Create() { base.Create(); backgroundGO = GameObjectFactory.CreateDiscGO(rootGO.GetName() + "_bg", radius, bgColor, true); MaterialUtil.DisableShadows(backgroundGO); backgroundGO.RotateD(Vector3f.AxisX, -90.0f); // make vertical AppendNewGO(backgroundGO, rootGO, false); progressGO = GameObjectFactory.CreateDiscGO(rootGO.GetName() + "_progress", radius, completedColor, true); progressGO.SetStartAngleDeg(89.0f); progressGO.SetEndAngleDeg(90.0f); MaterialUtil.DisableShadows(progressGO); progressGO.RotateD(Vector3f.AxisX, -90.0f); // make vertical progressGO.Translate(0.001f * Vector3f.AxisY, true); AppendNewGO(progressGO, rootGO, false); update_geometry(); }
static public fGameObject EmitDebugBox(string name, Box3d box, Colorf color, GameObject parent = null, bool bIsInWorldPos = true) { if (FPlatform.InMainThread() == false) { ThreadMailbox.PostToMainThread(() => { DebugUtil.EmitDebugBox(name, box, color, parent, bIsInWorldPos); }); return(null); } TrivialBox3Generator boxgen = new TrivialBox3Generator() { Box = box, NoSharedVertices = true, Clockwise = true }; boxgen.Generate(); DMesh3 mesh = boxgen.MakeDMesh(); fMeshGameObject fMeshGO = GameObjectFactory.CreateMeshGO(name, new fMesh(mesh), false, true); fMeshGO.SetMaterial(MaterialUtil.CreateStandardMaterialF(color)); if (parent != null) { parent.AddChild(fMeshGO, bIsInWorldPos); } return(fMeshGO); }
public virtual PivotSO Create(SOMaterial shapeMaterial, SOMaterial frameMaterial = null, int nShapeLayer = -1) { // [TODO] replace frame geometry with line renderer ? // [TODO] still cast shadows (semitransparent objects don't cast shadows, apparently) // [TODO] maybe render solid when not obscured by objects? use raycast in PreRender? AssignSOMaterial(shapeMaterial); // need to do this to setup BaseSO material stack pivotGO = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("Pivot")); creation_size = size; shapeGO = create_pivot_shape(); AppendNewGO(shapeGO, pivotGO, false); pivotGO.AddChild(shapeGO); if (frameMaterial != null) { this.frameMaterial = frameMaterial; fMaterial mat = MaterialUtil.ToMaterialf(frameMaterial); frameGO = UnityUtil.CreateMeshGO("pivotFrame", "icon_meshes/axis_frame", size, UnityUtil.MeshAlignOption.NoAlignment, mat, false); MaterialUtil.SetIgnoreMaterialChanges(frameGO); MaterialUtil.DisableShadows(frameGO); AppendNewGO(frameGO, pivotGO, false); } if (nShapeLayer >= 0) { shapeGO.SetLayer(nShapeLayer); } increment_timestamp(); return(this); }
// creates a button in the desired geometry shape public void Create() { entry = new GameObject(UniqueNames.GetNext("HUDTextEntry")); Mesh mesh = MeshGenerators.CreateTrivialRect(Width, Height, MeshGenerators.UVRegionType.FullUVSquare); backgroundMaterial = MaterialUtil.CreateFlatMaterialF(BackgroundColor); activeBackgroundMaterial = MaterialUtil.CreateFlatMaterialF(ActiveBackgroundColor); bgMesh = AppendMeshGO("background", mesh, backgroundMaterial, entry); bgMesh.transform.Rotate(Vector3.right, -90.0f); // ?? BoxPosition horzAlign = BoxPosition.CenterLeft; if (AlignmentHorz == HorizontalAlignment.Center) { horzAlign = BoxPosition.Center; } else if (AlignmentHorz == HorizontalAlignment.Right) { horzAlign = BoxPosition.CenterRight; } textMesh = GameObjectFactory.CreateTextMeshGO( "text", Text, TextColor, TextHeight, horzAlign, SceneGraphConfig.TextLabelZOffset); Vector2f toPos = BoxModel.GetBoxPosition(this, horzAlign); BoxModel.Translate(textMesh, Vector2f.Zero, toPos); AppendNewGO(textMesh, entry, false); cursor = GameObjectFactory.CreateRectangleGO("cursor", Height * 0.1f, Height * 0.8f, Colorf.VideoBlack, false); BoxModel.Translate(cursor, Vector2f.Zero, this.Bounds2D.CenterLeft, -Height * 0.1f); cursor.RotateD(Vector3f.AxisX, -90.0f); AppendNewGO(cursor, entry, false); cursor.SetVisible(false); }
public void Create() { rootGO = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("TransientXForm")); increment_timestamp(); }