public void Initialize(Cockpit cockpit) { Frame3 cockpitF = cockpit.GetLocalFrame(CoordSpace.WorldCoords); float fHUDRadius = 0.7f; Color bgColor = new Color(0.7f, 0.7f, 1.0f); Material bgMaterial = MaterialUtil.CreateTransparentMaterial(bgColor, 0.7f); Material primMaterial = MaterialUtil.CreateStandardMaterial(Color.yellow); HUDButton addCylinderButton = new HUDButton() { Radius = 0.08f }; addCylinderButton.Create(PrimitiveType.Cylinder, bgMaterial, primMaterial); Frame3 cylFrame = addCylinderButton.GetObjectFrame(); Frame3 cylHUDFrame = make_hud_sphere_frame(fHUDRadius, -45.0f, 0.0f); addCylinderButton.SetObjectFrame( cylFrame.Translated(cylHUDFrame.Origin) .Rotated(Quaternion.FromToRotation(cylFrame.Z, cylHUDFrame.Z))); addCylinderButton.OnClicked += (s, e) => { cockpit.Parent.Scene.AddCylinder(); }; cockpit.AddUIElement(addCylinderButton, true); HUDButton addBoxButton = new HUDButton() { Radius = 0.08f }; addBoxButton.Create(PrimitiveType.Cube, bgMaterial, primMaterial); Frame3 boxFrame = addBoxButton.GetObjectFrame(); Frame3 boxHUDFrame = make_hud_sphere_frame(fHUDRadius, -45.0f, -15.0f); addBoxButton.SetObjectFrame( boxFrame.Translated(boxHUDFrame.Origin) .Rotated(Quaternion.FromToRotation(boxFrame.Z, boxHUDFrame.Z))); addBoxButton.OnClicked += (s, e) => { cockpit.Parent.Scene.AddBox(); }; cockpit.AddUIElement(addBoxButton, true); }
public static HUDButton CreateIconClickButton(HUDShape shape, float fHUDRadius, float fAngleHorz, float fAngleVert, string icon, IGameObjectGenerator addGeometry = null) { Material mat = MaterialUtil.CreateTransparentImageMaterial(icon); HUDButton button = new HUDButton() { Shape = shape }; button.Create(mat); if (addGeometry != null) { button.AddVisualElements(addGeometry.Generate(), true); } HUDUtil.PlaceInSphere(button, fHUDRadius, fAngleHorz, fAngleVert); return(button); }
public static HUDButton CreateMeshClickButton( Mesh mesh, Color color, float fMeshScale, Quaternion meshRotation, HUDSurface hudSurf, float dx, float dy, IGameObjectGenerator addGeometry = null) { Material mat = (color.a < 1.0f) ? MaterialUtil.CreateTransparentMaterial(color, color.a) : MaterialUtil.CreateStandardMaterial(color); HUDButton button = new HUDButton(); button.Create(mesh, mat, fMeshScale, meshRotation); if (addGeometry != null) { button.AddVisualElements(addGeometry.Generate(), true); } hudSurf.Place(button, dx, dy); return(button); }
public static HUDButton CreateMeshClickButton( Mesh mesh, Color color, float fMeshScale, Quaternion meshRotation, float fHUDRadius, float fAngleHorz, float fAngleVert, IGameObjectGenerator addGeometry = null) { Material mat = (color.a < 1.0f) ? MaterialUtil.CreateTransparentMaterial(color, color.a) : MaterialUtil.CreateStandardMaterial(color); HUDButton button = new HUDButton(); button.Create(mesh, mat, fMeshScale, meshRotation); if (addGeometry != null) { button.AddVisualElements(addGeometry.Generate(), true); } HUDUtil.PlaceInSphere(button, fHUDRadius, fAngleHorz, fAngleVert); return(button); }
public static HUDButton CreateGeometryIconClickButton(HUDShape shape, float fHUDRadius, float fAngleHorz, float fAngleVert, Color bgColor, IGameObjectGenerator addGeometry = null) { Material mat = (bgColor.a == 1.0f) ? MaterialUtil.CreateStandardMaterial(bgColor) : MaterialUtil.CreateTransparentMaterial(bgColor); HUDButton button = new HUDButton() { Shape = shape }; button.Create(mat); if (addGeometry != null) { button.AddVisualElements(addGeometry.Generate(), true); } HUDUtil.PlaceInSphere(button, fHUDRadius, fAngleHorz, fAngleVert); return(button); }