Beispiel #1
0
        public MultiPointTool(FScene scene, SceneObject target)
        {
            this.Scene = scene;
            TargetSO   = target;

            // do this here ??
            behaviors = new InputBehaviorSet();
            behaviors.Add(
                new MultiPointTool_2DBehavior(scene.Context, this)
            {
                Priority = 5
            });
            if (FPlatform.IsUsingVR())
            {
                behaviors.Add(
                    new MultiPointTool_SpatialBehavior(scene.Context, this)
                {
                    Priority = 5
                });
            }

            Indicators       = new ToolIndicatorSet(this, scene);
            IndicatorBuilder = new StandardIndicatorFactory();
            GizmoPoints      = new Dictionary <int, ControlPoint>();
            PointHitTestF    = PointIntersectionTest;
        }
Beispiel #2
0
        public static async void DoFileOpen(string sFilename, bool bInteractive, Action <string> onCompletedF = null)
        {
            if (string.IsNullOrEmpty(sFilename))
            {
                return;
            }
            if (File.Exists(sFilename) == false)
            {
                CotangentUI.ShowModalMessageDialog("File Does Not Exist",
                                                   "File " + sFilename + " does not exist",
                                                   "Ok", null, null);
                return;
            }

            HaveOpenedOrImportedFile = true;

            if (sFilename.EndsWith(".cota", StringComparison.OrdinalIgnoreCase))
            {
                // [TODO] make this multi threaded?
                OpenSceneFile(sFilename);
                FPlatform.SetPrefsString("LastImportPath", sFilename);
            }
            else
            {
                ClearScene();
                MeshImporter importer = new MeshImporter();
                CCStatus.BeginOperation("reading");
                await importer.ImportInteractive(sFilename, onCompletedF);

                CCStatus.EndOperation("reading");
            }
        }
Beispiel #3
0
        /// <summary>
        /// Request a copy of the internal curve from a background thread.
        /// If curve is dirty, this will block until it is computed in PreRender (which will then signal this thread).
        /// </summary>
        public DCurve3 RequestCurveCopyFromBGThread()
        {
            if (FPlatform.InMainThread())
            {
                throw new Exception("ThreadSafePolyCurveSO.RequestCurveCopyFromBGThread: called from main thread!");
            }

            bool wait_for_compute = false;

            lock (curve_copy_lock) {
                if (curve_copy == null || this.curve.Timestamp != curve_timestamp || target_model_modified)
                {
                    wait_for_compute = true;
                }
            }
            if (wait_for_compute)
            {
                waiter.WaitOne();
            }

            DCurve3 result;

            lock (curve_copy_lock) {
                result           = new DCurve3(curve_copy);
                result.Timestamp = curve_copy.Timestamp;
            }
            return(result);
        }
 override public bool BeginCapture(InputEvent e)
 {
     if (Enabled && HasGO(e.hit.hitGO) && in_drag == false)
     {
         if (last_click_time != 0 &&
             (FPlatform.RealTime() - last_click_time) < SceneGraphConfig.ActiveDoubleClickDelay)
         {
             in_double_click = true;
         }
         else
         {
             hitFrame = cockpit.GetLocalFrame(CoordSpace.WorldCoords);
             float fRayT = 0.0f;
             if (RayIntersection.Sphere(e.ray.Origin, e.ray.Direction, hitFrame.Origin, IndicatorDistance, out fRayT) == false)
             {
                 return(false);       // should not happen! but could.
             }
             startHitPos = e.ray.Origin + fRayT * e.ray.Direction;
             start_tilt  = cockpit.TiltAngle;
             start_shift = cockpit.ShiftAngle;
             in_drag     = true;
         }
         return(true);
     }
     return(false);
 }
 public void Update()
 {
     if (FPlatform.RealTime() - start_time > 2.0)
     {
         base.TransitionVisibility(false);
     }
 }
Beispiel #6
0
        public static void ExportSocket()
        {
            if (OG.Model.HasSocket() == false)
            {
                return;
            }

            string filename = null;

            if (ShowExportDialogInEditor || FPlatform.InUnityEditor() == false)
            {
                filename = FPlatform.GetSaveFileName("Export Socket",
                                                     Path.Combine(ExportSocketPath, "socket.obj"), new string[] { "*.obj" }, "Mesh Files (*.OBJ)");
            }
            else
            {
                filename = Path.Combine(ExportSocketPath, "socket.obj");
            }
            if (filename == null)
            {
                return;
            }

            DMesh3           SocketMesh = new DMesh3(OG.Socket.Socket.Mesh);
            AxisAlignedBox3d bounds     = SocketMesh.CachedBounds;

            MeshTransforms.Translate(SocketMesh, -bounds.Min.y * Vector3d.AxisZ);
            MeshTransforms.FlipLeftRightCoordSystems(SocketMesh);   // convert from unity coordinate system

            WriteOptions opt = WriteOptions.Defaults;

            opt.bWriteGroups = true;
            StandardMeshWriter.WriteMesh(filename, SocketMesh, opt);
        }
Beispiel #7
0
        public override Capture UpdateCapture(InputState input, CaptureData data)
        {
            Vector2f      vDelta = input.StickDelta2D((int)data.which);
            internal_data d      = data.custom_data as internal_data;

            if (vDelta[0] < -0.75f)
            {
                if (d.last_sent_time == -1 || d.last_direction > 0 || FPlatform.RealTime() - d.last_sent_time > RepeatTime)
                {
                    Cycle(-1);
                    d.last_sent_time = FPlatform.RealTime();
                    d.last_direction = -1;
                }
            }
            else if (vDelta[0] > 0.75f)
            {
                if (d.last_sent_time == -1 || d.last_direction < 0 || FPlatform.RealTime() - d.last_sent_time > RepeatTime)
                {
                    Cycle(1);
                    d.last_sent_time = FPlatform.RealTime();
                    d.last_direction = 1;
                }
            }

            if (vDelta[StickAxis] == 0)
            {
                return(Capture.End);
            }

            return(Capture.Continue);
        }
Beispiel #8
0
        void initialize_db()
        {
            // if settings database does not exist, generate it
            if (Directory.Exists(cotangent.CCOptions.SettingsDBPath) == false)
            {
                populate_defaults();
                SettingsSerializer serializer = new SettingsSerializer();
                serializer.GenerateSettingsFolder(this, cotangent.CCOptions.SettingsDBPath);
                reset_db();
            }

            try {
                DebugUtil.Log("Reading settings database from {0}", cotangent.CCOptions.SettingsDBPath);
                populate_from_disk(cotangent.CCOptions.SettingsDBPath);
            } catch (Exception e) {
                DebugUtil.Log("MachineDatabase: fatal exception restoring : " + e.Message);
                if (FPlatform.InUnityEditor())
                {
                    throw;
                }
            }

            // [TODO] sync w/ new known settings?
            List <MachinePreset> new_defaults = populate_defaults();

            foreach (var preset in new_defaults)
            {
                SettingsSerializer serializer  = new SettingsSerializer();
                Manufacturer       mfg         = FindManufacturerByUUID(preset.Settings.BaseMachine.ManufacturerUUID);
                MachineModel       model       = FindModelByUUID(mfg, preset.Settings.BaseMachine.ModelUUID);
                string             machinePath = serializer.CreateNewSettingsFolder(this, mfg, model, cotangent.CCOptions.SettingsDBPath);
                preset.SourcePath = Path.Combine(machinePath, preset.Settings.Identifier + ".txt");
                serializer.StoreSettings(this, preset, true);
            }
        }
Beispiel #9
0
        public static void DoGCodeExport(string sFilename)
        {
            if (sFilename != null && sFilename.Length > 0)
            {
                if (string.IsNullOrEmpty(Path.GetExtension(sFilename)))
                {
                    sFilename = sFilename + ".gcode";
                }

                StandardGCodeWriter writer = new StandardGCodeWriter();
                using (StreamWriter w = new StreamWriter(sFilename)) {
                    writer.WriteFile(CC.Toolpather.CurrentGCode, w);
                }

                CotangentAnalytics.ExportGCode();

                if (CC.PrinterDB.ActivePreset.Settings is gs.info.ISailfishSettings)
                {
                    gs.info.ISailfishSettings sailfish = CC.PrinterDB.ActivePreset.Settings as gs.info.ISailfishSettings;
                    Task.Run(() => {
                        string GPX_PATH = Path.Combine(FPlatform.GameExecutablePath(), "utilities/gpx.exe");
                        string args     = sailfish.GPXModelFlag + " -p " + sFilename;
                        DebugUtil.Log("Running " + GPX_PATH + " " + args);
                        System.Diagnostics.Process.Start(GPX_PATH, args);
                    });
                }
            }
        }
    void on_export_always()
    {
        FPlatform.SetPrefsInt("WarnAboutGCodeExport", 1);

        CC.ActiveContext.RegisterNextFrameAction(() => {
            CCActions.DoGCodeExportInteractive();
        });
        this.gameObject.Destroy();
    }
    // Use this for initialization
    public void Start()
    {
        dismissButton = UnityUIUtil.FindButtonAndAddClickHandler(this.gameObject, "DimissButton", dismiss_on_click);
        start_time    = FPlatform.RealTime();

        if (FPlatform.InUnityEditor())
        {
            dismiss_on_click();
        }
    }
Beispiel #12
0
        public static void DoFileDialogImport()
        {
            Action <string> onCompletedF = (filename) => {
                FPlatform.SetPrefsString("LastImportPath", filename);
                CC.ActiveScene.History.PushInteractionCheckpoint();
                CCActions.UpdateViewClippingBounds();
            };

            FPlatform.GetOpenFileName_Async("Select File", "", new string[] { "*.stl", "*.obj" }, "Supported Files (.stl, .obj)",
                                            (sFilename) => { DoFileImport(sFilename, true, onCompletedF); });
        }
Beispiel #13
0
 public static void SetCurrentSaveFilePath(string sPath)
 {
     current_scene_filename = sPath;
     if (HaveActiveSaveFile)
     {
         string filename = Path.GetFileName(sPath);
         FPlatform.SetWindowTitle(filename);
     }
     else
     {
         FPlatform.SetWindowTitle(string.Format("cotangent {0}", CotangentVersion.CurrentVersionString));
     }
 }
    // Use this for initialization
    void Start()
    {
        FPlatform.InitializeMainThreadID();          // for DebugUtil.EmitDebug()

        mainCanvas = GameObject.Find("UICanvas").GetComponent <Canvas>();

        trackButton = GameObject.Find("TrackButton").GetComponent <Button>();
        trackButton.onClick.AddListener(track_click);

        resetButton = GameObject.Find("ResetButton").GetComponent <Button>();
        resetButton.onClick.AddListener(reset_click);

        sizeButton = GameObject.Find("SizeButton").GetComponent <Button>();
        sizeButton.onClick.AddListener(size_click);

        curSize           = SizeMode.cm_2;
        gsGlobal.GridSize = 0.02f;
        sizeButton.GetComponentInChildren <Text>().text = "2cm";

        viewDropDown = GameObject.Find("ViewModeDropDown").GetComponent <Dropdown>();
        viewDropDown.onValueChanged.AddListener(view_changed);

        debugText      = GameObject.Find("DebugText").GetComponent <Text>();
        debugText.text = "";
        GameObject.Find("DebugTextCloseButton").GetComponent <Button>().onClick.AddListener(hide_error_text);
        debugText.gameObject.SetVisible(false);
        gsGlobal.TextErrorHandlerF = set_error_text;


        GameObject simulateButtonGO = UnityUtil.FindGameObjectByName("SimulateButton");

        if (FPlatform.InUnityEditor())
        {
            simulateButtonGO.SetVisible(true);
            simulateButtonGO.GetComponent <Button>().onClick.AddListener(simulate_ar);
        }

        optionsButton = GameObject.Find("OptionsButton").GetComponent <Button>();
        optionsButton.onClick.AddListener(options_click);

        UnityUtil.FindGameObjectByName("OptionSaveARStream").GetComponent <Toggle>().
        onValueChanged.AddListener(option_savearstream_changed);
        UnityUtil.FindGameObjectByName("OptionSaveVideoStream").GetComponent <Toggle>().
        onValueChanged.AddListener(option_save_video_stream_changed);
        qualityDropDown = UnityUtil.FindGameObjectByName("OptionQualityDropDown").GetComponent <Dropdown>();
        qualityDropDown.onValueChanged.AddListener(on_quality_changed);

        optionsPanel = UnityUtil.FindGameObjectByName("OptionsPanel");
        optionsPanel.SetVisible(false);
    }
Beispiel #15
0
        public static void AcceptAndExitCurrentTool()
        {
            if (InTool)
            {
                ITool tool = CC.ActiveContext.ToolManager.ActiveRightTool;
                if (tool.HasApply && tool.CanApply)
                {
                    tool.Apply();
                }
                CancelCurrentTool();

                // run gc
                FPlatform.SuggestGarbageCollection();
            }
        }
Beispiel #16
0
 override public bool EndCapture(InputEvent e)
 {
     if (in_double_click)
     {
         tracker.IsLocked = !tracker.IsLocked;
         last_click_time  = 0.0f;
         in_double_click  = false;
     }
     else
     {
         in_drag         = false;
         last_click_time = FPlatform.RealTime();
     }
     return(true);
 }
Beispiel #17
0
        protected void UpdatePreferences()
        {
            FPlatform.SetPrefsString("LastManufacturer", ActiveManufacturer.UUID);
            FPlatform.SetPrefsString("LastMachine", ActiveMachine.UUID);
            FPlatform.SetPrefsString("LastPreset", ActivePreset.Settings.Identifier);

            StringBuilder disabledList = new StringBuilder();

            foreach (var mfg in DisabledManufacturers)
            {
                disabledList.Append(mfg.UUID); disabledList.Append(";");
            }
            ;
            FPlatform.SetPrefsString("DisabledManufacturers", disabledList.ToString());
        }
Beispiel #18
0
        protected void RestorePreferences()
        {
            // do this first because setting preset will replace this
            DisabledManufacturers = new List <Manufacturer>();
            string disabled_list = FPlatform.GetPrefsString("DisabledManufacturers", "");

            string[] disabled_uuids = disabled_list.Split(';');
            foreach (var uuid in disabled_uuids)
            {
                Manufacturer mfg = FindManufacturerByUUID(uuid);
                if (mfg != null)
                {
                    DisabledManufacturers.Add(mfg);
                }
            }


            string last_mfg_uuid     = FPlatform.GetPrefsString("LastManufacturer", ActiveManufacturer.UUID);
            string last_machine_uuid = FPlatform.GetPrefsString("LastMachine", ActiveMachine.UUID);
            string last_preset_id    = FPlatform.GetPrefsString("LastPreset", ActivePreset.Settings.Identifier);

            if (last_preset_id != ActivePreset.UUID)
            {
                Manufacturer mfg = MachineDB.FindManufacturerByUUID(last_mfg_uuid);
                if (mfg != null)
                {
                    SelectManufacturer(mfg);
                    MachineModel model = MachineDB.FindModelByUUID(mfg, last_machine_uuid);
                    if (model != null)
                    {
                        SelectMachine(model);
                        MachinePreset preset = MachineDB.FindPresetByIdentifier(model, last_preset_id);
                        if (preset != null)
                        {
                            CC.ActiveContext.RegisterNthFrameAction(2, () => {
                                SelectPreset(preset, true);
                            });
                        }
                    }
                }
            }
            else
            {
                CC.ActiveContext.RegisterNthFrameAction(2, () => {
                    SelectPreset(ActivePreset, true);
                });
            }
        }
Beispiel #19
0
        public static void CancelCurrentTool()
        {
            if (InTool == false)
            {
                return;
            }

            if (CCStatus.InOperation)
            {
                CCStatus.EndOperation("working...");
            }
            CC.ActiveContext.ToolManager.DeactivateTool(ToolSide.Right);

            // run gc
            FPlatform.SuggestGarbageCollection();
        }
Beispiel #20
0
 public static void ShowSplashScreen(int MaxFreqInMinutes = 5)
 {
     if (FPlatform.InUnityEditor() == false)
     {
         int      last_splash_mins = FPlatform.GetPrefsInt("LastSplashTime", 0);
         TimeSpan now_span         = DateTime.Now - new DateTime(2018, 1, 1);
         int      cur_mins         = (int)now_span.TotalMinutes;
         double   mins_elapsed     = cur_mins - last_splash_mins;
         //DebugUtil.Log("ticks now {0}  saved {1}   spansec {2}", cur_mins, last_splash_mins, mins_elapsed);
         if (mins_elapsed > MaxFreqInMinutes)
         {
             GameObject splash_screen = GameObject.Instantiate <GameObject>(Resources.Load <GameObject>("SplashScreenPanel"));
             CotangentUI.MainUICanvas.AddChild(splash_screen, false);
             FPlatform.SetPrefsInt("LastSplashTime", cur_mins);
         }
     }
 }
Beispiel #21
0
        public static void DoGCodeExport()
        {
            if (CC.Toolpather.CurrentGCode == null)
            {
                HUDUtil.ShowCenteredPopupMessage("Sorry", "Cannot Export GCode until Toolpaths are generated!", CC.ActiveCockpit);
                return;
            }

            int skipWarning = FPlatform.GetPrefsInt("WarnAboutGCodeExport", 0);

            if (skipWarning == 0)
            {
                ExportGCodeWarningDialog.ShowDialog();
            }
            else
            {
                DoGCodeExportInteractive();
            }
        }
Beispiel #22
0
        public static void RestorePreferences()
        {
            camera_mode =
                (CameraModes)FPlatform.GetPrefsInt("CameraMode", (int)CameraModes.Perspective);
            startup_workspace =
                (AppViewMode)FPlatform.GetPrefsInt("StartupWorkspace", (int)AppViewMode.PrintView);
            graphics_quality =
                (GraphicsQualityLevels)FPlatform.GetPrefsInt("GraphicsQuality", (int)GraphicsQualityLevels.Max);


            import_xform_mode =
                (ImportTransformModes)FPlatform.GetPrefsInt("ImportTransformMode", (int)ImportTransformModes.AutoCenterFirst);
            import_assistant_mode =
                (ImportAssistantModes)FPlatform.GetPrefsInt("ImportAssistantMode", (int)ImportAssistantModes.All);
            large_mesh_import_threshold =
                FPlatform.GetPrefsInt("LargeMeshImportThreshold", 250000);

            default_slicing_mode =
                (SlicingUpdateModes)FPlatform.GetPrefsInt("DefaultSlicingUpdateMode", (int)SlicingUpdateModes.SliceOnDemand);
            active_slicing_mode = default_slicing_mode;
        }
    System.Collections.IEnumerator enable_drag_drop()
    {
        yield return(new WaitForSeconds(2));

        bool bEnableDragDrop = (FPlatform.InUnityEditor() == false && FPlatform.GetDeviceType() == FPlatform.fDeviceType.WindowsDesktop);

        bEnableDragDrop = true;
        if (bEnableDragDrop)
        {
            Context.RegisterNextFrameAction(() => {
                if (FPlatform.InUnityEditor())
                {
                    DragDropHandler.Initialize();
                }
                else
                {
                    DragDropHandler.Initialize(WinAPI.GetCurrentThreadId(), "UnityWndClass");   // is this necessary?
                }
                DragDropHandler.OnDroppedFilesEvent += CCActions.DoDragDropImport;
            });
        }
    }
Beispiel #24
0
        public TwoPointMeasureTool(FScene scene, List <SceneObject> targets)
        {
            this.scene      = scene;
            SpecificTargets = (targets == null) ? null : new List <SceneObject>(targets);

            setPointsS        = new Vector3d[2];
            setPointsS[0]     = setPointsS[1] = Vector3d.Zero;
            snappedPointsS    = new Vector3d[2];
            snappedPointsS[0] = snappedPointsS[1] = Vector3d.Zero;
            point_initialized = new bool[2] {
                false, false
            };

            behaviors = new InputBehaviorSet();
            if (FPlatform.IsUsingVR())
            {
                behaviors.Add(new TwoPointMeasureTool_SpatialDeviceBehavior(scene.Context, this)
                {
                    Priority = 5
                });
            }
            if (FPlatform.IsTouchDevice())
            {
                behaviors.Add(new TwoPointMeasureTool_TouchBehavior(scene.Context, this)
                {
                    Priority = 5
                });
            }
            behaviors.Add(
                new TwoPointMeasureTool_MouseBehavior(scene.Context, this)
            {
                Priority = 5
            });

            // shut off transform gizmo
            scene.Context.TransformManager.PushOverrideGizmoType(TransformManager.NoGizmoType);
            scene.SelectionChangedEvent += Scene_SelectionChangedEvent;
        }
Beispiel #25
0
        public void Begin(GCodeFile gcode)
        {
            GCode = gcode;

            listener = new GCodeAnimationLister();
            listener.OnBeginDepositF = OnBeginDepositF;
            listener.OnBeginTravelF  = OnBeginTravelF;
            listener.OnMoveToAtTimeF = OnMoveToAtTimeF;
            listener.SpeedScale      = SpeedUnitsToMMPerSec;

            interp = new MakerbotInterpreter();
            interp.AddListener(listener);
            active_anim = interp.InterpretInteractive(GCode, InterpretArgs.Default).GetEnumerator();
            isFinished  = false;

            LaserGO       = GameObjectFactory.CreateLineGO("laser", Colorf.VideoRed, 0.5f, LineWidthType.World);
            HeatParticles = new PrintTempParticleSystem(CC.ActiveScene.RootGameObject);

            StartTime       = FPlatform.RealTime();
            CurrentPosition = Vector3d.Zero;
            PrevPosition    = Vector3d.Zero;
            PrevTime        = 0;
        }
Beispiel #26
0
        public void Update()
        {
            double time = FPlatform.RealTime() - StartTime;

            while (NextTime < time)
            {
                PrevPosition = NextPosition;
                PrevTime     = NextTime;

                update_heat_display((Vector3f)PrevPosition, PrevTime);
                bool bContinue = active_anim.MoveNext();
                if (bContinue == false)
                {
                    isFinished = true;
                    return;
                }
            }
            double   dt        = (time - PrevTime) / (NextTime - PrevTime);
            Vector3d interpPos = (1.0 - dt) * PrevPosition + (dt) * NextPosition;

            //CurrentPosition = NextPosition;
            //CurrentTime = NextTime;
            update_pos((Vector3f)interpPos, time);
        }
Beispiel #27
0
 public void Update()
 {
     if (CCStatus.InOperation)
     {
         if (statusBG.IsVisible() == false)
         {
             statusBG.SetVisible(true);
             statusText.text = CCStatus.CurrentOperation;
             start_time      = FPlatform.RealTime();
         }
         else
         {
             double cur_time = FPlatform.RealTime();
             double dt       = cur_time - start_time;
             double t        = (Math.Cos(frequency * dt) + 1) * 0.5;
             Colorf c        = Colorf.Lerp(color1, color2, (float)t);
             statusBGImage.color = c;
         }
     }
     else
     {
         statusBG.SetVisible(false);
     }
 }
Beispiel #28
0
 bool time_to_start_new_compute()
 {
     return(FPlatform.RealTime() - last_spawn_time > 0.5);
 }
    // Use this for initialization
    public override void Awake()
    {
        base.Awake();

        // if we need to auto-configure Rift vs Vive vs (?) VR, we need
        // to do this before any other F3 setup, because MainCamera will change
        // and we are caching that in a lot of places...
        if (AutoConfigVR)
        {
            VRCameraRig = gs.VRPlatform.AutoConfigureVR();
        }

        // add splash screen
        CCActions.ShowSplashScreen();

        // restore any settings
        SceneGraphConfig.RestorePreferences();
        CCPreferences.RestorePreferences();
        if (CCPreferences.CameraMode == CCPreferences.CameraModes.Orthographic)
        {
            Camera.main.orthographic = true;
        }

        // set up some defaults
        // this will move the ground plane down, but the bunnies will be floating...
        //SceneGraphConfig.InitialSceneTranslate = -4.0f * Vector3f.AxisY;
        SceneGraphConfig.InitialSceneTranslate          = Vector3f.Zero;
        SceneGraphConfig.DefaultSceneCurveVisualDegrees = 0.5f;
        SceneGraphConfig.DefaultPivotVisualDegrees      = 0.5f;
        SceneGraphConfig.DefaultAxisGizmoVisualDegrees  = 7.5f;
        SceneGraphConfig.CameraPivotVisualDegrees       = 0.3f;

        if (FPlatform.InUnityEditor())
        {
            Util.DebugBreakOnDevAssert = false;     // throw exception on gDevAssert
        }
        SceneOptions options = new SceneOptions();

        options.UseSystemMouseCursor  = true;
        options.Use2DCockpit          = true;
        options.ConstantSize2DCockpit = true;
        options.EnableTransforms      = true;
        options.EnableCockpit         = true;
        options.CockpitInitializer    = new SetupPrintCockpit();

        options.EnableDefaultLighting = true;

        options.MouseCameraControls = new MayaExtCameraHotkeys()
        {
            MouseOrbitSpeed = 5.0f, MousePanSpeed = 0.01f, MouseZoomSpeed = 0.1f, UseAdaptive = true
        };
        options.SpatialCameraRig = VRCameraRig;

        options.DefaultGizmoBuilder = new AxisTransformGizmoBuilder()
        {
            ScaleSpeed = 0.03f, TranslateSpeed = 1.0f
        };

        // very verbose
        options.LogLevel = 4;

        CCMaterials.InitializeMaterials();

        context = new FContext();
        CotangentUI.Initialize(context);   // have to do this before cockpit is configured, which currently
                                           // happens automatically on .Start() (which is dumb...)
        context.Start(options);

        CCMaterials.SetupSceneMaterials(context);

        // if you had other gizmos, you would register them here
        //context.TransformManager.RegisterGizmoType("snap_drag", new SnapDragGizmoBuilder());
        //controller.TransformManager.SetActiveGizmoType("snap_drag");
        //context.TransformManager.RegisterGizmoType(CotangentTypes.SlicePlaneHeightGizmoType, new SlicePlaneHeightGizmoBuilder() {
        //    Factory = new SlicePlaneHeightGizmoBuilder.WidgetFactory(), GizmoVisualDegrees = 4.0f, GizmoLayer = FPlatform.GeometryLayer
        //});
        //context.TransformManager.AddTypeFilter(SlicePlaneHeightGizmoBuilder.MakeTypeFilter());

        // if you had other tools, you would register them here.
        context.ToolManager.RegisterToolType(DrawPrimitivesTool.Identifier, new DrawPrimitivesToolBuilder());
        context.ToolManager.RegisterToolType(SetZLayerTool.Identifier, new SetZLayerToolBuilder());
        CCActions.InitializeCotangentScene(context);
        CCActions.InitializePrintTools(context);
        CCActions.InitializeRepairTools(context);
        CCActions.InitializeModelTools(context);
        context.ToolManager.SetActiveToolType(DrawPrimitivesTool.Identifier, ToolSide.Right);

        // Set up standard scene lighting if requested
        if (options.EnableDefaultLighting)
        {
            GameObject lighting = GameObject.Find("SceneLighting");
            if (lighting == null)
            {
                lighting = new GameObject("SceneLighting");
            }
            SceneLightingSetup setup = lighting.AddComponent <SceneLightingSetup>();
            setup.Context          = context;
            setup.LightDistance    = 200; // related to total scene scale...
            setup.LightCount       = 4;
            setup.ShadowLightCount = 1;
        }


        //GameObjectFactory.CurveRendererSource = new VectrosityCurveRendererFactory();


        // set up selection material
        context.Scene.SelectedMaterial = CCMaterials.SelectedMaterial;


        /*
         * Import elements of Unity scene that already exist into the FScene
         */

        // set up ground plane geometry (optional)
        GameObject boundsObject = GameObject.Find("PrintBed");

        if (boundsObject != null)
        {
            context.Scene.AddWorldBoundsObject(boundsObject);
            CC.PrinterBed = boundsObject;
        }

        CC.Initialize(context);


        if (StartupPart != null)
        {
            StartupPart.name = "Cylinder";
            DMeshSO startupSO = (DMeshSO)UnitySceneUtil.ImportExistingUnityGO(StartupPart, context.Scene, true, true, false,
                                                                              (mesh, material) => {
                PrintMeshSO so = new PrintMeshSO();
                return(so.Create(mesh, CCMaterials.PrintMeshMaterial));
            }
                                                                              );
            GameObject.Destroy(StartupPart);

            CC.Objects.AddPrintMesh(startupSO as PrintMeshSO);
            CCActions.StartupObjectUUID = CC.Objects.PrintMeshes[0].UUID;
        }


        //if (StartupPrintHead != null) {
        //    SceneObject wrapSO = UnitySceneUtil.WrapAnyGameObject(StartupPrintHead, context, false);
        //    CC.PrintHeadSO = wrapSO;
        //    SceneUtil.SetVisible(wrapSO, false);
        //}

        Context.ActiveCamera.Manipulator().SceneOrbit(Context.Scene, context.ActiveCamera, -25, -25);

        CCActions.SwitchToViewMode(CCPreferences.StartupWorkspace, true);

        // enable drag-drop on windows when not in editor
        StartAnonymousCoroutine(enable_drag_drop());

        // import command-line args
        CCActions.DoArgumentsImport(Environment.GetCommandLineArgs());

        // start auto-update check
        if (FPlatform.InUnityEditor() == false)
        {
            StartAnonymousCoroutine(auto_update_check());
        }

        // set window title
        FPlatform.SetWindowTitle(string.Format("cotangent {0}", CotangentVersion.CurrentVersionString));

        // show privacy dialog soon
        Context.RegisterNthFrameAction(100, CCActions.ShowPrivacyDialogIfRequired);
    }
Beispiel #30
0
 void mark_spawn_time()
 {
     last_spawn_time = FPlatform.RealTime();
 }