void enable_circle_indicator(bool enable) { if (enable == false && circle_indicator == null) { return; } if (enable && circle_indicator == null) { LineSet lines = new LineSet(); lines.UseFixedNormal = true; lines.FixedNormal = Vector3f.AxisY; DCurve3 curve = new DCurve3(Polygon2d.MakeCircle(gizmoInitialRadius, 64), 0, 2); lines.Curves.Add(curve); lines.Width = 1.0f; lines.WidthType = LineWidthType.Pixel; lines.Segments.Add( new Segment3d(Vector3d.Zero, gizmoInitialRadius * diagonals[nRotationAxis])); lines.Color = Colorf.DimGrey; circle_indicator = new fLineSetGameObject(new GameObject(), lines, "circle"); circle_indicator.SetLayer(FPlatform.WidgetOverlayLayer, true); circle_indicator.SetLocalRotation(Quaternionf.FromTo(Vector3f.AxisY, Frame3f.Identity.GetAxis(nRotationAxis))); RootGameObject.AddChild(circle_indicator, false); } circle_indicator.SetVisible(enable); }
public override void SetLayer(int nLayer) { base.SetLayer(nLayer); // [RMS] have to do this explicitly because currently the children are // GameObject, not fGameObject, so the fGameObject.SetLayer override will // not be called! if (grid_xy != null) { grid_xy.SetLayer(nLayer, true); } }
void enable_snap_indicator(bool enable) { if (enable == false && snap_indicator == null) { return; } if (enable && snap_indicator == null) { LineSet lines = new LineSet(); lines.UseFixedNormal = true; lines.FixedNormal = Vector3f.AxisY; int n = 360 / (int)SnapIncrementDeg; int n45 = 45 / (int)SnapIncrementDeg; int n90 = 90 / (int)SnapIncrementDeg; double r = gizmoInitialRadius; double r2 = gizmoInitialRadius * 1.05; double r45 = gizmoInitialRadius * 1.10; double r90 = gizmoInitialRadius * 1.175; for (int k = 0; k < n; ++k) { float angle = ((float)k / (float)n) * MathUtil.TwoPIf; double x = Math.Cos(angle), y = Math.Sin(angle); Vector3d v = new Vector3d(x, 0, y); v.Normalize(); double far_r = ((k + n45) % n90) == 0 ? r90 : (((k + n45) % n45) == 0 ? r45 : r2); lines.Segments.Add(new Segment3d(r * v, far_r * v)); } lines.Width = 1.0f; lines.WidthType = LineWidthType.Pixel; lines.Color = Colorf.DimGrey; snap_indicator = new fLineSetGameObject(new GameObject(), lines, "indicator"); snap_indicator.SetLayer(FPlatform.WidgetOverlayLayer, true); RootGameObject.AddChild(snap_indicator, false); } snap_indicator.SetVisible(enable); }