Exemplo n.º 1
0
        public void Quit()
        {
            //first of all, we close the world map manager
            WMap.Quit();

            // We want to quit the project, so we start by desroyng
            // the texture factory.
            TextureFactory = null;

            // We destroy the land and Atmos object.
            Land  = null;
            Atmos = null;
            // Don't forget to destroy the inputengine object...
            InputEngine = null;

            // Dispose of the GFX effect class
            GraphicFX = null;

            // Then, we destroy the scene object.
            Scene = null;

            // Dispose the Globals Object
            Globals = null;
            // We finish the frenetic destroy with the TV object.
            TV = null;
        }
Exemplo n.º 2
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.º 3
0
        public void Quit()
        {
            WMap.LoadThreadWork           = false;
            WMap.LoadHeightmapsThreadWork = false;

            // We want to quit the project, so we start by desroyng
            // the texture factory.
            TextureFactory = null;

            // We destroy the land and Atmos object.
            Land  = null;
            Atmos = null;
            // Don't forget to destroy the inputengine object...
            InputEngine = null;

            // Dispose of the GFX effect class
            GraphicFX = null;

            // Then, we destroy the scene object.
            Scene = null;

            // Dispose the Globals Object
            Globals = null;
            // We finish the frenetic destroy with the TV object.
            TV = null;
        }
Exemplo n.º 4
0
        public GameManager()
        {
            TotalTimeElapsed = 0;

            TvEngine = new TVEngine();
            TvEngine.DisplayFPS(true);

            if (windowed)
            {
                Form1 form = new Form1(this);
                form.Show();
                TvEngine.Init3DWindowed(form.Handle);
            }
            else
            {
                TvEngine.Init3DFullscreen(ScreenWidth, ScreenHeight);
            }

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

            TvScene  = new TVScene();
            TvCamera = TvScene.GetCamera();

            TvPhysics = new TVPhysics();
            TvPhysics.Initialize();
            TvPhysics.SetSolverModel(CONST_TV_PHYSICS_SOLVER.TV_SOLVER_LINEAR_10_PASSES);
            TvPhysics.SetFrictionModel(CONST_TV_PHYSICS_FRICTION.TV_FRICTION_EXACT);
            TvPhysics.SetGlobalGravity(new TV_3DVECTOR(0F, -980F, 0F));

            TvPhysics.SetMaterialInteractionContinuousCollision(0, 0, true);
            TvPhysics.SetMaterialInteractionFriction(0, 0, 0.000001f, 0.000001f);
            TvPhysics.SetMaterialInteractionBounciness(0, 0, 0.5f);

            TvMaths = new TVMathLibrary();

            TvScreen2DText = new TVScreen2DText();

            TvLights    = new TVLightEngine();
            TvMaterials = new TVMaterialFactory();
            TvGlobals   = new TVGlobals();

            Message = new MessageManager(this);
        }
Exemplo n.º 5
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.º 6
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.º 7
0
        //3D MODEL
        //////////
        public void Init3D()
        {
            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);
        }
Exemplo n.º 8
0
        public void Init()
        {
            //bool DebugToConsole = true;

            // We have to create the TV object before anything else.
            TV = new TVEngine();

            // Set the search directory of the objects, textures, ...
            TV.SetSearchDirectory(Application.StartupPath);

            // We put the debug file in the app directory
            //TV.SetDebugFile(Application.StartupPath + "\\WorldEngine-Debug.txt");
            //TV.SetDebugMode(true, true, DebugToConsole);
            TV.SetDebugMode(false, false, false, false);

            // We initialize TV in the picture box of the form.
            TV.Init3DWindowed(GameHandle);

            // We want to see the FPS.
            TV.DisplayFPS(true);

            // We create the TVGlobals object.
            Globals = new TVGlobals();

            // We create the input object.
            InputEngine = new TVInputEngine();
            InputEngine.Initialize();

            // New : we create the graphic object so we can add some fog.
            GraphicFX = new TVGraphicEffect();

            // We create the scene (the world).
            Scene = new TVScene();
            //Scene.SetViewFrustum(45, 20000);
            //Scene.SetViewFrustum(45, 20);

            // We create the atmosphere class
            Atmos = new TVAtmosphere();

            // As said above, we need to create a new object which will
            // hold all the textures needed for our land.
            TextureFactory = new TVTextureFactory();

            // We load the sky texture.
            TextureFactory.LoadTexture("Media\\sky\\sunset\\up.jpg", "SkyTop", -1, -1);
            TextureFactory.LoadTexture("Media\\sky\\sunset\\down.jpg", "SkyBottom", -1, -1);
            TextureFactory.LoadTexture("Media\\sky\\sunset\\left.jpg", "SkyLeft", -1, -1);
            TextureFactory.LoadTexture("Media\\sky\\sunset\\right.jpg", "SkyRight", -1, -1);
            TextureFactory.LoadTexture("Media\\sky\\sunset\\front.jpg", "SkyFront", -1, -1);
            TextureFactory.LoadTexture("Media\\sky\\sunset\\back.jpg", "SkyBack", -1, -1);

            // We set the sky textures.
            Atmos.SkyBox_SetTexture(Globals.GetTex("SkyFront"), Globals.GetTex("SkyBack"), Globals.GetTex("SkyLeft"), Globals.GetTex("SkyRight"), Globals.GetTex("SkyTop"), Globals.GetTex("SkyBottom"));
            Atmos.SkyBox_Enable(true);

            // New : the land generation. This is so much fun because it's
            // so simple! You load a texture as a height map, the engine
            // does the rest. But before this, we create the land object.
            Land = new TVLandscape();
            //Land = Scene.CreateLandscape("Land");

            // Generate the height of the land from the grayscale of the image.
            //Land.GenerateTerrain("Media\\heightmap.jpg", CONST_TV_LANDSCAPE_PRECISION.TV_PRECISION_LOW, 8, 8, -1024, 0, -1024, true);
            //Land.CreateEmptyTerrain(CONST_TV_LANDSCAPE_PRECISION.TV_PRECISION_LOW, 1, 1, -128, 0, -128);

            // Because we don't want to have mountains with height that get to
            // the clouds, we adjust the height (Y) factor.
            //Land.SetScale(1, 0.7f, 1);

            // Then, we load the land texture.
            TextureFactory.LoadTexture("Media\\dirtandgrass.jpg", "LandTexture", -1, -1, CONST_TV_COLORKEY.TV_COLORKEY_NO, true);
            TextureFactory.LoadTexture("Media\\dirtandgrass2.jpg", "LandTexture2", -1, -1, CONST_TV_COLORKEY.TV_COLORKEY_NO, true);

            //...The splatting texture...
            TextureFactory.LoadTexture("Media\\grass.dds", "SplattingTexture", -1, -1, CONST_TV_COLORKEY.TV_COLORKEY_NO, true);
            TextureFactory.LoadTexture("Media\\grassa.dds", "SplattingAlphaTexture", -1, -1, CONST_TV_COLORKEY.TV_COLORKEY_NO, true);

            // We assign a texture to that land.
            //Land.SetTexture(Globals.GetTex("LandTexture"), -1);
            //Land.SetTextureScale(3, 3, -1);

            // New : the sun. We have to place the sun in the world. Just like the
            // sky box, the sun is attached to the camera position vector. You will
            // never notice it until you start playing really badly with the
            // properties of the sun. Let's start by loading a texture for it.
            TextureFactory.LoadTexture("Media\\sun.jpg", "Sun", -1, -1, CONST_TV_COLORKEY.TV_COLORKEY_NO, true);

            // Then, initialize it by placing it via a vector.
            Atmos.Sun_SetTexture(Globals.GetTex("Sun"));
            Atmos.Sun_SetBillboardSize(1);
            Atmos.Sun_SetPosition(-1000f, 570f, 0f);
            Atmos.Sun_Enable(true);

            // New : To add extra visual effects, we add a lens flare effect. For
            // this, we have to load some cirles that will be used to simulate
            // the flare effect.
            TextureFactory.LoadTexture("Media\\flare1.jpg", "Flare1", -1, -1, CONST_TV_COLORKEY.TV_COLORKEY_NO, true);
            TextureFactory.LoadTexture("Media\\flare2.jpg", "Flare2", -1, -1, CONST_TV_COLORKEY.TV_COLORKEY_NO, true);
            TextureFactory.LoadTexture("Media\\flare3.jpg", "Flare3", -1, -1, CONST_TV_COLORKEY.TV_COLORKEY_NO, true);
            TextureFactory.LoadTexture("Media\\flare4.jpg", "Flare4", -1, -1, CONST_TV_COLORKEY.TV_COLORKEY_NO, true);

            // Initialize the lens flares.
            Atmos.LensFlare_SetLensNumber(4);
            Atmos.LensFlare_Enable(true);
            Atmos.LensFlare_SetLensParams(0, Globals.GetTex("Flare1"), 2 * 5f, 40, Globals.RGBA(1f, 1f, 1f, 0.5f), Globals.RGBA(1f, 1f, 1f, 0.5f));
            Atmos.LensFlare_SetLensParams(1, Globals.GetTex("Flare2"), 2 * 1f, 18, Globals.RGBA(1f, 1f, 1f, 0.5f), Globals.RGBA(1f, 1f, 1f, 0.5f));
            Atmos.LensFlare_SetLensParams(2, Globals.GetTex("Flare3"), 2 * 1.8f, 15, Globals.RGBA(1f, 1f, 1f, 0.5f), Globals.RGBA(0.7f, 1f, 1f, 0.5f));
            Atmos.LensFlare_SetLensParams(3, Globals.GetTex("Flare4"), 2 * 1f, 6, Globals.RGBA(1f, 0.1f, 0f, 0.5f), Globals.RGBA(0.5f, 1f, 1f, 0.5f));

            // New : also for fun, we add water. We start by loading the
            // water tetxure...

            sngWaterHeight = -1; //60
            TextureFactory.LoadTexture("Media\\water.bmp", "Water");

            WaterMesh = Scene.CreateMeshBuilder();
            WaterMesh.AddFloor(Globals.GetTex("Water"), -700, 0, (8 * 256) - 700, 8 * 256, sngWaterHeight, 1, 1, false);
            RenderSurf1 = Scene.CreateRenderSurface(256, 256, true);
            RenderSurf2 = Scene.CreateRenderSurface(256, 256, true);
            WPlane.Dist = -sngWaterHeight;
            WPlane.Normal = new TV_3DVECTOR(0, 1, 0);
            RenderSurf1.SetBackgroundColor(355);
            GraphicFX.SetWaterReflection(WaterMesh, RenderSurf1, RenderSurf2, 0, WPlane);

            // New : for fun, we will also add some clouds, just over the water
            // to give a creepy fog effect. Let's start by loading the clouds textures.
            TextureFactory.LoadTexture("Media\\cloud1.dds", "Clouds", -1, -1, CONST_TV_COLORKEY.TV_COLORKEY_BLACK, true);

            // Then, set the land's clouds.
            Atmos.Clouds_Create(1, 1024, 1024);
            Atmos.Clouds_SetLayerParameters(0, 300, Globals.GetTex("Clouds"));
            Atmos.Clouds_SetLayerAnimation(0, true, 0.01f, 0.01f);

            // We set the camera vectors (position and look at) and angles.
            sngPositionX = 0f;
            sngPositionY = 20f;
            sngPositionZ = 0f;
            snglookatX = 0f;
            snglookatY = 20f;
            snglookatZ = 50f;
            sngAngleX = 0f;
            sngAngleY = 0f;

            // We set the initial values of movement
            sngWalk = 0f;
            sngStrafe = 0f;

            // Set the viewing distance
            Scene.SetViewFrustum(60f, 900f); //"random" values, TODO : Check for better ones ?
            //http://www.truevision3d.com/forums/tv3d_sdk_63/about_tilemap-t3865.0.html;prev_next=prev

            // We pop the form over everything else.

            //We create the world map
            WMap = new WorldMap(Scene);

            // We start the main loop. You can't create the MainLoop by using the
            // toolbox buttons, nor by clicking on the form "Form1" : you have to
            // create it by yourself. It's not as hard as it may sound...
            DoLoop = true;

            TV.EnableProfiler(true, false);

            Main_Loop();
        }
Exemplo n.º 9
0
        public void Quit()
        {
            //first of all, we close the world map manager
            WMap.Quit();

            // We want to quit the project, so we start by desroyng
            // the texture factory.
            TextureFactory = null;

            // We destroy the land and Atmos object.
            Land = null;
            Atmos = null;
            // Don't forget to destroy the inputengine object...
            InputEngine = null;

            // Dispose of the GFX effect class
            GraphicFX = null;

            // Then, we destroy the scene object.
            Scene = null;

            // Dispose the Globals Object
            Globals = null;
            // We finish the frenetic destroy with the TV object.
            TV = null;
        }
Exemplo n.º 10
0
        //Inicializace enginu
        private void VytvorScenu()
        {
            TV = new TVEngine();

            //Povoleni debug zprav
            TV.SetDebugMode(true, true);
            //Nastaveni debug souboru pro ladeni chyb
            TV.SetDebugFile(System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\debugfile.txt");

            //Incizializace enginu
            TV.Init3DWindowed(this.panel2.Handle, true);

            //Nastaveni defaultniho adresare
            TV.SetSearchDirectory(Environment.CurrentDirectory);

            //Nastaveni samoobnovy velikosti obrazu dle okna
            TV.GetViewport().SetAutoResize(true);

            //Zobrazeni FPS
            TV.DisplayFPS(false);

            //Nastaveni preferovaneho uhloveho systemu
            TV.SetAngleSystem(MTV3D65.CONST_TV_ANGLE.TV_ANGLE_DEGREE);

            //Inicializace vsechno enginovych doplnku
            Scene = new TVScene();
            Globals = new TVGlobals();
            Input = new TVInputEngine();
            MatFactory = new TVMaterialFactory();
            TexFactory = new TVTextureFactory();

            //Povoleni mysi a klavesnice na vsup
            Input.Initialize(true, true);
        }
Exemplo n.º 11
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);
        }
Exemplo n.º 12
0
        public void Quit()
        {
            WMap.LoadThreadWork = false;
            WMap.LoadHeightmapsThreadWork = false;

            // We want to quit the project, so we start by desroyng
            // the texture factory.
            TextureFactory = null;

            // We destroy the land and Atmos object.
            Land = null;
            Atmos = null;
            // Don't forget to destroy the inputengine object...
            InputEngine = null;

            // Dispose of the GFX effect class
            GraphicFX = null;

            // Then, we destroy the scene object.
            Scene = null;

            // Dispose the Globals Object
            Globals = null;
            // We finish the frenetic destroy with the TV object.
            TV = null;
        }
Exemplo n.º 13
0
        public void Init()
        {
            //bool DebugToConsole = true;

            // We have to create the TV object before anything else.
            TV = new TVEngine();

            // Set the search directory of the objects, textures, ...
            TV.SetSearchDirectory(Application.StartupPath);

            // We put the debug file in the app directory
            //TV.SetDebugFile(Application.StartupPath + "\\WorldEngine-Debug.txt");
            //TV.SetDebugMode(true, true, DebugToConsole);
            TV.SetDebugMode(false, false, false, false);

            // We initialize TV in the picture box of the form.
            TV.Init3DWindowed(GameHandle);

            // We want to see the FPS.
            TV.DisplayFPS(true);

            // We create the TVGlobals object.
            Globals = new TVGlobals();

            // We create the input object.
            InputEngine = new TVInputEngine();
            InputEngine.Initialize();

            // New : we create the graphic object so we can add some fog.
            GraphicFX = new TVGraphicEffect();

            // We create the scene (the world).
            Scene = new TVScene();
            //Scene.SetViewFrustum(45, 20000);
            //Scene.SetViewFrustum(45, 20);

            // We create the atmosphere class
            Atmos = new TVAtmosphere();

            // As said above, we need to create a new object which will
            // hold all the textures needed for our land.
            TextureFactory = new TVTextureFactory();

            // We load the sky texture.
            TextureFactory.LoadTexture("Media\\sky\\sunset\\up.jpg", "SkyTop", -1, -1);
            TextureFactory.LoadTexture("Media\\sky\\sunset\\down.jpg", "SkyBottom", -1, -1);
            TextureFactory.LoadTexture("Media\\sky\\sunset\\left.jpg", "SkyLeft", -1, -1);
            TextureFactory.LoadTexture("Media\\sky\\sunset\\right.jpg", "SkyRight", -1, -1);
            TextureFactory.LoadTexture("Media\\sky\\sunset\\front.jpg", "SkyFront", -1, -1);
            TextureFactory.LoadTexture("Media\\sky\\sunset\\back.jpg", "SkyBack", -1, -1);

            // We set the sky textures.
            Atmos.SkyBox_SetTexture(Globals.GetTex("SkyFront"), Globals.GetTex("SkyBack"), Globals.GetTex("SkyLeft"), Globals.GetTex("SkyRight"), Globals.GetTex("SkyTop"), Globals.GetTex("SkyBottom"));
            Atmos.SkyBox_Enable(true);

            // New : the land generation. This is so much fun because it's
            // so simple! You load a texture as a height map, the engine
            // does the rest. But before this, we create the land object.
            Land = new TVLandscape();
            //Land = Scene.CreateLandscape("Land");

            // Generate the height of the land from the grayscale of the image.
            //Land.GenerateTerrain("Media\\heightmap.jpg", CONST_TV_LANDSCAPE_PRECISION.TV_PRECISION_LOW, 8, 8, -1024, 0, -1024, true);
            //Land.CreateEmptyTerrain(CONST_TV_LANDSCAPE_PRECISION.TV_PRECISION_LOW, 1, 1, -128, 0, -128);

            // Because we don't want to have mountains with height that get to
            // the clouds, we adjust the height (Y) factor.
            //Land.SetScale(1, 0.7f, 1);

            // Then, we load the land texture.
            TextureFactory.LoadTexture("Media\\dirtandgrass.jpg", "LandTexture", -1, -1, CONST_TV_COLORKEY.TV_COLORKEY_NO, true);
            TextureFactory.LoadTexture("Media\\dirtandgrass2.jpg", "LandTexture2", -1, -1, CONST_TV_COLORKEY.TV_COLORKEY_NO, true);

            //...The splatting texture...
            TextureFactory.LoadTexture("Media\\grass.dds", "SplattingTexture", -1, -1, CONST_TV_COLORKEY.TV_COLORKEY_NO, true);
            TextureFactory.LoadTexture("Media\\grassa.dds", "SplattingAlphaTexture", -1, -1, CONST_TV_COLORKEY.TV_COLORKEY_NO, true);

            // We assign a texture to that land.
            //Land.SetTexture(Globals.GetTex("LandTexture"), -1);
            //Land.SetTextureScale(3, 3, -1);

            // New : the sun. We have to place the sun in the world. Just like the
            // sky box, the sun is attached to the camera position vector. You will
            // never notice it until you start playing really badly with the
            // properties of the sun. Let's start by loading a texture for it.
            TextureFactory.LoadTexture("Media\\sun.jpg", "Sun", -1, -1, CONST_TV_COLORKEY.TV_COLORKEY_NO, true);

            // Then, initialize it by placing it via a vector.
            Atmos.Sun_SetTexture(Globals.GetTex("Sun"));
            Atmos.Sun_SetBillboardSize(1);
            Atmos.Sun_SetPosition(-1000f, 570f, 0f);
            Atmos.Sun_Enable(true);

            // New : To add extra visual effects, we add a lens flare effect. For
            // this, we have to load some cirles that will be used to simulate
            // the flare effect.
            TextureFactory.LoadTexture("Media\\flare1.jpg", "Flare1", -1, -1, CONST_TV_COLORKEY.TV_COLORKEY_NO, true);
            TextureFactory.LoadTexture("Media\\flare2.jpg", "Flare2", -1, -1, CONST_TV_COLORKEY.TV_COLORKEY_NO, true);
            TextureFactory.LoadTexture("Media\\flare3.jpg", "Flare3", -1, -1, CONST_TV_COLORKEY.TV_COLORKEY_NO, true);
            TextureFactory.LoadTexture("Media\\flare4.jpg", "Flare4", -1, -1, CONST_TV_COLORKEY.TV_COLORKEY_NO, true);

            // Initialize the lens flares.
            Atmos.LensFlare_SetLensNumber(4);
            Atmos.LensFlare_Enable(true);
            Atmos.LensFlare_SetLensParams(0, Globals.GetTex("Flare1"), 2 * 5f, 40, Globals.RGBA(1f, 1f, 1f, 0.5f), Globals.RGBA(1f, 1f, 1f, 0.5f));
            Atmos.LensFlare_SetLensParams(1, Globals.GetTex("Flare2"), 2 * 1f, 18, Globals.RGBA(1f, 1f, 1f, 0.5f), Globals.RGBA(1f, 1f, 1f, 0.5f));
            Atmos.LensFlare_SetLensParams(2, Globals.GetTex("Flare3"), 2 * 1.8f, 15, Globals.RGBA(1f, 1f, 1f, 0.5f), Globals.RGBA(0.7f, 1f, 1f, 0.5f));
            Atmos.LensFlare_SetLensParams(3, Globals.GetTex("Flare4"), 2 * 1f, 6, Globals.RGBA(1f, 0.1f, 0f, 0.5f), Globals.RGBA(0.5f, 1f, 1f, 0.5f));

            // New : also for fun, we add water. We start by loading the
            // water tetxure...

            sngWaterHeight = -1; //60
            TextureFactory.LoadTexture("Media\\water.bmp", "Water");

            WaterMesh = Scene.CreateMeshBuilder();
            WaterMesh.AddFloor(Globals.GetTex("Water"), -700, 0, (8 * 256) - 700, 8 * 256, sngWaterHeight, 1, 1, false);
            RenderSurf1   = Scene.CreateRenderSurface(256, 256, true);
            RenderSurf2   = Scene.CreateRenderSurface(256, 256, true);
            WPlane.Dist   = -sngWaterHeight;
            WPlane.Normal = new TV_3DVECTOR(0, 1, 0);
            RenderSurf1.SetBackgroundColor(355);
            GraphicFX.SetWaterReflection(WaterMesh, RenderSurf1, RenderSurf2, 0, WPlane);

            // New : for fun, we will also add some clouds, just over the water
            // to give a creepy fog effect. Let's start by loading the clouds textures.
            TextureFactory.LoadTexture("Media\\cloud1.dds", "Clouds", -1, -1, CONST_TV_COLORKEY.TV_COLORKEY_BLACK, true);

            // Then, set the land's clouds.
            Atmos.Clouds_Create(1, 1024, 1024);
            Atmos.Clouds_SetLayerParameters(0, 300, Globals.GetTex("Clouds"));
            Atmos.Clouds_SetLayerAnimation(0, true, 0.01f, 0.01f);


            // We set the camera vectors (position and look at) and angles.
            sngPositionX = 0f;
            sngPositionY = 20f;
            sngPositionZ = 0f;
            snglookatX   = 0f;
            snglookatY   = 20f;
            snglookatZ   = 50f;
            sngAngleX    = 0f;
            sngAngleY    = 0f;

            // We set the initial values of movement
            sngWalk   = 0f;
            sngStrafe = 0f;

            // Set the viewing distance
            Scene.SetViewFrustum(60f, 900f); //"random" values, TODO : Check for better ones ?
            //http://www.truevision3d.com/forums/tv3d_sdk_63/about_tilemap-t3865.0.html;prev_next=prev

            // We pop the form over everything else.

            //We create the world map
            WMap = new WorldMap(Scene);

            // We start the main loop. You can't create the MainLoop by using the
            // toolbox buttons, nor by clicking on the form "Form1" : you have to
            // create it by yourself. It's not as hard as it may sound...
            DoLoop = true;

            TV.EnableProfiler(true, false);

            Main_Loop();
        }
Exemplo n.º 14
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.º 15
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.º 16
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);
        }