コード例 #1
0
        public bool Initialize()
        {
            _actionReceiver           = new NodeAction("DynamicLoadManager");
            _actionReceiver.OnAction += ActionReceiver_OnAction;

            _zflipMatrix = new Matrix4x4(new Vector4(1, 0, 0), new Vector4(0, 1, 0), new Vector4(0, 0, -1), new Vector4(0, 0, 0, 1));

            GizmoSDK.GizmoBase.Message.Send("SceneManager", MessageLevel.DEBUG, "Loading Graph");

            GizmoSDK.Gizmo3D.Platform.Initialize();

            NodeLock.WaitLockEdit();

            _native_camera             = new PerspCamera("Test");
            _native_camera.RoiPosition = true;
            _controller.Camera         = _native_camera;

            _native_scene = new Scene("TestScene");

            _native_context = new Context();

            //native_camera.Debug(native_context);

            _native_traverse_action = new CullTraverseAction();

            DynamicLoader.OnDynamicLoad += DynamicLoader_OnDynamicLoad;

            _native_camera.Scene = _native_scene;

            NodeLock.UnLock();

            DbManager.Initialize();

            return(true);
        }
コード例 #2
0
        public bool ResetMap()
        {
            NodeLock.WaitLockEdit();

            foreach (var p in pendingLoaders)
            {
                p.loader?.Dispose();
                p.node?.Dispose();
            }

            pendingLoaders.Clear();

            foreach (var p in pendingActivations)
            {
                p.node?.Dispose();
            }

            pendingActivations.Clear();

            RemoveGameObjectHandles(_root);

            _controller.Reset();

            NodeLock.UnLock();

            return(true);
        }
コード例 #3
0
        public bool Uninitialize()
        {
            ResetMap();

            DynamicLoader.OnDynamicLoad -= DynamicLoader_OnDynamicLoad;
            _actionReceiver.OnAction    -= ActionReceiver_OnAction;

            NodeLock.WaitLockEdit();

            _native_camera.Debug(_native_context, false);
            _native_camera.Dispose();
            _native_camera = null;

            _native_context.Dispose();
            _native_context = null;

            _native_scene.Dispose();
            _native_scene = null;


            _actionReceiver.Dispose();
            _actionReceiver = null;

            NodeLock.UnLock();

            GizmoSDK.Gizmo3D.Platform.UnInitialize();

            _plugin_initializer = null;

            return(true);
        }
コード例 #4
0
        public bool Uninitialize()
        {
            DynamicLoaderManager.StopManager();

            ResetMap();

            DynamicLoader.OnDynamicLoad -= DynamicLoader_OnDynamicLoad;
            _actionReceiver.OnAction    -= ActionReceiver_OnAction;

            NodeLock.WaitLockEdit();

            try // We are now locked in edit
            {
                _native_camera.Debug(_native_context, false);
                _native_camera.Dispose();
                _native_camera = null;

                _native_context.Dispose();
                _native_context = null;

                _native_scene.Dispose();
                _native_scene = null;


                _actionReceiver.Dispose();
                _actionReceiver = null;
            }
            finally
            {
                NodeLock.UnLock();
            }


            return(true);
        }
コード例 #5
0
            override public void Release()
            {
                if (IsValid())
                {
                    NodeLock.WaitLockEdit();

                    base.Release();

                    NodeLock.UnLock();
                }
            }
コード例 #6
0
        // The LoadMap function takes an URL and loads the map into GizmoSDK native db
        public bool LoadMap(string mapURL)
        {
            NodeLock.WaitLockEdit();      // We assume we do all editing from main thread and to allow render we assume we edit in edit mode

            if (!ResetMap())
            {
                NodeLock.UnLock();
                return(false);
            }

            var node = DbManager.LoadDB(mapURL);

            if (node == null || !node.IsValid())
            {
                NodeLock.UnLock();
                return(false);
            }

            MapUrl = mapURL;

            _native_scene.AddNode(node);

            _controller.CurrentMap = node;

            _native_scene.Debug();

            _root = new GameObject("root");

            GameObject scene = Traverse(node, null);

            scene.transform.SetParent(_root.transform, false);

            // As GizmoSDK has a flipped Z axis going out of the screen we need a top transform to flip Z
            _root.transform.localScale = new Vector3(1, 1, -1);

            //// Add example object under ROI --------------------------------------------------------------

            //MapPos mapPos;

            //GetMapPosition(new LatPos(1.0084718541, 0.24984267815,300),out mapPos, GroundClampType.GROUND,true);

            //GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);

            //sphere.transform.parent = FindFirstGameObjectTransform(mapPos.roiNode);
            //sphere.transform.localPosition = mapPos.position.ToVector3();
            //sphere.transform.localScale = new Vector3(10,10,10);

            //// ------------------------------------------------------------------------------------------

            NodeLock.UnLock();

            return(true);
        }
コード例 #7
0
 // We need to release all existing objects in a locked mode
 void OnDestroy()
 {
     // Basically all nodes in the GameObject scene should already be release by callbacks but there might be some nodes left that needs this behaviour
     if (node != null)
     {
         if (node.IsValid())
         {
             NodeLock.WaitLockEdit();
             node.Dispose();
             NodeLock.UnLock();
         }
     }
 }
コード例 #8
0
ファイル: Platform.cs プロジェクト: Hengle/Streaming_Map_Demo
            public static bool UnInitialize(bool forceShutdown = false, bool shutdownBase = false)
            {
                NodeLock.WaitLockEdit();

                DynamicLoader.UnInitialize();

                UnInitializeFactories();

                NodeLock.UnLock();

                bool result = Platform_uninitialize(forceShutdown, shutdownBase);

                return(result);
            }
コード例 #9
0
        public bool Uninitialize()
        {
            if (!_initialized)
            {
                return(false);
            }

            // Stop manager
            DynamicLoaderManager.StopManager();

            ResetMap();

            // Remove actions
            DynamicLoader.OnDynamicLoad -= DynamicLoader_OnDynamicLoad;
            _actionReceiver.OnAction    -= ActionReceiver_OnAction;

            NodeLock.WaitLockEdit();

            try // We are now locked in edit
            {
                _native_camera.Debug(_native_context, false);
                _native_camera.Dispose();
                _native_camera = null;

                _native_context.Dispose();
                _native_context = null;

                _native_scene.Dispose();
                _native_scene = null;


                _actionReceiver.Dispose();
                _actionReceiver = null;
            }
            finally
            {
                NodeLock.UnLock();
            }

            // Drop platform streamer
            GizmoSDK.Gizmo3D.Platform.Uninitialize();

            _initialized = false;

            return(true);
        }
コード例 #10
0
        public bool InitializeInternal()
        {
            _actionReceiver = new NodeAction("DynamicLoadManager");

            _actionReceiver.OnAction += ActionReceiver_OnAction;

            _zflipMatrix = new Matrix4x4(new Vector4(1, 0, 0), new Vector4(0, 1, 0), new Vector4(0, 0, -1), new Vector4(0, 0, 0, 1));

            GizmoSDK.GizmoBase.Message.Send("SceneManager", MessageLevel.DEBUG, "Loading Graph");

            NodeLock.WaitLockEdit();

            try // We are now locked in edit
            {
                _native_camera              = new PerspCamera("Test");
                _native_camera.RoiPosition  = true;
                MapControl.SystemMap.Camera = _native_camera;

                _native_scene = new Scene("TestScene");

                _native_context = new Context();

#if DEBUG_CAMERA
                _native_camera.Debug(_native_context);      // Enable to debug view
#endif // DEBUG_CAMERA

                _native_traverse_action = new CullTraverseAction();

                DynamicLoader.OnDynamicLoad += DynamicLoader_OnDynamicLoad;

                _native_camera.Scene = _native_scene;
            }
            finally
            {
                NodeLock.UnLock();
            }


            DynamicLoader.UsePreCache(true);                    // Enable use of mipmap creation on dynamic loading
            DynamicLoaderManager.SetNumberOfActiveLoaders(4);   // Lets start with 4 parallell threads
            DynamicLoaderManager.StartManager();

            return(true);
        }
コード例 #11
0
            public RoiNode GetClosestRoiNode(Vec3D position)
            {
                RoiNode node;

                // We must call this from a node locked state as childs might unload during other edits

                try
                {
                    NodeLock.WaitLockEdit();

                    node = CreateObject(Roi_getClosestRoiNode(GetNativeReference(), ref position)) as RoiNode;
                }
                finally
                {
                    NodeLock.UnLock();
                }

                return(node);
            }
コード例 #12
0
        // We need to release all existing objects in a locked mode
        void OnDestroy()
        {
            // Basically all nodes in the GameObject scene should already be release by callbacks but there might be some nodes left that needs this behaviour
            if (node != null)
            {
                if (inNodeUtilsRegistry)
                {
                    NodeUtils.RemoveGameObjectReference(node.GetNativeReference(), gameObject);
                    inNodeUtilsRegistry = false;
                }


                if (node.IsValid())
                {
                    NodeLock.WaitLockEdit();
                    node.Dispose();
                    NodeLock.UnLock();
                }
            }
        }
コード例 #13
0
        public bool FindGameObjects(Node node, out List <GameObject> gameObjectList)
        {
            gameObjectList = null;

            if (node == null)
            {
                return(false);
            }

            if (!node.IsValid())
            {
                return(false);
            }

            NodeLock.WaitLockEdit();

            bool result = currentObjects.TryGetValue(node.GetNativeReference(), out gameObjectList);

            NodeLock.UnLock();

            return(result);
        }
コード例 #14
0
        public bool ResetMap()
        {
            //MapUrl = null;

            NodeLock.WaitLockEdit();

            try // We are now locked in edit
            {
                foreach (var p in pendingLoaders)
                {
                    p.loader?.Dispose();
                    p.node?.Dispose();
                }

                pendingLoaders.Clear();

                foreach (var p in pendingActivations)
                {
                    p.node?.Dispose();
                }

                pendingActivations.Clear();

                if (_root)
                {
                    Free(_root.transform);
                    _root = null;
                }


                MapControl.SystemMap.Reset();
            }
            finally
            {
                NodeLock.UnLock();
            }

            return(true);
        }
コード例 #15
0
        public void Reset()
        {
            try
            {
                NodeLock.WaitLockEdit();        // All change of map parameters shall be done in locked edit mode

                _mapType = MapType.UNKNOWN;

                _topRoi     = null;
                _currentMap = null;
                _nodeURL    = null;

                _origin   = new Vec3D(0, 0, 0);
                _metaData = new CoordinateSystemMetaData();

                _coordSystem = new CoordinateSystem();
            }
            finally
            {
                NodeLock.UnLock();
            }
        }
コード例 #16
0
        // Update is called once per frame
        private void Update()
        {
            NodeLock.WaitLockEdit();

            ProcessPendingUpdates();

            // Transfer camera parameters

            PerspCamera perspCamera = _native_camera as PerspCamera;

            if (perspCamera != null)
            {
                perspCamera.VerticalFOV   = UnityCamera.fieldOfView;
                perspCamera.HorizontalFOV = 2 * Mathf.Atan(Mathf.Tan(UnityCamera.fieldOfView * Mathf.Deg2Rad / 2) * UnityCamera.aspect) * Mathf.Rad2Deg;;
                perspCamera.NearClipPlane = UnityCamera.nearClipPlane;
                perspCamera.FarClipPlane  = UnityCamera.farClipPlane;
            }

            Matrix4x4 unity_camera_transform = UnityCamera.transform.worldToLocalMatrix;

            Matrix4x4 gz_transform = _zflipMatrix * unity_camera_transform * _zflipMatrix;

            _native_camera.Transform = gz_transform.ToMatrix4();

            IWorldCoord ctrl = UnityCamera.GetComponent <IWorldCoord>();

            if (ctrl != null)
            {
                _native_camera.Position = ctrl.Position;
            }

            NodeLock.UnLock();

            NodeLock.WaitLockRender();
            _native_camera.Render(_native_context, 1000, 1000, 1000, _native_traverse_action);
            //native_camera.DebugRefresh();
            NodeLock.UnLock();
        }
コード例 #17
0
        public bool ResetMap()
        {
            NodeLock.WaitLockEdit();

            try // We are now locked in edit
            {
                foreach (var p in pendingLoaders)
                {
                    p.loader?.Dispose();
                    p.node?.Dispose();
                }

                pendingLoaders.Clear();

                foreach (var p in pendingActivations)
                {
                    p.node?.Dispose();
                }

                pendingActivations.Clear();

                RemoveGameObjectHandles(_root);

                GameObject.Destroy(_root);

                _root = null;

                MapControl.SystemMap.Reset();
            }
            finally
            {
                NodeLock.UnLock();
            }

            return(true);
        }
コード例 #18
0
    public override void OnInspectorGUI()
    {
        if (m_Instance == null)
        {
            return;
        }

        this.DrawDefaultInspector();

        // Expose the decorated fields
        ExposeProperties.Expose(m_fields);

        GUILayoutOption[] emptyOptions = new GUILayoutOption[0];

        if (m_Instance.node == null || !m_Instance.node.IsValid())
        {
            EditorGUILayout.LabelField("No created native Node Handle", emptyOptions);

            m_defaultClass = EditorGUILayout.TextField("Class Name", m_defaultClass, emptyOptions);

            EditorGUILayout.BeginHorizontal(emptyOptions);

            if (GUILayout.Button("Create " + m_defaultClass))
            {
            }

            GUILayout.FlexibleSpace();

            EditorGUILayout.EndHorizontal();

            return;
        }

        /////////////////////////////////////////////////////
        /// Presentation Area of node attributes
        /// Shall reamin Locked
        ///

        try
        {
            NodeLock.WaitLockEdit();

            /////////////////////////////////////////////////////////////////////////////////////////////

            bool change = false;

            if (PropEdit_Object(m_Instance.node as GizmoSDK.GizmoBase.Object))
            {
                change = true;
            }

            if (PropEdit_Node(m_Instance.node as Node))
            {
                change = true;
            }

            if (PropEdit_DynamicLoader(m_Instance.node as DynamicLoader))
            {
                change = true;
            }

            if (change)
            {
                m_Instance.node.SetDirtySaveData(true);
            }

            if (m_Instance.node.HasDirtySaveData())
            {
                EditorGUILayout.BeginHorizontal(emptyOptions);

                if (GUILayout.Button("Save"))
                {
                    m_Instance.node.SaveDirtyData();
                }

                GUILayout.FlexibleSpace();

                EditorGUILayout.EndHorizontal();
            }

            //////////////////////////////////////////////////////////////////////////////////////////
        }
        finally
        {
            NodeLock.UnLock();
        }
    }
コード例 #19
0
        public bool InitializeInternal()
        {
            // Initialize streamer APIs
            if (!GizmoSDK.Gizmo3D.Platform.Initialize())
            {
                return(false);
            }

            // Initialize formats
            DbManager.Initialize();

            GizmoSDK.GizmoBase.Message.Send("SceneManager", MessageLevel.DEBUG, "Initialize Graph Streaming");

            // Add builder for registered types
            AddDefaultBuilders();

            // Setup internal subscription events
            _actionReceiver           = new NodeAction("DynamicLoadManager");
            _actionReceiver.OnAction += ActionReceiver_OnAction;

            DynamicLoader.OnDynamicLoad += DynamicLoader_OnDynamicLoad;


            NodeLock.WaitLockEdit();

            try // We are now locked in edit
            {
                // Camera setup
                _native_camera              = new PerspCamera("Test");
                _native_camera.RoiPosition  = true;
                MapControl.SystemMap.Camera = _native_camera;

                // Top scene
                _native_scene        = new Scene("Scene");
                _native_camera.Scene = _native_scene;

                // Top context
                _native_context = new Context();

#if DEBUG_CAMERA
                // If we want to visualize debug 3D
                _native_camera.Debug(_native_context);      // Enable to debug view
#endif // DEBUG_CAMERA

                // Default travrser
                _native_traverse_action = new CullTraverseAction();

                // _native_traverse_action.SetOmniTraverser(true);  // To skip camera cull and use LOD in omni directions
            }
            finally
            {
                NodeLock.UnLock();
            }

            // Set up dynamic loading
            DynamicLoader.UsePreCache(true);                                        // Enable use of mipmap creation on dynamic loading
            DynamicLoaderManager.SetNumberOfActiveLoaders(Settings.DynamicLoaders); // Lets start with 4 parallell threads
            DynamicLoaderManager.StartManager();

            // Start coroutines for asset loading
            StartCoroutine(AssetLoader());

            return(true);
        }
コード例 #20
0
        // The LoadMap function takes an URL and loads the map into GizmoSDK native db
        public bool LoadMap(string mapURL)
        {
            NodeLock.WaitLockEdit(); // We assume we do all editing from main thread and to allow render we assume we edit in edit mode

            try                      // We are now locked in edit
            {
                if (!ResetMap())
                {
                    return(false);
                }

                var node = DbManager.LoadDB(mapURL);

                if (node == null || !node.IsValid())
                {
                    Message.Send(ID, MessageLevel.WARNING, $"Failed to load map {mapURL}");
                    return(false);
                }

                MapUrl = mapURL;

                MapControl.SystemMap.NodeURL    = mapURL;
                MapControl.SystemMap.CurrentMap = node;

                _native_scene.AddNode(MapControl.SystemMap.CurrentMap);

                _native_scene.Debug();

                _root = new GameObject("root");

                GameObject scene = Traverse(MapControl.SystemMap.CurrentMap, null);

                if (scene != null)
                {
                    scene.transform.SetParent(_root.transform, false);
                }

                // As GizmoSDK has a flipped Z axis going out of the screen we need a top transform to flip Z
                _root.transform.localScale = new Vector3(1, 1, -1);


                //// Add example object under ROI --------------------------------------------------------------

                //MapPos mapPos;

                //GetMapPosition(new LatPos(1.0084718541, 0.24984267815, 300), out mapPos, GroundClampType.GROUND, true);

                //_test = GameObject.CreatePrimitive(PrimitiveType.Sphere);

                //_test.transform.parent = FindFirstGameObjectTransform(mapPos.roiNode);
                //_test.transform.localPosition = mapPos.position.ToVector3();
                //_test.transform.localScale = new Vector3(10, 10, 10);

                if (SceneManagerCamera != null)
                {
                    SceneManagerCamera.MapChanged();
                }

                OnMapChanged?.Invoke(node);
            }
            finally
            {
                NodeLock.UnLock();
            }

            return(true);
        }