Beispiel #1
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);
        }
Beispiel #2
0
        private void Robot_Load(object sender, EventArgs e)
        {
            //Tracking
            //pictureBox27.Load(Application.StartupPath + "\\Resources\\image1.jpg");
            /////3D
            lights = new TVLightEngine();
            globals = new TVGlobals();
            atmosphere = new TVAtmosphere();
            maths = new TVMathLibrary();
            materialfactory = new TVMaterialFactory();
            texturefactory = new TVTextureFactory();
            tv = new TVEngine();
            physics = new TVPhysics();

            //Setup TV
            tv.SetDebugMode(true, true);
            tv.SetDebugFile(System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\debugfile.txt");
            tv.SetAntialiasing(true, CONST_TV_MULTISAMPLE_TYPE.TV_MULTISAMPLE_2_SAMPLES);

            //Enter Your Beta Username And Password Here
            //tv.SetBetaKey("", "");

            tv.SetAngleSystem(CONST_TV_ANGLE.TV_ANGLE_DEGREE);
            //tv.Init3DWindowed(this.Handle, true);
            tv.Init3DWindowed(this.pictureBox3D.Handle, true);
            tv.GetViewport().SetAutoResize(true);
            tv.DisplayFPS(true);
            tv.SetVSync(true);

            scene = new TVScene();

            input = new TVInputEngine();
            input.Initialize(true, true);

            camera = new TVCamera();
            camera = scene.GetCamera();
            camera.SetViewFrustum(45, 1000, 0.1f);
            camera.SetPosition(0, 5, -20);
            camera.SetLookAt(0, 3, 0);

            viewport = new TVViewport();
            viewport = tv.CreateViewport(this.Handle, "viewport");
            viewport.SetCamera(camera);
            viewport.SetBackgroundColor(Color.Blue.ToArgb());
            bDoLoop = true;

            InitSound();
            InitMaterials();
            InitTextures();
            InitFonts();
            InitShaders();
            InitEnvironment();
            InitPhysics();
            InitLandscape();
            InitObjects();
            InitLights();
            InitPhysicsMaterials();
            Init2DText();

            this.Show();
            this.Focus();

            GameLoop();

            tv = null;

            this.Close();
            //// /3D

            groupComPortDefault.Enabled             = false;
            groupComPortSettings.Enabled            = false;
            groupTcpClientServerSettings.Enabled    = false;
            groupTcpClientServerDefault.Enabled     = false;
            groupDirectionAndMotion.Enabled         = false;
            groupCameraRotation.Enabled             = false;
            groupCameraRot2.Enabled                 = false;
            groupAdvencedSuppDevices.Enabled        = false;
            groupJoystickInit.Enabled               = false;
            labelCommunicationType.Text             = null;
            labelConnectingStatus.Text              = null;
            labelJoystickName.Text                  = null;
            SetMap();
            Maps.SelectedItem = "TUKE";

            //Full Screen
            Options op = new Options();
            op = op.ReadOptionsFromFile();
            this.combo_method.SelectedIndex = op.Scale;
            this.combo_streams.SelectedIndex = op.Streams;
            this.textBox1.Text = op.Text;
            //this.lbl_foreColor.BackColor = ColorTranslator.FromHtml(op.ForeColor);
        }
Beispiel #3
0
        /// <summary>
        /// Initializes the engine, services and components.
        /// </summary>
        /// <param name="sender">Ignored</param>
        /// <param name="e">Ignored</param>
        void InitializeEngine(object sender, EventArgs e)
        {
            // Attach the looping events
            looping = new Looping(this);

            Engine = new TVEngine();
#if DEBUG
            Engine.SetDebugMode(true, true, true, false);
            Engine.SetDebugFile(settings.DebugFile.FullName);
#else
            Engine.SetDebugMode(false, false, false, false);
            Engine.DisplayFPS(false);
#endif
            Engine.AllowMultithreading(settings.MultiThreading);

            if (File.Exists(GetType().Assembly.GetName().Name + ".lic"))
            {
                Engine.SetLicenseFile(GetType().Assembly.GetName().Name + ".lic");
            }

            // When we use doubles, we need double-precision.
            Engine.SetFPUPrecision(true);

            // Set default component update frequency value.
            if (settings.UpdateFrequency.Equals(0f))
            {
                settings.UpdateFrequency = 1f / 60f;
            }

            SetMultisample();

            // Create render form.
            settings.RenderForm = new RenderForm();

            // Apply v sync option.
            Engine.SetVSync(settings.VSync);

            // Use current settings by default if none are given.
            screenWidth  = Screen.PrimaryScreen.Bounds.Width;
            screenHeight = Screen.PrimaryScreen.Bounds.Height;

            if (settings.ScreenMode.Width == 0 || settings.ScreenMode.Height == 0)
            {
                settings.ScreenMode.Width  = screenWidth;
                settings.ScreenMode.Height = Screen.PrimaryScreen.Bounds.Height;
            }
            if (settings.ScreenMode.Format == 0)
            {
                settings.ScreenMode.Format = screenHeight;
            }

            bool initSuccess = false;

            if (settings.Fullscreen)
            {
                try
                {
                    initSuccess = Engine.Init3DFullscreen(settings.ScreenMode.Width, settings.ScreenMode.Height,
                                                          settings.ScreenMode.Format, true, settings.VSync,
                                                          CONST_TV_DEPTHBUFFERFORMAT.TV_DEPTHBUFFER_BESTBUFFER, 1, settings.RenderForm.Handle);
                }
                catch (AccessViolationException) { /* License failure */ }
            }
            else
            {
                try
                {
                    // Resize windowed form and move to center screen.
                    settings.RenderForm.Size = new System.Drawing.Size(settings.ScreenMode.Width, settings.ScreenMode.Height);
                    settings.RenderForm.Top  = (screenHeight - settings.ScreenMode.Height) / 2;
                    settings.RenderForm.Left = (screenWidth - settings.ScreenMode.Width) / 2;

                    initSuccess = Engine.Init3DWindowed(settings.RenderForm.Handle, true);
                }
                catch (AccessViolationException) { /* License failure */ }
            }

            // Apply auto resize.
            Engine.GetViewport().SetAutoResize(true);

            // Probably a license failure
            if (!initSuccess)
            {
                MessageBox.Show("Couldn't initialize engine! Exiting.", "Critical error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Idle -= InitializeEngine;
                Dispose();
                Application.Exit();
                return;
            }

            // Initialize physics
            Physics.Initialize();
            Physics.SetSolverModel(CONST_TV_PHYSICS_SOLVER.TV_SOLVER_ADAPTIVE);
            Physics.SetFrictionModel(CONST_TV_PHYSICS_FRICTION.TV_FRICTION_ADAPTIVE);
            Physics.SetGlobalGravity(new TV_3DVECTOR(0, -14.8f, 0));
            Physics.EnableCPUOptimizations(true);

            // Initialize input
            InputEngine.Initialize(true, true);

            // If nothing is found, just don't hook the events
            if (settings.RenderForm != null)
            {
                settings.RenderForm.FormClosing += (_, __) => Exit();
                //settings.RenderForm.Deactivate += (_, __) => looping.PauseLoop();
                //settings.RenderForm.Activated += delegate
                //{
                //    // Silly workaround
                //    InputEngine.ClearKeyBuffer();
                //    InputEngine.ForceUpdate();
                //    stopwatch.Reset();
                //    looping.ResumeLoop();
                //};
            }

            Initialize();

            if (!settings.Fullscreen)
            {
                settings.RenderForm.Show();
            }

            Application.Idle -= InitializeEngine;
        }
Beispiel #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);
		}
Beispiel #5
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);
        }