コード例 #1
0
 void Awake()
 {
     // retrieve the attached PanelOptions script
     panelOptions = GetComponent <PanelOptions>();
     // retrieve the attached SceneOptions script
     sceneOptions = GetComponent <SceneOptions>();
 }
コード例 #2
0
 public PlayerCollisionController(IMessageBroker messageBroker, ZenjectSceneLoader sceneLoader,
                                  INavigationGridAgentCollectorService agentCollectorService, SceneOptions sceneOptions)
 {
     _messageBroker         = messageBroker;
     _sceneLoader           = sceneLoader;
     _agentCollectorService = agentCollectorService;
     _sceneOptions          = sceneOptions;
 }
コード例 #3
0
        static async Task RunAllAsync(SceneOptions options)
        {
            var file = await OpenContainerAsync(options) as ISceneContainer;

            var scene = await file.GetSceneAsync();

            string dir = options.InputFile + ".extracted";

            Directory.CreateDirectory(dir);

            var mtlPath = Path.Combine(dir, "materials.mtl");

            using (var writer = File.CreateText(mtlPath))
            {
                writer.AutoFlush = true;
                foreach (var material in scene.Materials)
                {
                    WriteLine($"Extracting material with id: {material.Id}...");
                    await material.WriteToMTLAsync(writer);

                    WriteLine($"Wrote material with id: {material.Id} to {mtlPath}.", OutputImportance.Verbose);
                }
            }

            var texDir = Path.Combine(dir, "textures");

            Directory.CreateDirectory(texDir);

            foreach (var texture in scene.Textures)
            {
                WriteLine($"Extracting texture with id: {texture.Id}...");
                var image = await texture.ReadImageAsync();

                var texPath = Path.Combine(texDir, $"texture_{texture.Id}.png");
                await image.SaveAsPngAsync(texPath);

                WriteLine($"Wrote texture with id: {texture.Id} to {texPath}.", OutputImportance.Verbose);
            }

            var objPath = Path.Combine(dir, "scene.obj");

            using (var writer = File.CreateText(objPath))
            {
                writer.AutoFlush = true;

                await writer.WriteLineAsync("mtllib .\\materials.mtl");

                foreach (var obj in scene.Objects)
                {
                    WriteLine($"Extracting object with name: {obj.Name}...");
                    await obj.WriteToOBJAsync(writer);

                    WriteLine($"Wrote object with name: {obj.Name} to {objPath}.", OutputImportance.Verbose);
                }
            }

            Goodbye();
        }
コード例 #4
0
 public void NewScene(String sceneName, SceneOptions newSceneOption, int newStage)
 {
     _currentStage       = newStage;
     _menuCanvas.enabled = true;
     IsInScene           = sceneName;
     SceneManager.LoadScene(sceneName);
     //_nextSceneControl = true;
     LoadSceneOptions(newSceneOption);
 }
コード例 #5
0
        private NavigationActionGrid NavigationFactory(InjectContext ctx)
        {
            var target = SceneOptions.FindObjectOfType <NavigationActionGrid>();
            var grid   = target as NavigationActionGrid;

            grid.Graph            = ctx.Container.Resolve <IGraph>();
            grid.NeighborsService = ctx.Container.Resolve <IGraphNeighborsService>();
            return(target);
        }
コード例 #6
0
        static void Main(string[] args)
        {
            var sceneOptions = new SceneOptions
            {
                Height = 202,
                Width  = 600,
                Title  = "FireScene"
            };
            var scene = new FireScene(sceneOptions);

            scene.Run();
        }
コード例 #7
0
ファイル: Core.cs プロジェクト: StanislavMazanov/PixelSharpDx
        public Core()
        {
            var sceneOptions = new SceneOptions
            {
                Height = 600,
                Width  = 800,
                Title  = "Demoscena"
            };
            var scene = new MyScene(sceneOptions);

            scene.Run();
        }
コード例 #8
0
        public FireScene(SceneOptions sceneOptions) : base(sceneOptions)
        {
            _random     = new Random();
            _fireBuffer = new byte[WidthFire * HeightFire];

            // var col = 0;

            for (int i = 1; i <= WidthFire; i++)
            {
                _fireBuffer[i * HeightFire - 1] = 255;
            }
        }
コード例 #9
0
        private static IScene GetDefaultScene(SceneOptions options)
        {
            switch (options.DefaultScene)
            {
            case SceneOptions.BasicSceneType.Grid:
                return(GridScene.Instance);

            case SceneOptions.BasicSceneType.ActiveSpeaker:
                return(ActiveSpeakerScene.Instance);

            default:
                throw new ArgumentOutOfRangeException(nameof(options.DefaultScene), options.DefaultScene, null);
            }
        }
コード例 #10
0
    private void LoadSceneOptions(SceneOptions newSceneOption)
    {
        //SceneOptions newSceneOption = GameObject.FindGameObjectWithTag("SceneOptions").GetComponent<SceneOptions>();

        //Score Parameters

        _firstDiamondScore  = newSceneOption.firstDiamondScore;
        _secondDiamondScore = newSceneOption.secondDiamondScore;

        //Diamond Parameters
        _diamondsLeft = newSceneOption.diamondsNeeded;

        //Time Parameters
        _maxTime        = newSceneOption.maxTime;
        _timeStageStart = (int)Time.time;
    }
コード例 #11
0
ファイル: PlayManager.cs プロジェクト: Cryslo/EMSRisicoStage
    public static void PlayScene(FileInfo playScene)
    {
        if(File.Exists(playScene.FullName))
        {
            GameObject.Destroy(scene);
            scene = new GameObject("Scene");

            currentScene = scenes[sceneNumber];
            scenesDone.Add(scenes[sceneNumber].Name);

            print(playScene.Name);
            string notifyName = playScene.Name;
            Notify.notify(notifyName.Remove(notifyName.Length - 4));

            sceneOptions = XmlBehaviour.LoadScene(playScene.FullName, scene);
        }
    }
コード例 #12
0
ファイル: PlayManager.cs プロジェクト: Cryslo/EMSRisicoStage
    public static void PreviousScene()
    {
        if(sceneNumber > 0) {
            GameObject.Destroy(scene);
            scene = new GameObject("Scene");

            sceneNumber --;
            currentScene = scenes[sceneNumber];
            scenesDone.Add(scenes[sceneNumber].Name);
            string notifyName = scenes[sceneNumber].Name;
            Notify.notify(notifyName.Remove(notifyName.Length - 4));

            print(scenes[sceneNumber].Name);

            sceneOptions = XmlBehaviour.LoadScene(currentScene.FullName, scene);
        }else{
            Notify.notify("No Previous Scene");
        }
    }
コード例 #13
0
ファイル: PlayManager.cs プロジェクト: Cryslo/EMSRisicoStage
    public static void NextScene()
    {
        if(scenes.Count > sceneNumber + 1)
        {
            GameObject.Destroy(scene);
            scene = new GameObject("Scene");
            sceneNumber ++;
            currentScene = scenes[sceneNumber];
            scenesDone.Add(scenes[sceneNumber].Name);

            print(scenes[sceneNumber].Name);
            string notifyName = scenes[sceneNumber].Name;
            Notify.notify(notifyName.Remove(notifyName.Length - 4));

            sceneOptions = XmlBehaviour.LoadScene(currentScene.FullName, scene);
        }else{
            GameManager.queGameState = GameState.PlayMenu;
            GameManager.SetGameStateBack();
        }
    }
コード例 #14
0
ファイル: XmlBehaviour.cs プロジェクト: Cryslo/EMSRisicoStage
    public static SceneOptions LoadScene(string path, GameObject parent)
    {
        doc = new XmlDocument();
        loadedFireObjects = new List<Fire>();
        loadedGameObjects = new List<GameObject>();
        SceneOptions sceneOptions= new SceneOptions();

        XmlReaderSettings ReaderSettings = new XmlReaderSettings();
        ReaderSettings.IgnoreWhitespace = true;

        // Create an XmlReader
        //xmlDefaultPath + projectsMapName + tempName
        using(XmlReader reader = XmlReader.Create(path, ReaderSettings)) {
            doc.Load(reader);
            XmlElement root = doc.DocumentElement;
            // Create an XPathNavigator to use for the transform.
            XPathNavigator nav = root.CreateNavigator();

            #region SceneProperties
            XPathNodeIterator scenePropertiesNodus = nav.Select("/Scene/SceneProperties"); //Het pat dat hij moet afleggen in de XML File voor dat hij bij de juiste nodes is.
            while(scenePropertiesNodus.MoveNext()) { // Terwijl die elke keer volgende doet doet hij het volgende.
                XPathNavigator nodesNavigator = scenePropertiesNodus.Current; // hij begint vanaf het begin waar hij het path krijgt.

                XPathNodeIterator nodesText = nodesNavigator.SelectDescendants(XPathNodeType.Text, false);//maakt een variable aan die je kunt opvragen wat voor text er in staat.
                XPathNodeIterator scenePropertiesElement = nodesNavigator.SelectDescendants(XPathNodeType.Element, false);

                while(scenePropertiesElement.MoveNext()) { //pakt de volgende text.
                    //itemNodusElement.MoveNext();
                    //Debug.Log(itemNodusElement.Current.Name);
                    switch(scenePropertiesElement.Current.Name) {
                    case "TimerActive":
        //						print(scenePropertiesElement.Current.Value);
                        sceneOptions.timerActive = Convert.ToBoolean(scenePropertiesElement.Current.Value);
                        break;
                    case "Scenelength":
                        //print(scenePropertiesElement.Current.Value);
                        sceneOptions.scenelength = float.Parse(scenePropertiesElement.Current.Value);
                        break;
                    case "TimerVisable":
                        //print(scenePropertiesElement.Current.Value);
                        sceneOptions.timerVisable = Convert.ToBoolean(scenePropertiesElement.Current.Value);
                        break;
                    case "AudioNumber":
                        //print(scenePropertiesElement.Current.Value);
                        sceneOptions.audioNumber = Convert.ToInt16(scenePropertiesElement.Current.Value);
                        break;
                    case "BackgroundName":
                        //print(scenePropertiesElement.Current.Value);
                        sceneOptions.backgroundName = scenePropertiesElement.Current.Value;
                        break;

                    default:

                        break;
                    }

                }
            }
            #endregion

            #region SceneProperties
            XPathNodeIterator firesNodus = nav.Select("/Scene/Fires/Fire"); //Het pat dat hij moet afleggen in de XML File voor dat hij bij de juiste nodes is.
            while(firesNodus.MoveNext()) { // Terwijl die elke keer volgende doet doet hij het volgende.

                float posX = 0;
                float posY = 0;
                float posZ = 0;

                float rotationX = 0;
                float rotationY = 0;
                float rotationZ = 0;

                XPathNavigator nodesNavigator = firesNodus.Current; // hij begint vanaf het begin waar hij het path krijgt.

                XPathNodeIterator nodesText = nodesNavigator.SelectDescendants(XPathNodeType.Text, false);//maakt een variable aan die je kunt opvragen wat voor text er in staat.
                XPathNodeIterator FiresElement = nodesNavigator.SelectDescendants(XPathNodeType.Element, false);

                tempFire = new Fire();
                tempFire.obj = new GameObject();

                while(FiresElement.MoveNext()) { //pakt de volgende text.

                    //itemNodusElement.MoveNext();
                    switch(FiresElement.Current.Name) {
                    case "Name":
                        tempFire.obj.name = FiresElement.Current.Value;
                        break;
                    case "posX":
                        posX = float.Parse(FiresElement.Current.Value);
                        break;
                    case "posY":
        //						print("Test: " + FiresElement.Current.Value);
                        posY = float.Parse(FiresElement.Current.Value);
                        break;
                    case "posZ":
                        posZ = float.Parse(FiresElement.Current.Value);
                        break;
                    case "RotationX":
                        rotationX = float.Parse(FiresElement.Current.Value);
                        break;
                    case "RotationY":
                        rotationY = float.Parse(FiresElement.Current.Value);
                        break;
                    case "RotationZ":
                        rotationZ = float.Parse(FiresElement.Current.Value);
                        break;
                    case "Expanding":
                        tempFire.expandable = bool.Parse(FiresElement.Current.Value);
                        break;
                    case "ExtinguishAgent":
                        tempFire.ExtinguishAgent = int.Parse(FiresElement.Current.Value);
                        break;
                    }

                }

                tempFire.obj.transform.position = new Vector3(posX, posY, posZ);
                tempFire.obj.transform.rotation = new Quaternion(rotationX, rotationY, rotationZ, 0);
                loadedFireObjects.Add(tempFire);
            }
            #endregion

            #region SceneProperties
            XPathNodeIterator gameObjectNodus = nav.Select("/Scene/GameObjects/GameObject"); //Het pat dat hij moet afleggen in de XML File voor dat hij bij de juiste nodes is.
            while(gameObjectNodus.MoveNext()) { // Terwijl die elke keer volgende doet doet hij het volgende.
                GameObject tempObj;

                float posX = 0;
                float posY = 0;
                float posZ = 0;

                float rotationX = 0;
                float rotationY = 0;
                float rotationZ = 0;

                XPathNavigator nodesNavigator = gameObjectNodus.Current; // hij begint vanaf het begin waar hij het path krijgt.

                XPathNodeIterator nodesText = nodesNavigator.SelectDescendants(XPathNodeType.Text, false);//maakt een variable aan die je kunt opvragen wat voor text er in staat.
                XPathNodeIterator gameObjectElement = nodesNavigator.SelectDescendants(XPathNodeType.Element, false);

                tempObj = new GameObject();

                while(gameObjectElement.MoveNext()) { //pakt de volgende text.

                    //itemNodusElement.MoveNext();
                    switch(gameObjectElement.Current.Name) {
                    case "Name":
                        tempObj.name = gameObjectElement.Current.Value;
                        break;
                    case "posX":
                        posX = float.Parse(gameObjectElement.Current.Value);
                        break;
                    case "posY":
                        //print("Test: " + gameObjectElement.Current.Value);
                        posY = float.Parse(gameObjectElement.Current.Value);
                        break;
                    case "posZ":
                        posZ = float.Parse(gameObjectElement.Current.Value);
                        break;
                    case "RotationX":
                        rotationX = float.Parse(gameObjectElement.Current.Value);
                        break;
                    case "RotationY":
                        rotationY = float.Parse(gameObjectElement.Current.Value);
                        //print(rotationY);
                        break;
                    case "RotationZ":
                        rotationZ = float.Parse(gameObjectElement.Current.Value);
                        break;
                    }

                }

                tempObj.transform.position = new Vector3(posX, posY, posZ);
                tempObj.transform.rotation = new Quaternion(rotationX, rotationY, rotationZ, 0);
                loadedGameObjects.Add(tempObj);
            }
            #endregion

            for (int i = 0; i < loadedGameObjects.Count; i++) {
                loadedGameObjects[i].transform.parent = parent.transform;
            }

            for (int i = 0; i < loadedFireObjects.Count; i++) {
                loadedFireObjects[i].obj.transform.parent = parent.transform;
            }

            return sceneOptions;
        }
    }
コード例 #15
0
 public SceneOptions(SceneOptions options)
 {
     InheritOptions(options);
 }
コード例 #16
0
 public MatrixFullGraphFactory(SceneOptions options)
 {
     _options = options;
 }
コード例 #17
0
    // 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);
    }
コード例 #18
0
    // Use this for initialization
    void 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();
        }

        // restore any settings
        SceneGraphConfig.RestorePreferences();

        // set up some defaults
        SceneGraphConfig.InitialSceneTranslate          = -4.0f * Vector3f.AxisY;
        SceneGraphConfig.DefaultSceneCurveVisualDegrees = 0.5f;
        SceneGraphConfig.DefaultPivotVisualDegrees      = 2.3f;
        SceneGraphConfig.DefaultAxisGizmoVisualDegrees  = 25.0f;

        SceneOptions options = new SceneOptions();

        options.UseSystemMouseCursor = false;
        options.Use2DCockpit         = false;
        options.EnableTransforms     = true;
        options.EnableCockpit        = true;
        bool bDebugSplashScreen = false;
        bool bShowSplashScreen  = (Application.isEditor == false || bDebugSplashScreen);

        if (bShowSplashScreen == false)
        {
            options.CockpitInitializer = new SetupCADCockpit_V1();
        }
        else
        {
            options.CockpitInitializer = new SplashScreenCockpit();
        }
        options.MouseCameraControls = new MayaCameraHotkeys();
        options.SpatialCameraRig    = VRCameraRig;

        // very verbose
        options.LogLevel = 2;

        context = new FContext();
        context.Start(options);

        context.TransformManager.RegisterGizmoType("snap_drag", new SnapDragGizmoBuilder());
        context.TransformManager.RegisterGizmoType("object_edit", new EditObjectGizmoBuilder());
        //controller.TransformManager.SetActiveGizmoType("snap_drag");
        //controller.TransformManager.SetActiveGizmoType("object_edit");

        context.ToolManager.RegisterToolType(SnapDrawPrimitivesTool.Identifier, new SnapDrawPrimitivesToolBuilder());
        context.ToolManager.RegisterToolType(DrawTubeTool.Identifier, new DrawTubeToolBuilder());
        context.ToolManager.RegisterToolType(DrawCurveTool.Identifier, new DrawCurveToolBuilder());
        context.ToolManager.RegisterToolType(RevolveTool.Identifier, new RevolveToolBuilder());
        context.ToolManager.RegisterToolType(SculptCurveTool.Identifier, new SculptCurveToolBuilder()
        {
            InitialRadius = 0.1f
        });
        context.ToolManager.RegisterToolType(DrawSurfaceCurveTool.Identifier, new DrawSurfaceCurveToolBuilder()
        {
            DefaultSamplingRate = 0.1f, AttachCurveToSurface = true, Closed = false
        });
        context.ToolManager.RegisterToolType(TwoPointMeasureTool.Identifier, new TwoPointMeasureToolBuilder()
        {
            SnapThresholdAngle = 5.0f
        });
        context.ToolManager.RegisterToolType(PlaneCutTool.Identifier, new PlaneCutToolBuilder()
        {
            GenerateFillSurface = true
        });
        context.ToolManager.SetActiveToolType(SnapDrawPrimitivesTool.Identifier, ToolSide.Left);
        context.ToolManager.SetActiveToolType(SnapDrawPrimitivesTool.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 = 20.0f; // related to total scene scale...
        }


        // set up ground plane geometry
        GameObject groundPlane = GameObject.Find("GroundPlane");

        if (groundPlane != null)
        {
            context.Scene.AddWorldBoundsObject(new fGameObject(groundPlane));
        }


        //RMSTest.TestInflate();


        // [TODO] need to do this at cockpit level!!
        GameObject head = GameObject.Find("VRHead");

        if (bShowSplashScreen == false)
        {
            if (head != null && head.IsVisible())
            {
                head.transform.position = Vector3f.Zero;
                head.transform.rotation = Quaternionf.Identity;
                context.ActiveCamera.AddChild(head, false);

                GameObject           mesh    = head.FindChildByName("head_mesh", false);
                Colorf               c       = mesh.GetColor();
                SmoothCockpitTracker tracker = context.ActiveCockpit.CustomTracker as SmoothCockpitTracker;
                tracker.OnTrackingStateChange += (eState) => {
                    if (eState == SmoothCockpitTracker.TrackingState.NotTracking)
                    {
                        mesh.SetColor(c);
                    }
                    else if (eState == SmoothCockpitTracker.TrackingState.Tracking)
                    {
                        mesh.SetColor(Colorf.VideoRed);
                    }
                    else if (eState == SmoothCockpitTracker.TrackingState.TrackingWarmup || eState == SmoothCockpitTracker.TrackingState.TrackingCooldown)
                    {
                        mesh.SetColor(Colorf.Orange);
                    }
                };
            }
        }
        else
        {
            if (head != null)
            {
                head.Hide();
            }
        }


        // [RMS] circle that is roughly at edge of VR viewport (but tweak the 1.4 depending on type of screenshot...)
        //fCircleGameObject go = GameObjectFactory.CreateCircleGO("circ", 1.0f, Colorf.Red, 0.025f, LineWidthType.World);
        //Frame3f f = context.ActiveCamera.GetWorldFrame();
        //go.SetLocalPosition(context.ActiveCamera.GetPosition() + 1.4f * f.Z);
        //go.SetLocalRotation(Quaternionf.AxisAngleD(Vector3f.AxisX, 90));
        //context.ActiveCamera.AddChild(go, true);
    }
コード例 #19
0
 public GraphGridNeighborsServiceFactory(SceneOptions options)
 {
     _options = options;
 }
コード例 #20
0
    // Use this for initialization
    public override void 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();
        }

        // restore any settings
        SceneGraphConfig.RestorePreferences();

        // set up some defaults
        // this will move the ground plane down, but the bunnies will be floating...
        //SceneGraphConfig.InitialSceneTranslate = -4.0f * Vector3f.AxisY;
        SceneGraphConfig.DefaultSceneCurveVisualDegrees = 0.5f;
        SceneGraphConfig.DefaultPivotVisualDegrees      = 2.3f;
        SceneGraphConfig.DefaultAxisGizmoVisualDegrees  = 25.0f;
        PolyCurveSO.DefaultHitWidthMultiplier           = 2.5f;

        SceneOptions options = new SceneOptions();

        options.UseSystemMouseCursor  = false;
        options.Use2DCockpit          = false;
        options.EnableTransforms      = true;
        options.EnableCockpit         = true;
        options.EnableDefaultLighting = false;
        options.CockpitInitializer    = new SetupOrthoVRCockpit();

        options.MouseCameraControls = new MayaCameraHotkeys()
        {
            MousePanSpeed = 5.0f, MouseZoomSpeed = 5.0f
        };
        options.SpatialCameraRig = VRCameraRig;

        // very verbose
        options.LogLevel = 2;

        // hacks for stuff
#if F3_ENABLE_TEXT_MESH_PRO
        SceneGraphConfig.TextLabelZOffset = -0.01f;
#else
        SceneGraphConfig.TextLabelZOffset = -0.3f;
#endif


        context    = new FContext();
        OG.Context = context;
        OrthogenUI.ActiveContext = context;
        context.Start(options);


        // Set up standard scene lighting if enabled
        if (options.EnableDefaultLighting)
        {
            GameObject lighting = GameObject.Find("SceneLighting");
            if (lighting == null)
            {
                lighting = new GameObject("SceneLighting");
            }
            SceneLightingSetup setup = lighting.AddComponent <SceneLightingSetup>();
            setup.Context              = context;
            setup.ShadowLightCount     = 0;
            setup.AdjustShadowDistance = false;
            setup.LightDistance        = 1000.0f; // related to total scene scale...
        }

        // override sun so that it doesn't stick to one of the scene lights
        RenderSettings.sun = GameObject.Find("SunLight").GetComponent <Light>();

        //GameObjectFactory.CurveRendererSource = new VectrosityCurveRendererFactory();

        // set up ground plane geometry (optional)
        GameObject boundsObject = GameObject.Find("Bounds");
        if (boundsObject != null)
        {
            context.Scene.AddWorldBoundsObject(boundsObject);
        }


        /*
         * ORTHOGEN-SPECIFIC SETUP STARTS HERE
         */

        // set up scene and tools like Orthogen wants them
        OGActions.InitializeVRUsageContext();
        OrthogenMaterials.InitializeMaterials();
        OrthogenMaterials.ScanMaterial = new UnitySOMaterial(MaterialUtil.SafeLoadMaterial("scan_material"));
        //OrthogenMaterials.RectifiedLegMaterial = OrthogenMaterials.ScanMaterial;
        OGActions.InitializeF3Scene(context);
        OGActions.InitializeF3Tools(context);
        OGActions.InitializeF3VRTools(context);
        OGActions.PostConfigureTools_Demo();
        OGActions.ConfigurePlatformInput_VR();


        /*
         * optional things specific to demo app
         */

        // ground plane stays below socket as it is updated
        DemoActions.AddRepositionGroundPlaneOnSocketEdit();


        /*
         * import sample mesh
         */
        bool do_scan_demo = true;

        // load sample mesh
        string assetPath   = Application.dataPath;
        string samplesPath = Path.Combine(assetPath, "..", "sample_files");
        //string sampleFile = Path.Combine(samplesPath, "sample_socket_off.obj");
        string sampleFile = Path.Combine(samplesPath, "sample_socket_1.obj");
        if (do_scan_demo)
        {
            sampleFile = Path.Combine(samplesPath, "scan_1_remesh.obj");
        }
        if (File.Exists(sampleFile) == false)
        {
            sampleFile = Path.Combine(samplesPath, "sample_socket_1.obj");
        }
        DMesh3 mesh = StandardMeshReader.ReadMesh(sampleFile);
        // read sample file from Resources instead
        //MemoryStream sampleFileStream = FResources.LoadBinary("sample_socket_1");
        //DMesh3 mesh = StandardMeshReader.ReadMesh(sampleFileStream, "obj");
        if (mesh.HasVertexColors == false)
        {
            mesh.EnableVertexColors(Colorf.Silver);
        }

        // transform to our coordinate system
        double scale = Units.MetersTo(Units.Linear.Millimeters); // this mesh is in meters, so scale to mm
        MeshTransforms.FlipLeftRightCoordSystems(mesh);          // convert to unity coordinate system
        MeshTransforms.Scale(mesh, scale);

        if (do_scan_demo)
        {
            OGActions.SetSizeMode(OGActions.SizeModes.RealSize);
        }
        else
        {
            OGActions.SetSizeMode(OGActions.SizeModes.DemoSize);
        }

        // initialize the datamodel
        OGActions.BeginSocketDesignFromScan(Context, mesh);

        // set up my UI tests/etc
        configure_unity_ui();

        // [RMS] do this next frame because SteamVR needs a chance to set up and position the cockpit
        OGActions.RecenterVRView(true);

        add_vr_head(context);

        // dgraph tests
        //DGTest.test(Debug.Log);
    }
コード例 #21
0
 public MyScene(SceneOptions sceneOptions) : base(sceneOptions)
 {
     _random = new Random();
 }
コード例 #22
0
ファイル: PlayManager.cs プロジェクト: Cryslo/EMSRisicoStage
    // Use this for initialization
    void Start()
    {
        instance = this;
        scene = new GameObject("Scene");
        scenesDone = new List<string>();

        directoryName = GameManager.directoryName;
        sceneName = GameManager.sceneName;

        scenes = folderManager.GetScenesByName(directoryName);
        scenesWaiting = folderManager.GetScenesByName(directoryName);
        print(scenes.Count);

        for(int i = 0; i < scenes.Count; i++) {
            if(scenes[i].Name == sceneName)
            {
                currentScene = scenes[i];
                scenesDone.Add(scenes[i].Name);
                sceneNumber = i;
            }
        }

        print(currentScene.FullName);
        print(scenes.Count);
        RPCController.instance.SendScenes(scenes);

        sceneOptions = XmlBehaviour.LoadScene(currentScene.FullName, scene);
    }
コード例 #23
0
    // Use this for initialization
    public override void 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();
        }

        // restore any settings
        SceneGraphConfig.RestorePreferences();

        // set up some defaults
        // this will move the ground plane down, but the bunnies will be floating...
        //SceneGraphConfig.InitialSceneTranslate = -4.0f * Vector3f.AxisY;
        SceneGraphConfig.DefaultSceneCurveVisualDegrees = 0.35f;
        SceneGraphConfig.DefaultPivotVisualDegrees      = 2.3f;
        SceneGraphConfig.DefaultAxisGizmoVisualDegrees  = 25.0f;

        // make curves easier to click
        PolyCurveSO.DefaultHitWidthMultiplier = 2.0f;

        SceneOptions options = new SceneOptions();

        options.UseSystemMouseCursor = true;
        options.EnableTransforms     = true;
        options.EnableCockpit        = true;
        options.CockpitInitializer   = new SetupOrthoGenCockpit();

        options.MouseCameraControls = new MayaCameraHotkeys()
        {
            MousePanSpeed = 5.0f, MouseZoomSpeed = 5.0f
        };
        options.SpatialCameraRig = VRCameraRig;

        options.Use2DCockpit             = true;
        options.ConstantSize2DCockpit    = true;
        FPlatform.EditorPixelScaleFactor = 1.0f;

        // very verbose
        options.LogLevel = 2;

        context    = new FContext();
        OG.Context = context;
        OrthogenUI.ActiveContext = context;
        context.Start(options);

        DebugUtil.Log("started context");

        // Set up standard scene lighting if enabled
        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 = 30.0f; // related to total scene scale...
        }


        //GameObjectFactory.CurveRendererSource = new VectrosityCurveRendererFactory();

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

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


        /*
         * ORTHOGEN-SPECIFIC SETUP STARTS HERE
         */

        // set up scene and tools like Orthogen wants them
        OGActions.InitializeUsageContext(OGActions.UsageContext.OrthoVRApp);
        //OGActions.InitializeUsageContext(OGActions.UsageContext.NiaOrthogenApp);
        OrthogenMaterials.InitializeMaterials();
        OGActions.InitializeF3Scene(context);
        OGActions.InitializeF3Tools(context);
        OGActions.PostConfigureTools_Demo();
        OGActions.ConfigurePlatformInput_Mouse();

        /*
         * optional things specific to demo app
         */

        // ground plane stays below socket as it is updated
        DemoActions.AddRepositionGroundPlaneOnSocketEdit();


        /*
         * import sample mesh
         */

        // load sample mesh
        string assetPath   = Application.dataPath;
        string samplesPath = Path.Combine(assetPath, "..", "sample_files");
        //string sampleFile = Path.Combine(samplesPath, "sample_socket_off.obj");
        //string sampleFile = Path.Combine(samplesPath, "sample_socket_1.obj");
        //string sampleFile = Path.Combine(samplesPath, "scan_1_raw.obj");
        string sampleFile = Path.Combine(samplesPath, "scan_1_remesh.obj");
        DMesh3 mesh       = StandardMeshReader.ReadMesh(sampleFile);

        if (mesh.HasVertexColors == false)
        {
            mesh.EnableVertexColors(Colorf.Silver);
        }
        // read sample file from Resources instead
        //MemoryStream sampleFileStream = FResources.LoadBinary("sample_socket_1");
        //DMesh3 mesh = StandardMeshReader.ReadMesh(sampleFileStream, "obj");
        double scale = Units.MetersTo(Units.Linear.Millimeters); // this mesh is in meters, so scale to mm

        MeshTransforms.FlipLeftRightCoordSystems(mesh);          // convert to unity coordinate system
        MeshTransforms.Scale(mesh, scale);

        // initialize the datamodel
        OGActions.BeginSocketDesignFromScan(Context, mesh);

        // set up my UI tests/etc
        configure_unity_ui();

        // dgraph tests
        //DGTest.test(Debug.Log);
    }
コード例 #24
0
    // Use this for initialization
    public override void 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();
        }

        // restore any settings
        SceneGraphConfig.RestorePreferences();

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


        SceneOptions options = new SceneOptions();

        options.UseSystemMouseCursor = false;
        options.Use2DCockpit         = false;
        options.EnableTransforms     = true;
        options.EnableCockpit        = true;
        options.CockpitInitializer   = new SetupBasicVRCockpit();

        options.MouseCameraControls = new MayaCameraHotkeys();
        options.SpatialCameraRig    = VRCameraRig;

        // very verbose
        options.LogLevel = 2;

        context = new FContext();
        context.Start(options);

        // if you had other gizmos, you would register them here
        //context.TransformManager.RegisterGizmoType("snap_drag", new SnapDragGizmoBuilder());
        //controller.TransformManager.SetActiveGizmoType("snap_drag");

        // if you had other tools, you would register them here.
        context.ToolManager.RegisterToolType(DrawPrimitivesTool.Identifier, new DrawPrimitivesToolBuilder());
        context.ToolManager.RegisterToolType(DrawSurfaceCurveTool.Identifier, new DrawSurfaceCurveToolBuilder()
        {
            AttachCurveToSurface = false,
            DefaultSamplingRateS = 0.0025f, DefaultSurfaceOffsetS = 0.0025f,
            CurveMaterialF       = () => { var mat = context.Scene.DefaultCurveSOMaterial.Clone(); mat.RGBColor = Colorf.VideoRed; return(mat); }
        });
        context.ToolManager.RegisterToolType(DrawSpaceCurveTool.Identifier, new DrawSpaceCurveToolBuilder()
        {
            AttachCurveToTarget  = false,
            DefaultSamplingRateS = 0.01f,
            CurveMaterialF       = () => { var mat = context.Scene.DefaultCurveSOMaterial.Clone(); mat.RGBColor = Colorf.VideoBlue; return(mat); }
        });
        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 = 30.0f; // related to total scene scale...
        }



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

        // set up ground plane geometry (optional)
        GameObject groundPlane = GameObject.Find("GroundPlane");

        context.Scene.AddWorldBoundsObject(groundPlane);

        SceneObject focusSO = null;

        // wrap existing complex GameObject named capsule1 as a SceneObject
        GameObject capsuleGO = GameObject.Find("capsule1");

        if (capsuleGO != null)
        {
            SceneObject capsuleSO = UnitySceneUtil.WrapAnyGameObject(capsuleGO, context, true);
            focusSO = capsuleSO;
        }

        // wrap a prefab as a GOWrapperSO
        GameObject prefabGO = GameObject.Find("bunny_prefab");

        if (prefabGO != null)
        {
            UnitySceneUtil.WrapAnyGameObject(prefabGO, context, false);
        }

        // convert a mesh GameObject to our DMeshSO
        // Note: any child GameObjects will be lost
        GameObject meshGO = GameObject.Find("bunny_mesh");

        if (meshGO != null)
        {
            //DMeshSO meshSO = UnitySceneUtil.WrapMeshGameObject(meshGO, context, true) as DMeshSO;
            UnitySceneUtil.WrapMeshGameObject(meshGO, context, true);
        }

        GameObject meshGO2 = GameObject.Find("bunny_mesh2");

        if (meshGO2 != null)
        {
            //DMeshSO meshSO = UnitySceneUtil.WrapMeshGameObject(meshGO, context, true) as DMeshSO;
            UnitySceneUtil.WrapMeshGameObject(meshGO2, context, true);
        }

        // center the camera on the capsule assembly
        if (focusSO != null)
        {
            Vector3f centerPt = focusSO.GetLocalFrame(CoordSpace.WorldCoords).Origin;
            context.ActiveCamera.Animator().AnimatePanFocus(centerPt, CoordSpace.WorldCoords, 0.3f);
        }
    }
コード例 #25
0
 public void Select(SceneOptions sceneOption)
 {
     GameState.EnemiesArmy = sceneOption.Armies.Select(a => Instantiate(a)).Cast <IArmyModel>().ToList();
     SceneManager.LoadSceneAsync(sceneOption.SceneBuildIndex);
 }
コード例 #26
0
 public void InheritOptions(SceneOptions options)
 {
     m_oGenerationType = options.GenType;
     m_iAdCount        = options.AdCount;
 }
コード例 #27
0
    // Use this for initialization
    public override void 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();
        }

        // restore any settings
        SceneGraphConfig.RestorePreferences();

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


        SceneOptions options = new SceneOptions();

        options.UseSystemMouseCursor = false;
        options.Use2DCockpit         = false;
        options.EnableTransforms     = true;
        options.EnableCockpit        = true;
        options.CockpitInitializer   = new PhotoToolCockpit();

        options.MouseCameraControls = new MayaCameraHotkeys();
        options.SpatialCameraRig    = VRCameraRig;

        // very verbose
        options.LogLevel = 2;

        context = new FContext();
        context.Start(options);

        // if you had other gizmos, you would register them here
        //context.TransformManager.RegisterGizmoType("snap_drag", new SnapDragGizmoBuilder());
        //controller.TransformManager.SetActiveGizmoType("snap_drag");

        // if you had other tools, you would register them here.
        context.ToolManager.RegisterToolType(DrawPrimitivesTool.Identifier, new DrawPrimitivesToolBuilder());
        context.ToolManager.RegisterToolType(DrawSurfaceCurveTool.Identifier, new DrawSurfaceCurveToolBuilder()
        {
            AttachCurveToSurface = true,
            DefaultSamplingRateS = 0.0025f, DefaultSurfaceOffsetS = 0.0025f,
            CurveMaterialF       = () => { var mat = context.Scene.DefaultCurveSOMaterial.Clone(); mat.RGBColor = Colorf.VideoRed; return(mat); }
        });
        context.ToolManager.SetActiveToolType(DrawSurfaceCurveTool.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 = 30.0f; // related to total scene scale...
        }


        Context.Scene.DisableSelectionMaterial = true;


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

        // set up ground plane geometry (optional)
        GameObject groundPlane = GameObject.Find("GroundPlane");

        if (groundPlane != null && groundPlane.IsVisible())
        {
            context.Scene.AddWorldBoundsObject(groundPlane);
        }


        float    fSquareSize = 1.0f;
        Vector3f eyePos      = context.ActiveCamera.GetPosition();

        System.Random rand = new System.Random(31337);

        // [RMS] this path only works in Editor, is relative to top-level project directory
        string sPhotoFolder = "Data\\PhotoSets\\kitchen";

        string[] photos = Directory.GetFiles(sPhotoFolder);
        foreach (string filename in photos)
        {
            Texture2D tex = load_texture(filename);
            if (tex == null)
            {
                continue;
            }

            float fScale = fSquareSize / (float)tex.width;
            if (tex.height > tex.width)
            {
                fScale = fSquareSize / (float)tex.height;
            }

            float w = fScale * (float)tex.width;
            float h = fScale * (float)tex.height;

            TrivialRectGenerator rectgen = new TrivialRectGenerator()
            {
                Width = w, Height = h
            };
            rectgen.Generate();
            DMesh3 mesh = new DMesh3(MeshComponents.VertexUVs);
            rectgen.MakeMesh(mesh);

            SOMaterial material = new SOMaterial()
            {
                Name     = "photomaterial",
                Type     = SOMaterial.MaterialType.TextureMap,
                RGBColor = Colorf.White
            };
            material.MainTexture = tex;

            DMeshSO so = new DMeshSO();
            so.Create(mesh, material);
            context.Scene.AddSceneObject(so);

            float horz = rand.Next(-50, 50);
            float vert = rand.Next(-20, 25);
            int   mult = 1000;
            float dist = (float)(rand.Next(2 * mult, 3 * mult)) / (float)mult;

            Ray3f r = VRUtil.MakeRayFromSphereCenter(horz, vert);
            r.Origin += eyePos;
            float fRayT = 0.0f;
            RayIntersection.Sphere(r.Origin, r.Direction, eyePos, dist, out fRayT);
            Vector3f v = r.Origin + fRayT * r.Direction;
            Frame3f  f = new Frame3f(v, v.Normalized);

            Vector3f toEye = context.ActiveCamera.GetPosition() - f.Origin;
            toEye.Normalize();
            f.AlignAxis(1, toEye);
            f.ConstrainedAlignAxis(2, Vector3f.AxisY, f.Y);

            so.SetLocalFrame(f, CoordSpace.WorldCoords);
        }
    }
コード例 #28
0
    // Use this for initialization
    public override void Awake()
    {
        VRPlatform.VREnabled = false;

        // restore any settings
        SceneGraphConfig.RestorePreferences();

        // set up some defaults
        SceneGraphConfig.DefaultSceneCurveVisualDegrees = 0.5f;
        SceneGraphConfig.DefaultPivotVisualDegrees      = 1.5f;
        SceneGraphConfig.DefaultAxisGizmoVisualDegrees  = 10.0f;


        SceneOptions options = new SceneOptions();

        options.UseSystemMouseCursor  = true;
        options.EnableCockpit         = true;
        options.Use2DCockpit          = true;
        options.ConstantSize2DCockpit = true;    // you usually want this
        options.EnableTransforms      = true;
        options.CockpitInitializer    = new SetupObjectsDemoCockpit();

        options.MouseCameraControls = new MayaCameraHotkeys();

        // very verbose
        options.LogLevel = 2;

        context = new FContext();
        context.Start(options);

        // register transformation gizmos
        //context.TransformManager.RegisterGizmoType(AxisTransformGizmo.DefaultName, new AxisTransformGizmoBuilder());
        //context.TransformManager.SetActiveGizmoType(AxisTransformGizmo.DefaultName);

        // if you had other tools, you would register them here.
        context.ToolManager.RegisterToolType(DrawPrimitivesTool.Identifier, new DrawPrimitivesToolBuilder());
        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 = 30.0f; // related to total scene scale...
        }



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

        // set up ground plane geometry (optional)
        GameObject groundPlane = GameObject.Find("GroundPlane");

        context.Scene.AddWorldBoundsObject(groundPlane);


        Sphere3Generator_NormalizedCube gen = new Sphere3Generator_NormalizedCube()
        {
            Radius = 1.0f
        };
        DMeshSO meshSO = new DMeshSO();

        meshSO.Create(gen.Generate().MakeDMesh(), Context.Scene.DefaultMeshSOMaterial);
        Context.Scene.AddSceneObject(meshSO);

        //SceneObject focusSO = null;

        // convert a mesh GameObject to our DMeshSO
        // Note: any child GameObjects will be lost
        GameObject meshGO = GameObject.Find("bunny_mesh");

        if (meshGO != null)
        {
            //DMeshSO meshSO = UnitySceneUtil.WrapMeshGameObject(meshGO, context, true) as DMeshSO;
            UnitySceneUtil.WrapMeshGameObject(meshGO, context, true);
        }

        GameObject meshGO2 = GameObject.Find("bunny_mesh2");

        if (meshGO2 != null)
        {
            //DMeshSO meshSO = UnitySceneUtil.WrapMeshGameObject(meshGO, context, true) as DMeshSO;
            UnitySceneUtil.WrapMeshGameObject(meshGO2, context, true);
        }

        //// center the camera on the capsule assembly
        //if (focusSO != null) {
        //    Vector3f centerPt = focusSO.GetLocalFrame(CoordSpace.WorldCoords).Origin;
        //    context.ActiveCamera.Manipulator().ScenePanFocus(
        //        context.Scene, context.ActiveCamera, centerPt, true);
        //}
    }