virtual public void Setup() { brushIndicator = new BrushCursorSphere() { PositionF = () => { return(lastBrushPosW.Origin); }, Radius = fDimension.World(() => { return(radius.WorldValue); }) }; primaryBrushMat = MaterialUtil.CreateTransparentMaterialF(Colorf.CornflowerBlue, 0.2f); secondaryBrushMat = MaterialUtil.CreateTransparentMaterialF(Colorf.ForestGreen, 0.2f); Indicators.AddIndicator(brushIndicator); brushIndicator.material = primaryBrushMat; }
public static HUDButton CreateGeometryIconClickButton(HUDShape shape, float fHUDRadius, float fAngleHorz, float fAngleVert, Colorf bgColor, IGameObjectGenerator addGeometry = null) { fMaterial mat = (bgColor.a == 1.0f) ? MaterialUtil.CreateStandardMaterialF(bgColor) : MaterialUtil.CreateTransparentMaterialF(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); }
public static HUDButton CreateMeshClickButton( fMesh mesh, Colorf color, float fMeshScale, Quaternionf meshRotation, HUDSurface hudSurf, float dx, float dy, IGameObjectGenerator addGeometry = null) { fMaterial mat = (color.a < 1.0f) ? MaterialUtil.CreateTransparentMaterialF(color, color.a) : MaterialUtil.CreateStandardMaterialF(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( fMesh mesh, Colorf color, float fMeshScale, Quaternionf meshRotation, float fHUDRadius, float fAngleHorz, float fAngleVert, IGameObjectGenerator addGeometry = null) { fMaterial mat = (color.a < 1.0f) ? MaterialUtil.CreateTransparentMaterialF(color, color.a) : MaterialUtil.CreateStandardMaterialF(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 SculptCurveTool(FScene scene, List <SceneObject> targets) { this.scene = scene; behaviors = new InputBehaviorSet(); // TODO is this where we should be doing this?? behaviors.Add( new SculptCurveTool_2DInputBehavior(this, scene.Context) { Priority = 5 }); behaviors.Add( new SculptCurveTool_SpatialBehavior(this, scene.Context) { Priority = 5 }); // shut off transform gizmo scene.Context.TransformManager.PushOverrideGizmoType(TransformManager.NoGizmoType); scene.SelectionChangedEvent += Scene_SelectionChangedEvent; // initialize active set with input selection Scene_SelectionChangedEvent(null, null); indicators = new ToolIndicatorSet(this, scene); brushIndicator = new BrushCursorSphere() { PositionF = () => { return(lastBrushPos.Origin); }, Radius = fDimension.World(() => { return(radius.WorldValue); }) }; moveSphereMat = MaterialUtil.CreateTransparentMaterialF(Colorf.CornflowerBlue, 0.2f); smoothSphereMat = MaterialUtil.CreateTransparentMaterialF(Colorf.ForestGreen, 0.2f); indicators.AddIndicator(brushIndicator); brushIndicator.material = moveSphereMat; SmoothAlpha = 0.15f; SmoothIterations = 5; }
public void Create(Cockpit cockpit) { base.Create(); this.cockpit = cockpit; float fHUDRadius = 0.7f; float fButtonRadius = 0.06f; Colorf bgColor = new Color(0.7f, 0.7f, 1.0f, 0.7f); Colorf activeColor = new Colorf(ColorUtil.SelectionGold, 0.7f); defaultMaterial = (bgColor.a == 1.0f) ? MaterialUtil.CreateStandardMaterialF(bgColor) : MaterialUtil.CreateTransparentMaterialF(bgColor); activeMaterial = (activeColor.a == 1.0f) ? MaterialUtil.CreateStandardMaterialF(activeColor) : MaterialUtil.CreateTransparentMaterialF(activeColor); List <toolInfo> toolNames = new List <toolInfo>() { new toolInfo() { identifier = "cancel", sMeshPath = "tool_icons/cancel", fMeshScaleFudge = 1.2f }, new toolInfo() { identifier = SnapDrawPrimitivesTool.Identifier, sMeshPath = "tool_icons/draw_primitive", fMeshScaleFudge = 1.2f }, new toolInfo() { identifier = DrawTubeTool.Identifier, sMeshPath = "tool_icons/draw_tube", fMeshScaleFudge = 1.2f }, new toolInfo() { identifier = DrawCurveTool.Identifier, sMeshPath = "tool_icons/draw_curve", fMeshScaleFudge = 1.2f }, new toolInfo() { identifier = DrawSurfaceCurveTool.Identifier, sMeshPath = "tool_icons/draw_surface_curve", fMeshScaleFudge = 1.2f }, new toolInfo() { identifier = RevolveTool.Identifier, sMeshPath = "tool_icons/revolve", fMeshScaleFudge = 1.2f }, new toolInfo() { identifier = TwoPointMeasureTool.Identifier, sMeshPath = "tool_icons/measure", fMeshScaleFudge = 1.2f }, new toolInfo() { identifier = SculptCurveTool.Identifier, sMeshPath = "tool_icons/sculpt_curve", fMeshScaleFudge = 1.2f }, new toolInfo() { identifier = PlaneCutTool.Identifier, sMeshPath = "tool_icons/plane_cut", fMeshScaleFudge = 1.2f } }; float fRight = -43.0f; float df = -11.0f; List <float> AngleSteps = new List <float>() { fRight, fRight + df, fRight + 2 * df }; float fVertStep = 11.0f; float fTop = 0.0f; int ri = 0, ci = 0; toolButtons = new List <ActivateToolButton>(); toolButtonInfo = new List <toolInfo>(); foreach (toolInfo t in toolNames) { float fX = AngleSteps[ci++]; float fY = fTop - (float)ri * fVertStep; if (ci == AngleSteps.Count) { ci = 0; ri++; } var button = add_tool_button(cockpit, t.identifier, fHUDRadius, fX, fY, fButtonRadius, t); AddChild(button); toolButtons.Add(button); toolInfo ti = new toolInfo(); ti = t; ti.button = button; toolButtonInfo.Add(ti); } // build indicators string[] paths = { "tool_icons/star_green", "tool_icons/star_red" }; for (int k = 0; k < 2; ++k) { Mesh iconMesh = null; Material iconMaterial = null; try { iconMesh = Resources.Load <Mesh>(paths[k]); iconMaterial = MaterialUtil.CreateStandardVertexColorMaterial(Color.white); } catch { } if (iconMesh == null) { iconMesh = UnityUtil.GetPrimitiveMesh(PrimitiveType.Sphere); iconMaterial = MaterialUtil.CreateStandardMaterial((k == 0) ? Color.green : Color.red); } indicator[k] = GameObject.CreatePrimitive(PrimitiveType.Sphere); indicator[k].name = (k == 0) ? "left_tool_star" : "right_tool_star"; Component.Destroy(indicator[k].GetComponent <Collider>()); indicator[k].SetMesh(iconMesh); indicator[k].GetComponent <Renderer>().material = iconMaterial; // have to add to some button because we need them to be in GO tree // when we do AddChild() on cockpit...that sets up layer, size, etc indicatorButton[k] = toolButtons[0]; indicator[k].transform.localScale = fIndicatorSize * Vector3.one; indicator[k].transform.localPosition += fIndicatorShiftXY * (Vector3.up + Vector3.right * ((k == 0) ? -1 : 1)) - fIndicatorShiftZ * Vector3.forward; indicatorButton[k].AppendNewGO(indicator[k], indicatorButton[k].RootGameObject, false); indicator[k].Hide(); } // listen for changes cockpit.Context.ToolManager.OnToolActivationChanged += on_tool_changed; }