Exemplo n.º 1
0
        /// <summary>
        /// Parameterless constructor.
        /// Initializes references and identifies the run mode.
        /// </summary>
        public Core()
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
            Application.ThreadException        += new ThreadExceptionEventHandler(UIThreadException);
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledException);
            ctorParams = new object[] { this };

#if DEBUG
            runMode = RunMode.Debug;
#else
            runMode = RunMode.Release;
#endif

            Atmosphere        = new TVAtmosphere();
            CameraFactory     = new TVCameraFactory();
            Globals           = new TVGlobals();
            InputEngine       = new TVInputEngine();
            InternalObjects   = new TVInternalObjects();
            LightEngine       = new TVLightEngine();
            MathLibrary       = new TVMathLibrary();
            Physics           = new TVPhysics();
            Scene             = new TVScene();
            Screen2DImmediate = new TVScreen2DImmediate();
            Screen2DText      = new TVScreen2DText();
            TextureFactory    = new TVTextureFactory();
            MaterialFactory   = new TVMaterialFactory();
            GameControllers   = new TVGameControllers();
            DeviceInfo        = new TVDeviceInfo();
            GraphicEffect     = new TVGraphicEffect();
        }
Exemplo n.º 2
0
        public UIView(ICore core, UIType menuType, int width, int height, UIFlags flags, bool transparent)
            : base(core)
        {
            webCore            = core.GetService <IUIManagerService>().GetWebCore();
            this.menuType      = menuType;
            this.width         = width;
            this.height        = height;
            this.flags         = flags;
            this.isTransparent = transparent;
            isLoading          = false;
            pageLoaded         = false;
            webTextureID       = TextureFactory.CreateTexture(width, height, isTransparent);
            hudPosX            = 0;
            hudPosY            = 0;
            hud      = new TVScreen2DImmediate();
            Keyboard = core.GetService <IKeyboardService>();
            Mouse    = core.GetService <IMouseService>();
            JoyStick = core.GetService <IJoyStickService>();
            Gamepad  = core.GetService <IGamepadsService>();

            CanculateHudPosition(flags);

            View = webCore.CreateWebView(width, height, isTransparent, true);
            View.OnFinishLoading += OnFinishLoading;
            View.OnCallback      += OnCallback;
            View.Focus();

            buttonClickSound = Core.GetService <ISoundManagerService>().Load2DSound(Path.Combine(Application.StartupPath, @"Data\Sounds\menu\button_click.mp3"));
            buttonFocusSound = Core.GetService <ISoundManagerService>().Load2DSound(Path.Combine(Application.StartupPath, @"Data\Sounds\menu\button_focus.mp3"));
            Core.GetService <ISoundManagerService>().SetVolume(buttonClickSound, 0.5f);
            Core.GetService <ISoundManagerService>().SetVolume(buttonFocusSound, 0.5f);
        }
Exemplo n.º 3
0
        public void Terminate()
        {
            if (TV3DEngine != null)
            {
                TV3DEngine.ReleaseAll();
            }
            TV3DEngine = null;
            if (TV3DScene != null)
            {
                TV3DScene.DestroyAllMeshes();
            }
            TV3DScene = null;
            if (TexFactory != null)
            {
                TexFactory.DeleteAll();
            }
            TexFactory = null;
            if (Screen2DImmediate != null)
            {
                Screen2DImmediate = null;
            }
            Screen2DText = null;
            if (LightEngine != null)
            {
                LightEngine.DeleteAllLights();
            }
            LightEngine = null;
            Gl          = null;

            Camera = null;
            if (Atmosphere != null)
            {
                Atmosphere.Unload();
            }
            Atmosphere = null;
            if (Input != null)
            {
                Input.UnloadDevices();
            }
            Input = null;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initialise the scene
        /// </summary>
        /// <param name="window">The IWin32Window to render to.  System.Windows.Forms.Form implements IWin32Window</param>
        /// <param name="target">The render target</param>
        /// <param name="resolution">The resolution to render in</param>
        public void Initialise(IWin32Window window, EnumRenderTarget target, Resolution resolution)
        {
            if (TV3DEngine != null)
            {
                Terminate();
            }
            TV3DEngine = new TVEngine();
            try {
                Engine.TV3DEngine.Init3DWindowedMode(window.Handle.ToInt32(), true);
                //TV3DEngine.Init3DFullscreen( 800, 600, 16, true, false, CONST_TV_DEPTHMODE.TV_DEPTHBUFFER_BESTBUFFER, 1, 0 );
                _renderTarget = window;
            }
            catch (Exception e) {
                throw new EngineInitialisationException(e);
            }
            TV3DEngine.SetAngleSystem(CONST_TV_ANGLE.TV_ANGLE_DEGREE);
            TV3DEngine.SetVSync(true);
            TV3DEngine.DisplayFPS = true;
            TV3DScene             = new TVScene();
            TV3DScene.SetDepthBuffer(CONST_TV_DEPTHBUFFER.TV_WBUFFER);
            //TV3DScene.SetRenderMode( CONST_TV_RENDERMODE.TV_LINE );
            TV3DScene.SetTextureFilter(CONST_TV_TEXTUREFILTER.TV_FILTER_ANISOTROPIC);
            TexFactory        = new TVTextureFactory();
            Screen2DImmediate = new TVScreen2DImmediate();

            // TODO: this hax setting is to allow for clearing part of a rendersurface
            // would be nice if there is a better way....
            Screen2DImmediate.SETTINGS_SetBlendingMode(DxVBLibA.CONST_D3DBLEND.D3DBLEND_ZERO, DxVBLibA.CONST_D3DBLEND.D3DBLEND_ONE, false);

            Screen2DText = new TVScreen2DText();
            LightEngine  = new TVLightEngine();
            Gl           = new TVGlobals();
            Camera       = new TVCamera();
            Atmosphere   = new TVAtmosphere();
            Atmosphere.Fog_SetParameters(100F, 10000F, 0.0005F);
            Atmosphere.Fog_Enable(true);
            Input     = new TVInputEngine();
            FontIndex = Screen2DText.TextureFont_Create("font", "Verdana", 20, true, false, false, false);
        }
Exemplo n.º 5
0
        public UIView(ICore core, UIType menuType, int width, int height, UIFlags flags, bool transparent)
            : base(core)
        {
            webCore = core.GetService<IUIManagerService>().GetWebCore();
            this.menuType = menuType;
            this.width = width;
            this.height = height;
            this.flags = flags;
            this.isTransparent = transparent;
            isLoading = false;
            pageLoaded = false;
            webTextureID = TextureFactory.CreateTexture(width, height, isTransparent);
            hudPosX = 0;
            hudPosY = 0;
            hud = new TVScreen2DImmediate();
            Keyboard = core.GetService<IKeyboardService>();
            Mouse = core.GetService<IMouseService>();
            JoyStick = core.GetService<IJoyStickService>();
            Gamepad = core.GetService<IGamepadsService>();

            CanculateHudPosition(flags);

            View = webCore.CreateWebView(width, height, isTransparent, true);
            View.OnFinishLoading += OnFinishLoading;
            View.OnCallback += OnCallback;
            View.Focus();

            buttonClickSound = Core.GetService<ISoundManagerService>().Load2DSound(Path.Combine(Application.StartupPath, @"Data\Sounds\menu\button_click.mp3"));
            buttonFocusSound = Core.GetService<ISoundManagerService>().Load2DSound(Path.Combine(Application.StartupPath, @"Data\Sounds\menu\button_focus.mp3"));
            Core.GetService<ISoundManagerService>().SetVolume(buttonClickSound, 0.5f);
            Core.GetService<ISoundManagerService>().SetVolume(buttonFocusSound, 0.5f);
        }
Exemplo n.º 6
0
		public void Terminate() {
			if(TV3DEngine != null)
				TV3DEngine.ReleaseAll();
			TV3DEngine = null;
			if(TV3DScene != null)
				TV3DScene.DestroyAllMeshes();
			TV3DScene = null;
			if(TexFactory != null)
				TexFactory.DeleteAll();
			TexFactory = null;
			if(Screen2DImmediate != null)
				Screen2DImmediate = null;
			Screen2DText = null;
			if(LightEngine != null)
				LightEngine.DeleteAllLights();
			LightEngine = null;
			Gl = null;
			
			Camera = null;
			if(Atmosphere != null)
				Atmosphere.Unload();
			Atmosphere = null;
			if(Input != null)
				Input.UnloadDevices();
			Input = null;
		}
Exemplo n.º 7
0
		/// <summary>
		/// Initialise the scene
		/// </summary>
		/// <param name="window">The IWin32Window to render to.  System.Windows.Forms.Form implements IWin32Window</param>
		/// <param name="target">The render target</param>
		/// <param name="resolution">The resolution to render in</param>
		public void Initialise(IWin32Window window, EnumRenderTarget target, Resolution resolution) {
			if ( TV3DEngine != null ) {
				Terminate();
			}
			TV3DEngine = new TVEngine();
			try {
				Engine.TV3DEngine.Init3DWindowedMode(window.Handle.ToInt32(), true);
				//TV3DEngine.Init3DFullscreen( 800, 600, 16, true, false, CONST_TV_DEPTHMODE.TV_DEPTHBUFFER_BESTBUFFER, 1, 0 );
				_renderTarget = window;
			}
			catch(Exception e) {
				throw new EngineInitialisationException(e);
			}
			TV3DEngine.SetAngleSystem( CONST_TV_ANGLE.TV_ANGLE_DEGREE );
			TV3DEngine.SetVSync( true );
			TV3DEngine.DisplayFPS = true;
			TV3DScene = new TVScene();
			TV3DScene.SetDepthBuffer( CONST_TV_DEPTHBUFFER.TV_WBUFFER );
			//TV3DScene.SetRenderMode( CONST_TV_RENDERMODE.TV_LINE );
			TV3DScene.SetTextureFilter( CONST_TV_TEXTUREFILTER.TV_FILTER_ANISOTROPIC );
			TexFactory = new TVTextureFactory();
			Screen2DImmediate = new TVScreen2DImmediate();

			// TODO: this hax setting is to allow for clearing part of a rendersurface
			// would be nice if there is a better way....
			Screen2DImmediate.SETTINGS_SetBlendingMode( DxVBLibA.CONST_D3DBLEND.D3DBLEND_ZERO, DxVBLibA.CONST_D3DBLEND.D3DBLEND_ONE, false );

			Screen2DText = new TVScreen2DText();
			LightEngine = new TVLightEngine();
			Gl = new TVGlobals();
			Camera = new TVCamera();
			Atmosphere = new TVAtmosphere();
			Atmosphere.Fog_SetParameters( 100F, 10000F, 0.0005F );
			Atmosphere.Fog_Enable( true );
			Input = new TVInputEngine();
			FontIndex = Screen2DText.TextureFont_Create("font", "Verdana", 20, true, false, false, false);
		}
Exemplo n.º 8
0
        private void StartEngine()
        {
            Time = new GameTime();
            Components = new List<GameComponent>();

            Engine = new TVEngine();
            Scene = new TVScene();
            Screen2D = new TVScreen2DImmediate();
            Textures = new TVTextureFactory();
            Text2D = new TVScreen2DText();
            Globals = new TVGlobals();
            Materials = new TVMaterialFactory();
            Math = new TVMathLibrary();
            Effects = new TVGraphicEffect();
            Atmosphere = new TVAtmosphere();
            Internal = new TVInternalObjects();
            Light = new TVLightEngine();
            Input = new TVInputEngine();
            Random = new Random();

            Engine.SetInternalShaderVersion(CONST_TV_SHADERMODEL.TV_SHADERMODEL_BEST);
            Engine.SetAngleSystem(CONST_TV_ANGLE.TV_ANGLE_DEGREE);
            Engine.AllowMultithreading(true);
            Engine.SetFPUPrecision(true);
            Engine.EnableSmoothTime(false);
            Engine.SetDebugMode(true, true);
            Engine.SetDebugFile("debug.txt");
            Engine.EnableProfiler(false);
            Engine.DisplayFPS(false);
            Engine.SetVSync(false);
            Engine.SetAntialiasing(false, CONST_TV_MULTISAMPLE_TYPE.TV_MULTISAMPLE_NONE);

            Engine.Init3DWindowed(Form.Handle);
            //Engine.Init3DFullscreen(1920, 1200, 32, true, false, CONST_TV_DEPTHBUFFERFORMAT.TV_DEPTHBUFFER_BESTBUFFER, 1, Window.Handle);
            Engine.GetViewport().SetAutoResize(true);

            Input.Initialize(true, true);
            Input.SetRepetitionDelay(400, 100);

            Textures.SetTextureMode(CONST_TV_TEXTUREMODE.TV_TEXTUREMODE_BETTER);
            Light.SetGlobalAmbient(0, 0, 0);
        }