Exemplo n.º 1
0
        public NativeDesignView()
        {
            GameEngine.Initialize();
            Util3D.Init();

            QuadView.TopLeft = new NativeDesignControl(this)
            {
                ViewType = ViewTypes.Perspective
            };
            QuadView.TopRight = new NativeDesignControl(this)
            {
                ViewType = ViewTypes.Right
            };
            QuadView.BottomLeft = new NativeDesignControl(this)
            {
                ViewType = ViewTypes.Top
            };
            QuadView.BottomRight = new NativeDesignControl(this)
            {
                ViewType = ViewTypes.Front
            };

            // set control names.
            QuadView.TopLeft.Name     = "TopLeft";
            QuadView.TopRight.Name    = "TopRight";
            QuadView.BottomLeft.Name  = "BottomLeft";
            QuadView.BottomRight.Name = "BottomRight";



            ViewMode        = ViewModes.Single;
            ContextChanged += NativeDesignView_ContextChanged;
        }
Exemplo n.º 2
0
        /// <summary>
        /// init game engine
        /// call it one time during startup on the UI thread.</summary>
        public static void Init()
        {
            s_syncContext        = SynchronizationContext.Current;
            s_invalidateCallback = new InvalidateViewsDlg(InvalidateViews);
            try
            {
                GUILayer.EngineDevice.SetDefaultWorkingDirectory();
                s_engineDevice = new GUILayer.EngineDevice();
                s_engineDevice.AttachDefaultCompilers();
                s_retainedRenderResources = new GUILayer.RetainedRenderResources(s_engineDevice);
                s_underlyingScene         = new GUILayer.EditorSceneManager();
                Util3D.Init();
                XLEBridgeUtils.Utils.GlobalSceneManager = s_underlyingScene;
                s_entityInterface = s_underlyingScene.GetEntityInterface();
                CriticalError     = "";
                s_inist.PopulateEngineInfo(
                    @"<EngineInfo>
                        <SupportedResources>
                            <ResourceDescriptor Type='Model' Name='Model' Description='Model' Ext='.dae' />
                            <ResourceDescriptor Type='ModelBookmark' Name='ModelBookmark' Description='ModelBookmark' Ext='.modelbookmark' />
                            <ResourceDescriptor Type='Texture' Name='Texture' Description='Texture' Ext='.dds,.tga,.bmp,.jpg,.jpeg,.png,.tif,.tiff,.gif,.hpd,.jxr,.wdp,.ico,.hdr,.exr' />
                            <ResourceDescriptor Type='Prefab' Name='Prefab' Description='Prefab' Ext='.prefab' />
                        </SupportedResources>
                    </EngineInfo>");

                XLEBridgeUtils.Utils.AttachLibrary(s_engineDevice);
                s_loggingRedirect = new XLEBridgeUtils.LoggingRedirect();

                s_foregroundUpdateTimer          = new System.Windows.Forms.Timer();
                s_foregroundUpdateTimer.Tick    += s_foregroundUpdateTimer_Elapsed;
                s_foregroundUpdateTimer.Interval = 32;
                s_foregroundUpdateTimer.Start();
            }
            catch (Exception e)
            {
                CriticalError = "Error while initialising engine device: " + e.Message;
            }
        }
Exemplo n.º 3
0
        public NativeDesignView()
        {
            GameEngine.Initialize(QuadView.Handle);
            Util3D.Init();

            QuadView.TopLeft = new NativeDesignControl(this)
            {
                ViewType = ViewTypes.Perspective
            };
            QuadView.TopRight = new NativeDesignControl(this)
            {
                ViewType = ViewTypes.Right
            };
            QuadView.BottomLeft = new NativeDesignControl(this)
            {
                ViewType = ViewTypes.Top
            };
            QuadView.BottomRight = new NativeDesignControl(this)
            {
                ViewType = ViewTypes.Front
            };
            ViewMode        = ViewModes.Single;
            ContextChanged += new EventHandler(NativeDesignView_ContextChanged);
        }
Exemplo n.º 4
0
        /// <summary>
        /// init game engine
        /// call it one time during startup on the UI thread.</summary>
        public static void Init()
        {
            // the full dll name can be loaded in a config when needed.
            if (s_libHandle != IntPtr.Zero)
            {
                return;
            }

            CriticalError = s_notInitialized;
            try
            {
                Uri    uri    = new Uri(System.Windows.Forms.Application.StartupPath);
                string dllDir = uri.LocalPath + "\\NativePlugin";

                string dllName = "LvEdRenderingEngine.dll";

                if (IntPtr.Size == 4)
                {// 32 bit
                    s_fullDllName = dllDir + "\\x86\\" + dllName;
                }
                else if (IntPtr.Size == 8)
                {// 64 bit.
                    s_fullDllName = dllDir + "\\x64\\" + dllName;
                }
                else
                {
                    throw new Exception("unsupported address space");
                }

                if (!File.Exists(s_fullDllName))
                {
                    throw new FileNotFoundException(s_fullDllName);
                }

                s_libHandle = NativeMethods.LoadLibrary(s_fullDllName);
                if (s_libHandle == IntPtr.Zero)
                {
                    int hr = Marshal.GetHRForLastWin32Error();
                    Marshal.ThrowExceptionForHR(hr);
                }

                // verify entry points

                /*
                 * Type type = typeof(GameEngine);
                 *
                 * foreach (MethodInfo minfo in type.GetMethods(BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic))
                 * {
                 *  foreach( object obj in minfo.GetCustomAttributes(false))
                 *  {
                 *      DllImportAttribute dllimport = obj as DllImportAttribute;
                 *      if (dllimport != null)
                 *      {
                 *          string entryname = dllimport.EntryPoint;
                 *          // verify entry point name.
                 *          IntPtr fntPtr = NativeMethods.GetProcAddress(s_libHandle, entryname);
                 *          if (fntPtr == IntPtr.Zero)
                 *              throw new ArgumentException(string.Format("Can't find native function: {0}(...) in {1}", dllimport.EntryPoint, dllName));
                 *          break;
                 *      }
                 *  }
                 * }
                 */


                CriticalError = string.Empty;

                IntPtr data;
                s_invalidateCallback = new InvalidateViewsDlg(InvalidateViews);
                s_logInstance        = new LogCallbackType(LogCallback);
                NativeInitialize(s_logInstance, s_invalidateCallback, out data);
                if (data != IntPtr.Zero)
                {
                    string engineInfo = Marshal.PtrToStringUni(data);
                    s_inist.PopulateEngineInfo(engineInfo);
                }

                // get SynchronizationContext for current thread.
                // Note:
                s_syncContext = SynchronizationContext.Current;
                //Application.AddMessageFilter(new MessageFilter());

                Util3D.Init();
            }
            catch (Exception e)
            {
                Console.WriteLine("loading dll: " + s_fullDllName);
                Console.WriteLine("Engine init failed: " + e.Message);
                CriticalError = e.Message;
            }
        }