Example #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();
        }
Example #2
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);
        }
Example #3
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);
        }
Example #4
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);
        }
Example #5
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);
        }
        //*** Render Method
        private void SetupScene(IntPtr hWnd)
        {
            TV_3DVECTOR Min = new TV_3DVECTOR();
            TV_3DVECTOR Max = new TV_3DVECTOR();
            TV_3DVECTOR Offset = new TV_3DVECTOR();
            TV_3DVECTOR SphereCenter = new TV_3DVECTOR();
            TV_3DVECTOR posVector = new TV_3DVECTOR();

            TV = new TVEngine();
            Scene = new TVScene();
            Cam = new TVCamera();
            TF = new TVTextureFactory();
            Mats = new TVMaterialFactory();
            Lights = new TVLightEngine();
            Maths = new TVMathLibrary();

            //Initialize the TV engine
            TV.SetDebugFile(Application.StartupPath + "\\debug.txt");
            TV.Init3DWindowed(hWnd, true);
            TV.SetSearchDirectory(Application.StartupPath);
            TV.SetAngleSystem(CONST_TV_ANGLE.TV_ANGLE_DEGREE);  // use degree system

            Scene.SetBackgroundColor(0.6f, 0.6f, 0.6f);

            //Load the texture into the integer ID holder
            FloorTex = TF.LoadTexture("smallGrid.bmp", "Grid", -1, -1, CONST_TV_COLORKEY.TV_COLORKEY_NO, true);
            WallTex = TF.LoadTexture("smallGridWall.bmp", "Wall", -1, -1, CONST_TV_COLORKEY.TV_COLORKEY_NO, true);

            Room = Scene.CreateMeshBuilder("Room");
            Room.AddFloor(FloorTex, -300.0f, -300.0f, 300.0f, 300.0f, 0, 15.0f, 15.0f, true);
            Room.AddWall(WallTex, -300.0f, 300.0f, 300.0f, 300.0f, 400.0f, 0, 15.0f, 15.0f, true);
            Room.AddWall(WallTex, 300.0f, -300.0f, -300.0f, -300.0f, 400.0f, 0, 15.0f, 15.0f, true);
            Room.AddWall(WallTex, 300.0f, 300.0f, 300.0f, -300.0f, 400.0f, 0, 15.0f, 15.0f, true);
            Room.AddWall(WallTex, -300.0f, -300.0f, -300.0f, 300.0f, 400.0f, 0, 15.0f, 15.0f, true);
            //ShowVector("RoomLocal", Room.GetPosition());
            //ShowVector("RoomWorld", Room.GetWorldPosition(Room.GetPosition()));

            SensorNode = Scene.CreateMeshBuilder("SensorNode");
            SensorNode.LoadXFile("N70.X", true, true);
            SensorNode.SetParent(CONST_TV_NODETYPE.TV_NODETYPE_MESH, Room.GetIndex(), 1);
            SensorNode.SetPosition(0.0f, 150.0f, 0.0f);
            TV_3DVECTOR oriScale = SensorNode.GetScale();
            SensorNode.SetScale(oriScale.x, oriScale.y, oriScale.z * 1.5f);
            SensorNode.SetLightingMode(CONST_TV_LIGHTINGMODE.TV_LIGHTING_NORMAL, 0, 1);
            SensorNode.SetRotation(90.0f, 0.0f, 0.0f);
            //SensorNode.GetBoundingBox(ref Min, ref Max, true);
            //SensorNode.ShowBoundingBox(true);
            //ShowVector("MoteLocal", SensorNode.GetPosition());
            //ShowVector("MoteWorld", Room.GetWorldPosition(SensorNode.GetPosition()));

            //WiimoteMesh = Scene.CreateMeshBuilder("Wiimote");
            //WiimoteMesh.LoadXFile("Wiimote.X", true, true);
            //TV_3DVECTOR oriScale = WiimoteMesh.GetScale();
            //WiimoteMesh.SetScale(oriScale.x * 0.15f, oriScale.y * 0.15f, oriScale.z * 0.15f);
            //WiimoteMesh.SetPosition(0.0f, 70.0f, 0.0f);
            //WiimoteMesh.SetLightingMode(CONST_TV_LIGHTINGMODE.TV_LIGHTING_NORMAL, 0, 1);//Tell TV we want normal, per-vertex, lighting with 1 point light.

            Cam.SetParent(CONST_TV_NODETYPE.TV_NODETYPE_MESH, Room.GetIndex(), 0);
            Cam.SetPosition(0.0f, 250.0f, 200.0f);
            Cam.LookAtMesh(SensorNode);
            //ShowVector("CamLocal", Cam.GetPosition());
            //ShowVector("CamWorld", Room.GetWorldPosition(Cam.GetPosition()));

            //Create a point light. Again, these can be more complex.
            IDLight = Lights.CreatePointLight(new TV_3DVECTOR(0.0f, 250.0f, 200.0f), 0.9f, 0.9f, 0.9f, 250.0f);
            IDBackLight = Lights.CreatePointLight(new TV_3DVECTOR(0.0f, 250.0f, -200.0f), 0.1f, 0.1f, 0.1f, 250.0f);
            Lights.SetSpecularLighting(false);
        }
Example #7
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);
        }