コード例 #1
0
ファイル: ChangeSamples.cs プロジェクト: mcneel/RhinoCycles
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            Plugin.InitialiseCSycles();
            if (doc.Views.ActiveView.ActiveViewport.DisplayMode.Id == Guid.Parse("69E0C7A5-1C6A-46C8-B98B-8779686CD181"))
            {
                var rvp = doc.Views.ActiveView.RealtimeDisplayMode as RenderedViewport;

                if (rvp != null)
                {
                    var getNumber = new GetInteger();
                    getNumber.SetLowerLimit(1, true);
                    getNumber.SetDefaultInteger(rvp.HudMaximumPasses()+100);
                    getNumber.SetCommandPrompt("Set new sample count");
                    var getRc = getNumber.Get();
                    if (getNumber.CommandResult() != Result.Success) return getNumber.CommandResult();
                    if (getRc == GetResult.Number)
                    {
                        var nr = getNumber.Number();
                        RhinoApp.WriteLine($"User changes samples to {nr}");
                        rvp.ChangeSamples(nr);
                        return Result.Success;
                    }
                }
            }

            RhinoApp.WriteLine("Active view isn't rendering with Cycles");

            return Result.Nothing;
        }
コード例 #2
0
ファイル: SetDebugOptions.cs プロジェクト: mcneel/RhinoCycles
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            var getNumber = new GetInteger();
            getNumber.SetLowerLimit(2, false);
            getNumber.SetUpperLimit(10000000, false);
            getNumber.SetDefaultInteger(RcCore.It.EngineSettings.Samples);
            getNumber.SetCommandPrompt("Set Debug Options");

            var toggleVerbose = new OptionToggle(RcCore.It.EngineSettings.Verbose, "No", "Yes");
            var toggleInteractive = new OptionToggle(RcCore.It.EngineSettings.UseInteractiveRenderer, "No", "Yes");

            var spotlightFactor = new OptionDouble(RcCore.It.EngineSettings.SpotlightFactor, 0.0, 1000000.0);
            var pointlightFactor = new OptionDouble(RcCore.It.EngineSettings.PointlightFactor, 0.0, 1000000.0);
            var sunlightFactor = new OptionDouble(RcCore.It.EngineSettings.SunlightFactor, 0.0, 1000000.0);
            var arealightFactor = new OptionDouble(RcCore.It.EngineSettings.ArealightFactor, 0.0, 1000000.0);
            var polishFactor = new OptionDouble(RcCore.It.EngineSettings.PolishFactor, 0.0, 1000000.0);

            getNumber.AddOptionToggle("verbose", ref toggleVerbose);
            getNumber.AddOptionToggle("use_interactive_renderer", ref toggleInteractive);

            getNumber.AddOptionDouble("spotlight_factor", ref spotlightFactor);
            getNumber.AddOptionDouble("pointlight_factor", ref pointlightFactor);
            getNumber.AddOptionDouble("sunlight_factor", ref sunlightFactor);
            getNumber.AddOptionDouble("arealight_factor", ref arealightFactor);
            getNumber.AddOptionDouble("polish_factor", ref polishFactor);

            while (true)
            {
                var getRc = getNumber.Get();
                if (getNumber.CommandResult() != Result.Success) return getNumber.CommandResult();
                switch (getRc)
                {
                    case GetResult.Nothing:
                    case GetResult.Number:
                        RcCore.It.EngineSettings.Samples = getNumber.Number();
                        ReadOptions(toggleVerbose, toggleInteractive, spotlightFactor, pointlightFactor, sunlightFactor, arealightFactor, polishFactor);
                        break;
                    case GetResult.Option:
                        ReadOptions(toggleVerbose, toggleInteractive, spotlightFactor, pointlightFactor, sunlightFactor, arealightFactor, polishFactor);
                        continue;
                    default:
                        continue;
                }

                break;
            }
            return Result.Success;
        }
コード例 #3
0
    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
      var gi = new GetInteger();
      gi.SetCommandPrompt("New display precision");
      gi.SetDefaultInteger(doc.ModelDistanceDisplayPrecision);
      gi.SetLowerLimit(0, false);
      gi.SetUpperLimit(7, false);
      gi.Get();
      if (gi.CommandResult() != Result.Success)
        return gi.CommandResult();
      var distance_display_precision = gi.Number();

      if (distance_display_precision != doc.ModelDistanceDisplayPrecision)
        doc.ModelDistanceDisplayPrecision = distance_display_precision;

      return Result.Success;
    }
コード例 #4
0
ファイル: SetThreads.cs プロジェクト: mcneel/RhinoCycles
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            var getNumber = new GetInteger();
            getNumber.SetLowerLimit(0, false);
            getNumber.SetUpperLimit(Environment.ProcessorCount, false);
            getNumber.SetDefaultInteger(RcCore.It.EngineSettings.Threads);
            getNumber.SetCommandPrompt($"Set CPU render threads (max {Environment.ProcessorCount}, 0 for automatic)");
            var getRc = getNumber.Get();
            if (getNumber.CommandResult() != Result.Success) return getNumber.CommandResult();
            if (getRc == GetResult.Number)
            {
                var nr = getNumber.Number();
                var endS = nr != 1 ? "s" : "";
                RhinoApp.WriteLine($"User wants {nr} CPU thread{endS}");
                RcCore.It.EngineSettings.Threads = nr;
                return Result.Success;
            }

            return Result.Nothing;
        }
コード例 #5
0
ファイル: SelectDevice.cs プロジェクト: mcneel/RhinoCycles
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            Plugin.InitialiseCSycles();
            var getNumber = new GetInteger();
            getNumber.SetLowerLimit(-1, false);
            getNumber.SetUpperLimit((int)(Device.Count-1), false);
            getNumber.SetDefaultInteger(RcCore.It.EngineSettings.SelectedDevice);
            getNumber.SetCommandPrompt($"Select device to render on (-1 for default, 0-{Device.Count - 1})");
            var getRc = getNumber.Get();
            if (getNumber.CommandResult() != Result.Success) return getNumber.CommandResult();
            if (getRc == GetResult.Number)
            {
                var idx = getNumber.Number();
                Device dev = idx > -1 ? Device.GetDevice(idx) : Device.FirstCuda;
                RhinoApp.WriteLine($"User selected device {idx}: {dev}");
                RcCore.It.EngineSettings.SelectedDevice = idx;
                return Result.Success;
            }

            return Result.Nothing;
        }
コード例 #6
0
    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
      if (m_draw_conduit != null)
      {
        RhinoApp.WriteLine("Turn off existing arrowhead conduit");
        m_draw_conduit.Enabled = false;
        m_draw_conduit = null;
      }
      else
      {
        // get arrow head size
        var go = new GetOption();
        go.SetCommandPrompt("ArrowHead length in screen size (pixels) or world size (percentage of arrow length)?");
        go.AddOption("screen");
        go.AddOption("world");
        go.Get();
        if (go.CommandResult() != Result.Success)
          return go.CommandResult();

        int screen_size = 0;
        double world_size = 0.0;
        if (go.Option().EnglishName == "screen")
        {
          var gi = new GetInteger();
          gi.SetLowerLimit(0, true);
          gi.SetCommandPrompt("Length of arrow head in pixels");
          gi.Get();
          if (gi.CommandResult() != Result.Success)
            return gi.CommandResult();
          screen_size = gi.Number();
        }
        else
        {
          var gi = new GetInteger();
          gi.SetLowerLimit(0, true);
          gi.SetUpperLimit(100, false);
          gi.SetCommandPrompt("Length of arrow head in percentage of total arrow length");
          gi.Get();
          if (gi.CommandResult() != Result.Success)
            return gi.CommandResult();
          world_size = gi.Number() / 100.0;
        }


        // get arrow start and end points
        var gp = new GetPoint();
        gp.SetCommandPrompt("Start of line");
        gp.Get();
        if (gp.CommandResult() != Result.Success)
          return gp.CommandResult();
        var start_point = gp.Point();

        gp.SetCommandPrompt("End of line");
        gp.SetBasePoint(start_point, false);
        gp.DrawLineFromPoint(start_point, true);
        gp.Get();
        if (gp.CommandResult() != Result.Success)
          return gp.CommandResult();
        var end_point = gp.Point();

        var v = end_point - start_point;
        if (v.IsTiny(Rhino.RhinoMath.ZeroTolerance))
          return Result.Nothing;

        var line = new Line(start_point, end_point);

        m_draw_conduit = new DrawArrowHeadsConduit(line, screen_size, world_size);
        // toggle conduit on/off
        m_draw_conduit.Enabled = true;
        RhinoApp.WriteLine("Draw arrowheads conduit enabled.");
      }
      doc.Views.Redraw();
      return Result.Success;
    }