コード例 #1
0
        /*!
         * Start up Vixen 3D display and event processing.
         * This function should not be called until the
         * underlying Window has been created and the
         * OS window handle is available. Vixen will display
         * the 3D content in this window.
         */
        public virtual bool RunVixen()
        {
            bool loadasync = World.DoAsyncLoad;

            if (_world == null)
            {
                SharedWorld.LogError("Vixen did not start");
                return(false);
            }
            if (_window == null)
            {
                SharedWorld.LogError("Cannot get window handle for parent window");
                return(false);
            }
            if (_world.IsRunning())
            {
                return(false);
            }
            //world.SetDebugLevel(1);
            if (MediaDir != null)
            {
                _world.SetMediaDir(MediaDir);
            }
            if (ContentFile == null)
            {
                loadasync = false;
            }
            else if (loadasync)
            {
                _world.FileName = GetMediaPath(ContentFile);
            }
            _world.Run((long)_window);
            if (_world.IsRunning())
            {
                ThreadStart eventloop = new ThreadStart(EventLoop);
                Thread      thread    = new Thread(eventloop);

                _scene = SharedWorld.MainScene;
                thread.Start();
                if (!loadasync)
                {
                    try
                    {
                        Scene scene = MakeScene();
                        if (scene != null)
                        {
                            GC.KeepAlive(scene);
                            _world.SetScene(scene);
                        }
                    }
                    catch (Exception ex)
                    {
                        SharedWorld.LogError("exception making initial scene " + ex.Message);
                    }
                }
                return(true);
            }
            return(false);
        }
コード例 #2
0
        /*!
         * Start up Vixen 3D display and event processing.
         * This function should not be called until the
         * underlying Window has been created and the
         * OS window handle is available. Vixen will display
         * the 3D content in this window.
         */
        public virtual bool RunVixen()
        {
            SharedWorld world        = SharedWorld.Get();
            IntPtr      windowHandle = Handle;
            Scene       scene        = null;

            try
            {
                if (windowHandle == null)
                {
                    LogError("Cannot get window handle for parent window");
                    return(false);
                }
                if ((world != null) && world.IsRunning())
                {
                    return(false);
                }
                //world.SetDebugLevel(1);
                world.Run((uint)windowHandle);
            }
            catch (Exception ex)
            {
                LogError("exception starting 3D  " + ex.Message);
            }
            if (world.IsRunning())
            {
                ThreadStart eventloop = new ThreadStart(EventLoop);
                Thread      thread    = new Thread(eventloop);
                bool        loadasync = World.DoAsyncLoad;

                if (MediaDir != null)
                {
                    world.SetMediaDir(MediaDir);
                }
                if (ContentFile != null)
                {
                    world.FileName = GetMediaPath(ContentFile);
                }
                else
                {
                    loadasync = false;
                }
                thread.Start();
                if (!loadasync)
                {
                    try
                    {
                        scene = MakeScene();
                        if (scene != null)
                        {
                            world.SetScene(scene);
                        }
                    }
                    catch (Exception ex)
                    {
                        SharedWorld.LogError("exception making initial scene " + ex.Message);
                    }
                }
                scene = world.GetScene();
                if (scene != null)
                {
                    scene.OnResize();
                }
                return(true);
            }
            return(false);
        }