Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        private void Main_Loop()
        {
            // Okay, we start the main loop here. We are going to loop over
            // and over until the user click on the "Quit" button and by this,
            // change the value of DoLoop to false.

            // We loop all of this until the DoLoop isn't True.
            while (DoLoop == true)
            {
                // Let us the capacity to use buttons of the form.
                System.Windows.Forms.Application.DoEvents();

                // New : We moved the movement code in an other sub to make
                // the code clearer.
                Check_Input();

                if (InputEngine.IsKeyPressed(CONST_TV_KEY.TV_KEY_Z))
                {
                    Scene.SetRenderMode(CONST_TV_RENDERMODE.TV_LINE);
                }
                else
                {
                    Scene.SetRenderMode(CONST_TV_RENDERMODE.TV_SOLID);
                }

                // New : We moved the checking of maximum camera "look at" and
                // also the camera movement smoothing in an other sub too.
                Check_Movement();

                //render surfaces before tv3d.clear or you get funkey results
                RenderSurf1.StartRender(false);
                Atmos.Atmosphere_Render();
                //Land.Render();
                RenderSurf1.EndRender();
                RenderSurf2.StartRender(false);
                Atmos.Atmosphere_Render();
                //Land.Render();
                RenderSurf2.EndRender();

                // Clear the the last frame.
                TV.Clear(false);

                // New : if we are below the waterheight, this means the we are
                // underwater. To give a cool underwater effect, we will add fog.
                // If we are over the ground, then don't add the fog but render
                // the lens flare.

                /*
                 * if (sngPositionY < sngWaterHeight)
                 * {
                 *  //' Render a blue fog to simulate under water.
                 *  Atmos.Fog_Enable(true);
                 *  Atmos.Fog_SetColor(0f, 0.4f, 0.5f);
                 *  Atmos.Fog_SetParameters(0f, 0f, 0.01f);
                 *  Atmos.Fog_SetType(CONST_TV_FOG.TV_FOG_EXP, CONST_TV_FOGTYPE.TV_FOGTYPE_RANGE);
                 *  Atmos.LensFlare_Enable(false);
                 * }
                 * else
                 * {*/
                // New : we have to render the lens flare.
                Atmos.LensFlare_Enable(true);
                Atmos.Fog_Enable(false);

                /*Atmos.Fog_Enable(true);
                 * Atmos.Fog_SetColor(1, 1, 1);
                 * Atmos.Fog_SetParameters(50f, 100f, 0.01f);
                 * Atmos.Fog_SetType(CONST_TV_FOG.TV_FOG_LINEAR, CONST_TV_FOGTYPE.TV_FOGTYPE_VERTEX);*/
                //}

                // New have to render the sky, the sun and lens flares
                Atmos.Atmosphere_Render();

                // New : we have to render the landscape.
                //Land.Render();
                WMap.Render();
                //Scene.RenderAll(false);

                // We render all the 3D objects contained in the scene.
                //Scene.RenderAllMeshes(true);

                // We display everything that we have rendered
                TV.RenderToScreen();

                WorldPosition PlayerPos = WMap.GetPlayerPosition();
                GlobalVars.GameForm.Text = "Pos:" + sngPositionX + " (" + PlayerPos.TileX + ");" + sngPositionY + ";" + sngPositionZ + " (" + PlayerPos.TileZ + ") + (" + PlayerPos.TilePosX + ";" + PlayerPos.TilePosY + ";" + PlayerPos.TilePosZ + ")";
                //GlobalVars.GameForm.Text = Scene.GetTriangleNumber().ToString();
            }

            // We ask to quit.
            this.Quit();
        }
Ejemplo n.º 3
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);
		}